Tonic commited on
Commit
af86876
1 Parent(s): 4a0366f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -19
app.py CHANGED
@@ -1,11 +1,6 @@
1
  import gradio as gr
2
  import requests
3
  import json
4
-
5
- # Function to interact with Vectara API
6
- import gradio as gr
7
- import requests
8
- import json
9
  from decouple import config # Import config from python-decouple
10
 
11
  # Function to interact with Vectara API
@@ -30,7 +25,7 @@ def query_vectara(question, chat_history, uploaded_file):
30
  if response.status_code == 200:
31
  upload_status = "File uploaded successfully"
32
  else:
33
- upload_status = "Failed to upload file"
34
 
35
  # Get the user's message from the chat history
36
  user_message = chat_history[-1][0]
@@ -42,17 +37,15 @@ def query_vectara(question, chat_history, uploaded_file):
42
  "start": 0,
43
  "numResults": 10,
44
  "corpusKey": [
45
- else:
46
- return {"error": "Failed to query Vectara API"}
47
-
48
- # Create a Gradio ChatInterface
49
- iface = gr.ChatInterface(
50
- fn=query_vectara,
51
- examples=["Hello", "What is the weather today?", "Tell me a joke"],
52
- title="Vectara Chatbot",
53
- description="Ask me anything using the Vectara API!",
54
-
55
- )
56
 
57
  api_endpoint = "https://api.vectara.io/v1/query"
58
  return f"{upload_status}\n\nResponse from Vectara API: {response.text}"
@@ -67,5 +60,5 @@ iface = gr.Interface(
67
  outputs=gr.outputs.Textbox(),
68
  examples=["Hello", "What is the weather today?", "Tell me a joke"],
69
  title="Vectara Chatbot",
70
- description="Ask me anything using the Vectara API!",
71
- )
 
1
  import gradio as gr
2
  import requests
3
  import json
 
 
 
 
 
4
  from decouple import config # Import config from python-decouple
5
 
6
  # Function to interact with Vectara API
 
25
  if response.status_code == 200:
26
  upload_status = "File uploaded successfully"
27
  else:
28
+ upload_status = "Failed to upload the file"
29
 
30
  # Get the user's message from the chat history
31
  user_message = chat_history[-1][0]
 
37
  "start": 0,
38
  "numResults": 10,
39
  "corpusKey": [
40
+ {
41
+ "customerId": customer_id,
42
+ "corpusId": corpus_id,
43
+ "lexicalInterpolationConfig": {"lambda": 0.025}
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
 
 
49
 
50
  api_endpoint = "https://api.vectara.io/v1/query"
51
  return f"{upload_status}\n\nResponse from Vectara API: {response.text}"
 
60
  outputs=gr.outputs.Textbox(),
61
  examples=["Hello", "What is the weather today?", "Tell me a joke"],
62
  title="Vectara Chatbot",
63
+ description="Ask me anything using the Vectara API!"
64
+ )