-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgr.py
36 lines (30 loc) · 1.08 KB
/
gr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from langserve import RemoteRunnable
import requests
def get_response(input):
url = "http://localhost:5000/chat/"
try:
data = {"input": input}
headers = {"Content-Type": "application/json", "Accept": "application/json"}
response = requests.get(url, json=data, headers=headers)
if response.status_code == 200:
return response.text
else:
return "There was an error"
except requests.exceptions.RequestException as e:
return e
iface = gr.Interface(
fn=get_response,
inputs=gr.Textbox(
value="Enter your question"
),
outputs="textbox",
title="GRE Analytical Writing Essay Grader",
theme=gr.themes.Soft(),
allow_flagging="never",
examples=[
"Give me a Quantitative Reasoning question that uses the concept of the Normal distribution",
"Give me a Critical Reasoning question as well as its accompanying reading section"
]
)
iface.launch(share=True)