Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ from openai import OpenAI
|
|
| 4 |
|
| 5 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 6 |
openai_client = OpenAI(api_key="OPENAI_API_KEY")
|
| 7 |
-
def generate_response(prompt,
|
| 8 |
try:
|
| 9 |
response = openai_client.chat.completions.create(
|
| 10 |
model="gpt-3.5-turbo", # or another model of your choice
|
|
@@ -18,3 +18,19 @@ def generate_response(prompt, model_provider, temperature, top_p, max_tokens, re
|
|
| 18 |
return response.choices[0].message.content.strip()
|
| 19 |
except Exception as e:
|
| 20 |
return f"OpenAI API Error: {str(e)}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
| 6 |
openai_client = OpenAI(api_key="OPENAI_API_KEY")
|
| 7 |
+
def generate_response(prompt,temperature, top_p, max_tokens, repetition_penalty):
|
| 8 |
try:
|
| 9 |
response = openai_client.chat.completions.create(
|
| 10 |
model="gpt-3.5-turbo", # or another model of your choice
|
|
|
|
| 18 |
return response.choices[0].message.content.strip()
|
| 19 |
except Exception as e:
|
| 20 |
return f"OpenAI API Error: {str(e)}"
|
| 21 |
+
|
| 22 |
+
iface = gr.Interface(
|
| 23 |
+
fn=generate_response,
|
| 24 |
+
inputs=[
|
| 25 |
+
gr.Textbox(label="Prompt", lines=6, placeholder="Ask something..."),
|
| 26 |
+
gr.Slider(minimum=0.1, maximum=1.5, value=0.7, step=0.1, label="Temperature"),
|
| 27 |
+
gr.Slider(minimum=0.1, maximum=1.0, value=0.9, step=0.05, label="Top-p"),
|
| 28 |
+
gr.Slider(minimum=32, maximum=2048, value=512, step=32, label="Max New Tokens"),
|
| 29 |
+
gr.Slider(minimum=1.0, maximum=2.0, value=1.1, step=0.1, label="Repetition Penalty")
|
| 30 |
+
],
|
| 31 |
+
outputs="text",
|
| 32 |
+
title="🧠 DeepSeek LLM Chat with Parameter Tuning",
|
| 33 |
+
theme=gr.themes.Soft()
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
iface.launch()
|