Spaces:
Running
Running
Upload 2 files
Browse files- app.py +69 -0
- requirements.txt +0 -0
app.py
ADDED
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, prompt_type):
|
10 |
+
if input:
|
11 |
+
if prompt_type == "Zero Shot Prompt":
|
12 |
+
input += ""
|
13 |
+
elif prompt_type == "One Shot Prompt":
|
14 |
+
input += " Convert this zero shot prompt to one shot prompt"
|
15 |
+
elif prompt_type == "Few Shot Prompt":
|
16 |
+
input += " Convert this zero shot prompt to few shot prompt"
|
17 |
+
elif prompt_type == "System Prompt":
|
18 |
+
input += " Convert this zero shot prompt to system prompt"
|
19 |
+
elif prompt_type == "Contextual Prompt":
|
20 |
+
input += " Convert this zero shot prompt to contextual prompt"
|
21 |
+
elif prompt_type == "Role Prompt":
|
22 |
+
input += " Convert this zero shot prompt to role prompt"
|
23 |
+
elif prompt_type == "Step-back Prompt":
|
24 |
+
input += " Convert this zero shot prompt to step-back prompt"
|
25 |
+
elif prompt_type == "Chain-of-thought Prompt":
|
26 |
+
input += " Convert this zero shot prompt to chain-of-thought prompt"
|
27 |
+
elif prompt_type == "Tree-of-thought":
|
28 |
+
input += " Convert this zero shot prompt to tree-of-thought prompt"
|
29 |
+
elif prompt_type == "React Prompt":
|
30 |
+
input += " Convert this zero shot prompt to react prompt"
|
31 |
+
elif prompt_type == "Code Prompt":
|
32 |
+
input += " Convert this zero shot prompt to code prompt"
|
33 |
+
elif prompt_type == "Multi-Modal Prompt":
|
34 |
+
input += " Convert this zero shot prompt to multi-Modal prompt"
|
35 |
+
elif prompt_type == "Augmented Prompt":
|
36 |
+
input += " Convert this zero shot prompt to augmented prompt"
|
37 |
+
|
38 |
+
messages.append({"role": "user", "content": f"{prompt_type}: {input}"})
|
39 |
+
chat = client.chat.completions.create(
|
40 |
+
model="deepseek/deepseek-r1:free", messages=messages
|
41 |
+
)
|
42 |
+
reply = chat.choices[0].message.content
|
43 |
+
messages.append({"role": "assistant", "content": reply})
|
44 |
+
return reply
|
45 |
+
|
46 |
+
prompt_types = [
|
47 |
+
"Zero Shot Prompt",
|
48 |
+
"One Shot Prompt",
|
49 |
+
"Few Shot Prompt",
|
50 |
+
"System Prompt",
|
51 |
+
"Contextual Prompt",
|
52 |
+
"Role Prompt",
|
53 |
+
"Step-back Prompt",
|
54 |
+
"Chain-of-thought Prompt",
|
55 |
+
"Tree-of-thought Prompt",
|
56 |
+
"React Prompt",
|
57 |
+
"Code Prompt",
|
58 |
+
"Multi-Modal Prompt",
|
59 |
+
"Augmented Prompt"
|
60 |
+
]
|
61 |
+
|
62 |
+
with gr.Blocks() as demo:
|
63 |
+
dropdown = gr.Dropdown(choices=prompt_types, label="Select Prompt Type", type="value")
|
64 |
+
inputs = gr.Textbox(lines=7, label="Prompt : Try - What is the value of pi")
|
65 |
+
outputs = gr.Textbox(label="Result")
|
66 |
+
|
67 |
+
gr.Interface(fn=chatbot, inputs=[inputs, dropdown], outputs=outputs, title="PolarisAI Labs - Prompt Engineering", theme="compact")
|
68 |
+
|
69 |
+
demo.launch(share=True)
|
requirements.txt
ADDED
File without changes
|