Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import gradio as gr
|
|
5 |
import time
|
6 |
|
7 |
# --- Constants ---
|
8 |
-
DEFAULT_MODEL = "gpt-
|
9 |
DEFAULT_TEMPERATURE = 1.0 # Match your example
|
10 |
DEFAULT_TOP_P = 1.0 # Match your example
|
11 |
DEFAULT_FREQ_PENALTY = 0 # Match your example
|
@@ -25,7 +25,7 @@ def get_openai_response(prompt, model=DEFAULT_MODEL, temperature=DEFAULT_TEMPERA
|
|
25 |
"""Gets a response from the OpenAI API, handling errors and streaming."""
|
26 |
today_day = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
27 |
try:
|
28 |
-
messages = [{"role": "system", "content": f"
|
29 |
if chat_history:
|
30 |
for turn in chat_history:
|
31 |
messages.append({"role": "user", "content": turn[0]})
|
@@ -80,9 +80,25 @@ def update_ui(message, chat_history, model, temperature, top_p, frequency_penalt
|
|
80 |
# --- Gradio Interface ---
|
81 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
82 |
gr.Markdown("# Chat with GPT-4.5 -> gpt-4.5-preview-2025-02-27 model")
|
83 |
-
gr.Markdown("Made by: [@diegocabezas01](https://x.com/diegocabezas01) on X")
|
84 |
gr.Markdown("☕ [Buy me a Coffee](https://buymeacoffee.com/diegocp01m)")
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
with gr.Row():
|
87 |
with gr.Column(scale=4):
|
88 |
chatbot = gr.Chatbot(
|
@@ -99,7 +115,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
99 |
with gr.Accordion("Advanced Options", open=False):
|
100 |
model_select = gr.Dropdown(
|
101 |
label="Model",
|
102 |
-
choices=["gpt-
|
103 |
value=DEFAULT_MODEL,
|
104 |
interactive=True
|
105 |
)
|
|
|
5 |
import time
|
6 |
|
7 |
# --- Constants ---
|
8 |
+
DEFAULT_MODEL = "gpt-4o-mini-2024-07-18" # Assuming gpt-4o is a good default
|
9 |
DEFAULT_TEMPERATURE = 1.0 # Match your example
|
10 |
DEFAULT_TOP_P = 1.0 # Match your example
|
11 |
DEFAULT_FREQ_PENALTY = 0 # Match your example
|
|
|
25 |
"""Gets a response from the OpenAI API, handling errors and streaming."""
|
26 |
today_day = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
27 |
try:
|
28 |
+
messages = [{"role": "system", "content": f"Todays date is: {today_day} " + system_prompt}]
|
29 |
if chat_history:
|
30 |
for turn in chat_history:
|
31 |
messages.append({"role": "user", "content": turn[0]})
|
|
|
80 |
# --- Gradio Interface ---
|
81 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
82 |
gr.Markdown("# Chat with GPT-4.5 -> gpt-4.5-preview-2025-02-27 model")
|
83 |
+
gr.Markdown("GPT 4.5 IS NOT WORKING ON THIS SPACE ANYMORE, IT WAS FREE FOR ~ 4 HOURS! | Made by: [@diegocabezas01](https://x.com/diegocabezas01) on X")
|
84 |
gr.Markdown("☕ [Buy me a Coffee](https://buymeacoffee.com/diegocp01m)")
|
85 |
|
86 |
+
gr.Image("https://pbs.twimg.com/media/Gk1tVnRXkAASa2U?format=jpg&name=4096x4096", elem_id="gpt4_5_image")
|
87 |
+
|
88 |
+
gr.Markdown("""
|
89 |
+
🚀 **GPT-4.5 EXPERIMENT:** GPT-4.5 was released today at 3 PM ET, but it's only available to PRO users and developers.
|
90 |
+
I created a Hugging Face Space using the API so everyone can chat with GPT-4.5 for FREE—until my credits run out! 😄
|
91 |
+
|
92 |
+
**Here's how the experiment went:**
|
93 |
+
|
94 |
+
📊 **Chat Completions Metrics (Feb 27, 2025):**
|
95 |
+
- 111 requests
|
96 |
+
- 64,764 Total tokens processed
|
97 |
+
- Total spend: $10.99
|
98 |
+
|
99 |
+
This space went live at 4:23 PM ET today, Feb 27, 2025 until 8:53 PM ET. [Read More](https://x.com/diegocabezas01/status/1895291365376041045)
|
100 |
+
""")
|
101 |
+
|
102 |
with gr.Row():
|
103 |
with gr.Column(scale=4):
|
104 |
chatbot = gr.Chatbot(
|
|
|
115 |
with gr.Accordion("Advanced Options", open=False):
|
116 |
model_select = gr.Dropdown(
|
117 |
label="Model",
|
118 |
+
choices=["gpt-3.5-turbo-0125", "gpt-4o-mini-2024-07-18"], # Update with your models
|
119 |
value=DEFAULT_MODEL,
|
120 |
interactive=True
|
121 |
)
|