Serg4451D commited on
Commit
874475c
1 Parent(s): 3d0392b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from g4f.client import Client
3
+
4
+ # Создаем экземпляр клиента
5
+ client = Client()
6
+
7
+ # Функция для общения с GPT-3.5
8
+ def chat_with_gpt(user_input):
9
+ try:
10
+ response = client.chat.completions.create(
11
+ model="gpt-3.5-turbo",
12
+ messages=[{"role": "user", "content": user_input}]
13
+ )
14
+ return response.choices[0].message.content
15
+ except Exception as e:
16
+ return str(e)
17
+
18
+ # Создаем интерфейс Gradio
19
+ with gr.Blocks() as demo:
20
+ gr.Markdown("# Chat with GPT-3.5")
21
+
22
+ user_input = gr.Textbox(label="You:", placeholder="Type your message here...")
23
+ output = gr.Textbox(label="GPT-3.5:", interactive=False)
24
+
25
+ submit_button = gr.Button("Send")
26
+
27
+ submit_button.click(chat_with_gpt, inputs=user_input, outputs=output)
28
+
29
+ # Запускаем интерфейс
30
+ demo.launch()