Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from g4f.client import Client
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
client = Client()
|
5 |
+
|
6 |
+
def chatbot_respone(user_input):
|
7 |
+
response = client.chat.completions.create(
|
8 |
+
model="gpt-4",
|
9 |
+
messages=[{"role": "user", "content": user_input}]
|
10 |
+
|
11 |
+
)
|
12 |
+
return response.choices[0].message.content
|
13 |
+
|
14 |
+
interface = gr.Interface(
|
15 |
+
fn=chatbot_respone,
|
16 |
+
inputs= gr.Textbox(lines=2),
|
17 |
+
outputs=["text"],
|
18 |
+
title="AI power up"
|
19 |
+
)
|
20 |
+
|
21 |
+
if __name__ =="__main__":
|
22 |
+
interface.launch(share=True)
|
23 |
+
|
24 |
+
|
25 |
+
|