rogkesavan commited on
Commit
9eac11a
1 Parent(s): c3746f0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Define a function to send the input to the FastAPI endpoint and get the response
5
+ def get_response(query):
6
+ try:
7
+ # Send the query to the FastAPI endpoint
8
+ response = requests.post("http://164.52.213.121:8000/chat", data=query)
9
+ # Check if the request was successful
10
+ response.raise_for_status()
11
+ # Extract the text from the response JSON
12
+ return response.json().get("response", "No response from server.")
13
+ except requests.exceptions.RequestException as e:
14
+ return f"Error: {e}"
15
+
16
+ # Define the Gradio interface
17
+ iface = gr.Interface(
18
+ fn=get_response,
19
+ inputs=gr.Textbox(lines=2, placeholder="Enter your query here..."),
20
+ outputs="text",
21
+ title="Chat with Model",
22
+ description="Enter a query and get a response from the model."
23
+ )
24
+
25
+ # Launch the Gradio app
26
+ if __name__ == "__main__":
27
+ iface.launch()