Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
|
|
|
|
|
| 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(
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def chatbot(input, prompt_type):
|
| 10 |
if input:
|
| 11 |
if prompt_type == "Zero Shot Prompt":
|
|
@@ -58,9 +68,9 @@ prompt_types = [
|
|
| 58 |
"Multi-Modal Prompt",
|
| 59 |
"Augmented Prompt"
|
| 60 |
]
|
| 61 |
-
with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as
|
| 62 |
-
dropdown = gr.Dropdown(choices=prompt_types, label="Select Prompt Type", type="value")
|
| 63 |
-
inputs = gr.Textbox(lines=7,
|
| 64 |
outputs = gr.Textbox(label="Result")
|
| 65 |
-
gr.Interface(fn=chatbot, inputs=[inputs
|
| 66 |
-
|
|
|
|
| 1 |
+
|
| 2 |
+
import os
|
| 3 |
from openai import OpenAI
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
+
API_KEY = os.environ['API_KEY']
|
| 7 |
messages = [
|
| 8 |
{"role": "system", "content": "You are AI specialized in Prompt Engineering"},
|
| 9 |
]
|
| 10 |
+
client = OpenAI(
|
| 11 |
+
base_url="https://openrouter.ai/api/v1",
|
| 12 |
+
api_key="API_KEY",
|
| 13 |
+
default_headers={
|
| 14 |
+
"Authorization": f"Bearer {API_KEY}",
|
| 15 |
+
"HTTP-Referer": "", # Optional: Your app's URL
|
| 16 |
+
"X-Title": "" # Optional: Your app name
|
| 17 |
+
}
|
| 18 |
+
)
|
| 19 |
def chatbot(input, prompt_type):
|
| 20 |
if input:
|
| 21 |
if prompt_type == "Zero Shot Prompt":
|
|
|
|
| 68 |
"Multi-Modal Prompt",
|
| 69 |
"Augmented Prompt"
|
| 70 |
]
|
| 71 |
+
with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as promptengineering:
|
| 72 |
+
dropdown = gr.Dropdown(choices=prompt_types, label="Select Prompt Type:", type="value")
|
| 73 |
+
inputs = gr.Textbox(lines=7, placeholder="Prompt : Try - What is the value of pi")
|
| 74 |
outputs = gr.Textbox(label="Result")
|
| 75 |
+
gr.Interface(fn=chatbot, inputs=[dropdown,inputs], outputs=outputs)
|
| 76 |
+
promptengineering.launch(share=True)
|