farukkr commited on
Commit
f529744
1 Parent(s): 46078ec

create app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ import json
4
+
5
+ API_URL = "https://jj78yliqd7.execute-api.eu-central-1.amazonaws.com/dev/chatbot"
6
+
7
+ def send_prompt_to_api(prompt, message):
8
+ params = {"prompt": prompt}
9
+ response = requests.get(API_URL, params=params)
10
+ if response.status_code == 200:
11
+ response_body = response.json().get('body')
12
+ answer = response_body.get('answer')
13
+ return answer
14
+ else:
15
+ return "Sorry, something went wrong. Please try again."
16
+
17
+ gr.ChatInterface(
18
+ send_prompt_to_api,
19
+ chatbot=gr.Chatbot(height=700),
20
+ textbox=gr.Textbox(placeholder="Ask me a question", container=False, scale=7),
21
+ title="Wissensguru - IDTA",
22
+ theme="soft",
23
+ examples=[
24
+ ],
25
+ cache_examples=False,
26
+ retry_btn="Retry",
27
+ undo_btn="Delete Previous",
28
+ clear_btn="Clear",
29
+ ).launch(share=TRUE)