Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,25 +1,25 @@
|
|
1 |
-
from openai import OpenAI
|
2 |
-
import gradio as gr
|
3 |
-
|
4 |
-
messages = [
|
5 |
-
{"role": "system", "content": "You are AI specialized in Prompt Engineering"},
|
6 |
-
]
|
7 |
-
client = OpenAI(api_key="
|
8 |
-
|
9 |
-
def chatbot(input):
|
10 |
-
if input:
|
11 |
-
messages.append({"role": "user", "content": input})
|
12 |
-
chat = client.chat.completions.create(
|
13 |
-
model="deepseek/deepseek-r1:free", messages=messages
|
14 |
-
)
|
15 |
-
reply = chat.choices[0].message.content
|
16 |
-
messages.append({"role": "assistant", "content": reply})
|
17 |
-
return reply
|
18 |
-
|
19 |
-
inputs = gr.Textbox(lines=7, label="Query")
|
20 |
-
outputs = gr.Textbox(label="Response")
|
21 |
-
|
22 |
-
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Prompt Engineering Prodigy",
|
23 |
-
theme="compact").launch(share=True)
|
24 |
-
|
25 |
-
|
|
|
1 |
+
from openai import OpenAI
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
messages = [
|
5 |
+
{"role": "system", "content": "You are AI specialized in Prompt Engineering"},
|
6 |
+
]
|
7 |
+
client = OpenAI(api_key="DEEPSEEK_API_KEY", base_url="https://openrouter.ai/api/v1")
|
8 |
+
|
9 |
+
def chatbot(input):
|
10 |
+
if input:
|
11 |
+
messages.append({"role": "user", "content": input})
|
12 |
+
chat = client.chat.completions.create(
|
13 |
+
model="deepseek/deepseek-r1:free", messages=messages
|
14 |
+
)
|
15 |
+
reply = chat.choices[0].message.content
|
16 |
+
messages.append({"role": "assistant", "content": reply})
|
17 |
+
return reply
|
18 |
+
|
19 |
+
inputs = gr.Textbox(lines=7, label="Query")
|
20 |
+
outputs = gr.Textbox(label="Response")
|
21 |
+
|
22 |
+
gr.Interface(fn=chatbot, inputs=inputs, outputs=outputs, title="Prompt Engineering Prodigy",
|
23 |
+
theme="compact").launch(share=True)
|
24 |
+
|
25 |
+
|