Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -75,11 +75,14 @@ def query_vectara(question):
|
|
75 |
|
76 |
if response.status_code == 200:
|
77 |
query_data = response.json()
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
83 |
else:
|
84 |
return f"Error: {response.status_code}"
|
85 |
|
|
|
75 |
|
76 |
if response.status_code == 200:
|
77 |
query_data = response.json()
|
78 |
+
if query_data:
|
79 |
+
# Extract summary and the first 5 sources
|
80 |
+
summary_text = query_data[0]["summary"]["text"]
|
81 |
+
sources = query_data[0]["responseSet"]["responseList"][:5]
|
82 |
+
sources_text = [source["text"] for source in sources]
|
83 |
+
return f"Summary: {summary_text}\n\nSources:\n{json.dumps(sources_text, indent=2)}"
|
84 |
+
else:
|
85 |
+
return "No data found in the response."
|
86 |
else:
|
87 |
return f"Error: {response.status_code}"
|
88 |
|