Update query.py
Browse filesfixing query endpoint
query.py
CHANGED
@@ -2,19 +2,14 @@ import requests
|
|
2 |
import json
|
3 |
|
4 |
def query_vectara(question, customer_id, api_key, corpus_key):
|
5 |
-
"""Queries the uploaded documents in Vectara API v2."""
|
6 |
-
url = f"https://api.vectara.io/v2/corpora/{corpus_key}/query"
|
7 |
headers = {
|
8 |
"x-api-key": api_key,
|
9 |
"Accept": "application/json"
|
10 |
}
|
11 |
|
12 |
-
|
13 |
-
"query": question,
|
14 |
-
"top_k": 5 # Retrieve top 5 relevant results
|
15 |
-
}
|
16 |
-
|
17 |
-
response = requests.get(url, headers=headers, data=json.dumps(payload))
|
18 |
return response.json()
|
19 |
|
20 |
def process_queries(customer_id, api_key, corpus_key):
|
@@ -33,4 +28,4 @@ def process_queries(customer_id, api_key, corpus_key):
|
|
33 |
response = query_vectara(question, customer_id, api_key, corpus_key)
|
34 |
results[question] = response
|
35 |
|
36 |
-
return results
|
|
|
2 |
import json
|
3 |
|
4 |
def query_vectara(question, customer_id, api_key, corpus_key):
|
5 |
+
"""Queries the uploaded documents in Vectara API v2 using the correct query format."""
|
6 |
+
url = f"https://api.vectara.io/v2/corpora/{corpus_key}/query?query={question}"
|
7 |
headers = {
|
8 |
"x-api-key": api_key,
|
9 |
"Accept": "application/json"
|
10 |
}
|
11 |
|
12 |
+
response = requests.get(url, headers=headers)
|
|
|
|
|
|
|
|
|
|
|
13 |
return response.json()
|
14 |
|
15 |
def process_queries(customer_id, api_key, corpus_key):
|
|
|
28 |
response = query_vectara(question, customer_id, api_key, corpus_key)
|
29 |
results[question] = response
|
30 |
|
31 |
+
return results
|