apaxray commited on
Commit
4c671d3
·
verified ·
1 Parent(s): 43454ac

Update ui.py

Browse files
Files changed (1) hide show
  1. ui.py +8 -13
ui.py CHANGED
@@ -1,20 +1,15 @@
1
  import gradio as gr
2
  import requests
3
 
4
- API_URL = "http://localhost:8000/chat/" # تغییر به URL واقعی بک‌اند در آینده
 
 
5
 
6
- def ask_chatbot(query):
7
- response = requests.post(API_URL, json={"query": query})
8
- return response.json().get("response", "خطایی رخ داد!")
9
-
10
- # رابط کاربری
11
- interface = gr.Interface(
12
- fn=ask_chatbot,
13
- inputs="text",
14
  outputs="text",
15
- title="ChatGPT Clone",
16
- description="چت‌بات بر پایه GPT-Neo"
17
  )
18
 
19
- if __name__ == "__main__":
20
- interface.launch()
 
1
  import gradio as gr
2
  import requests
3
 
4
+ def chat_with_ai(input_text, mode):
5
+ response = requests.post("http://localhost:8000/chat", json={"input_text": input_text, "mode": mode})
6
+ return response.json()["response"]
7
 
8
+ ui = gr.Interface(
9
+ fn=chat_with_ai,
10
+ inputs=["text", gr.Radio(["general", "iran", "math"], label="Mode")],
 
 
 
 
 
11
  outputs="text",
12
+ title="AI Chat System",
 
13
  )
14
 
15
+ ui.launch()