File size: 2,885 Bytes
27db63f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4914b1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from openai import OpenAI
import gradio as gr

messages = [
    {"role": "system", "content": "You are AI specialized in Prompt Engineering"},
]
client = OpenAI(api_key="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", base_url="https://openrouter.ai/api/v1")

def chatbot(input, prompt_type):
    if input:
        if prompt_type == "Zero Shot Prompt":
            input += ""
        elif prompt_type == "One Shot Prompt":
            input += " Convert this zero shot prompt to one shot prompt"
        elif prompt_type == "Few Shot Prompt":
            input += " Convert this zero shot prompt to few shot prompt"
        elif prompt_type == "System Prompt":
            input += " Convert this zero shot prompt to system prompt"
        elif prompt_type == "Contextual Prompt":
            input += " Convert this zero shot prompt to contextual prompt"
        elif prompt_type == "Role Prompt":
            input += " Convert this zero shot prompt to role prompt"
        elif prompt_type == "Step-back Prompt":
            input += " Convert this zero shot prompt to step-back prompt"
        elif prompt_type == "Chain-of-thought Prompt":
            input += " Convert this zero shot prompt to chain-of-thought prompt"
        elif prompt_type == "Tree-of-thought":
            input += " Convert this zero shot prompt to tree-of-thought prompt"
        elif prompt_type == "React Prompt":
            input += " Convert this zero shot prompt to react prompt"
        elif prompt_type == "Code Prompt":
            input += " Convert this zero shot prompt to code prompt"
        elif prompt_type == "Multi-Modal Prompt":
            input += " Convert this zero shot prompt to multi-Modal prompt"
        elif prompt_type == "Augmented Prompt":
            input += " Convert this zero shot prompt to augmented prompt"

        messages.append({"role": "user", "content": f"{prompt_type}: {input}"})
        chat = client.chat.completions.create(
            model="deepseek/deepseek-r1:free", messages=messages
        )
        reply = chat.choices[0].message.content
        messages.append({"role": "assistant", "content": reply})
        return reply

prompt_types = [
    "Zero Shot Prompt", 
    "One Shot Prompt", 
    "Few Shot Prompt", 
    "System Prompt",
    "Contextual Prompt", 
    "Role Prompt", 
    "Step-back Prompt", 
    "Chain-of-thought Prompt",
    "Tree-of-thought Prompt", 
    "React Prompt", 
    "Code Prompt", 
    "Multi-Modal Prompt",
    "Augmented Prompt"
]

with gr.Blocks() as demo:
    dropdown = gr.Dropdown(choices=prompt_types, label="Select Prompt Type", type="value")
    inputs = gr.Textbox(lines=7, label="Prompt : Try - What is the value of pi")
    outputs = gr.Textbox(label="Result")

    gr.Interface(fn=chatbot, inputs=[inputs, dropdown], outputs=outputs, theme="compact")

demo.launch(share=True)