Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,6 +50,28 @@ def query_vectara(question, chat_history, uploaded_file):
|
|
| 50 |
api_endpoint = "https://api.vectara.io/v1/query"
|
| 51 |
return f"{upload_status}\n\nResponse from Vectara API: {response.text}"
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
# Create a Gradio ChatInterface with a text input, a file upload input, and a text output
|
| 55 |
iface = gr.Interface(
|
|
|
|
| 50 |
api_endpoint = "https://api.vectara.io/v1/query"
|
| 51 |
return f"{upload_status}\n\nResponse from Vectara API: {response.text}"
|
| 52 |
|
| 53 |
+
# from vectara_retriever import VectaraRetriever # Assuming VectaraRetriever is in vectara_retriever.py
|
| 54 |
+
|
| 55 |
+
# Function to interact with Vectara API
|
| 56 |
+
# def query_vectara(question, chat_history, uploaded_file):
|
| 57 |
+
# # Handle file upload to Vectara
|
| 58 |
+
#
|
| 59 |
+
# # Get the user's message from the chat history
|
| 60 |
+
# user_message = chat_history[-1][0]
|
| 61 |
+
#
|
| 62 |
+
# # Create a VectaraRetriever instance
|
| 63 |
+
# retriever = VectaraRetriever(index=your_vectara_index) # Replace with your VectaraIndex instance
|
| 64 |
+
#
|
| 65 |
+
# # Create a QueryBundle with the user's message
|
| 66 |
+
# query_bundle = QueryBundle(query_str=user_message)
|
| 67 |
+
#
|
| 68 |
+
# # Retrieve the top k most similar nodes
|
| 69 |
+
# top_k_nodes = retriever._retrieve(query_bundle)
|
| 70 |
+
#
|
| 71 |
+
# # Format the nodes for display
|
| 72 |
+
# responses = "\n".join([f"{node.node.text} (score: {node.score})" for node in top_k_nodes])
|
| 73 |
+
#
|
| 74 |
+
# return f"{upload_status}\n\nResponse from Vectara API: {responses}"
|
| 75 |
|
| 76 |
# Create a Gradio ChatInterface with a text input, a file upload input, and a text output
|
| 77 |
iface = gr.Interface(
|