-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrag.py
30 lines (23 loc) · 778 Bytes
/
rag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from meilisearch import Client
meili_client = Client('http://127.0.0.1:7700')
index = meili_client.index('paper_id')
def search_in_meilisearch(query, requirements):
important_requirements = requirements[:4]
search_query = ' '.join(important_requirements)
search_results = index.search(search_query)
return search_results
def test():
query = "Find documents related to the given requirements."
requirements = [
"reminder system",
"autonomous vehicles",
"alerts",
"driver attentiveness",
"response time"
]
results = search_in_meilisearch(query, requirements)
print("hits length:", len(results['hits']))
print("Search Results:")
print(results)
if __name__ == "__main__":
test()