deepak191z commited on
Commit
fe7f68c
·
verified ·
1 Parent(s): 5ef7985

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -10
app.py CHANGED
@@ -1,15 +1,18 @@
1
  import gradio as gr
2
  import requests
3
 
4
-
5
  def chatbot_response(user_input: str, history) -> str:
6
- r = requests.post(
7
- f"http://localhost:3000/chat/?query={user_input}")
8
- response = r.json()
9
- return f"Response from the API was {response}"
10
-
11
- demo = gr.ChatInterface(fn=chatbot_response,
12
- title="Name of demo goes here",
13
- description="Description goes here")
 
 
 
 
14
 
15
- demo.launch(server_name="localhost", server_port=4000, show_api=False)
 
1
  import gradio as gr
2
  import requests
3
 
 
4
  def chatbot_response(user_input: str, history) -> str:
5
+ r = requests.get( # changed to GET
6
+ f"http://localhost:3000/chat/?query={user_input}"
7
+ )
8
+ response = r.json()
9
+ return response.get("answer", "No answer received from API.")
10
+
11
+ demo = gr.ChatInterface(
12
+ fn=chatbot_response,
13
+ title="Name of demo goes here",
14
+ description="Description goes here",
15
+ type="messages" # new line added
16
+ )
17
 
18
+ demo.launch(server_name="localhost", server_port=4000, show_api=False)