Polarisailabs commited on
Commit
91454b4
·
verified ·
1 Parent(s): 2666cdb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +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="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", 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
+