Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ def query_openai(messages, temperature, top_p, max_output_tokens):
|
|
23 |
# Ensure numeric values for OpenAI parameters
|
24 |
temperature = float(temperature) if temperature else 1.0
|
25 |
top_p = float(top_p) if top_p else 1.0
|
26 |
-
max_output_tokens = int(max_output_tokens) if max_output_tokens else
|
27 |
|
28 |
response = openai.ChatCompletion.create(
|
29 |
model="gpt-4.5-preview",
|
@@ -95,7 +95,7 @@ def pdf_chat(pdf_file, text_query, temperature, top_p, max_output_tokens):
|
|
95 |
|
96 |
# Function to clear the chat (Fix: Returns the correct number of outputs)
|
97 |
def clear_chat():
|
98 |
-
return "", "", "", "", "", "", "", None, "", None, "", 1.0, 1.0,
|
99 |
|
100 |
# Gradio UI Layout
|
101 |
with gr.Blocks() as demo:
|
@@ -110,7 +110,7 @@ with gr.Blocks() as demo:
|
|
110 |
with gr.Row():
|
111 |
temperature = gr.Slider(0, 2, value=1.0, step=0.1, label="Temperature")
|
112 |
top_p = gr.Slider(0, 1, value=1.0, step=0.1, label="Top-P")
|
113 |
-
max_output_tokens = gr.Slider(0, 16384, value=
|
114 |
|
115 |
with gr.Tabs():
|
116 |
with gr.Tab("Image URL Chat"):
|
|
|
23 |
# Ensure numeric values for OpenAI parameters
|
24 |
temperature = float(temperature) if temperature else 1.0
|
25 |
top_p = float(top_p) if top_p else 1.0
|
26 |
+
max_output_tokens = int(max_output_tokens) if max_output_tokens else 2048
|
27 |
|
28 |
response = openai.ChatCompletion.create(
|
29 |
model="gpt-4.5-preview",
|
|
|
95 |
|
96 |
# Function to clear the chat (Fix: Returns the correct number of outputs)
|
97 |
def clear_chat():
|
98 |
+
return "", "", "", "", "", "", "", None, "", None, "", 1.0, 1.0, 2048
|
99 |
|
100 |
# Gradio UI Layout
|
101 |
with gr.Blocks() as demo:
|
|
|
110 |
with gr.Row():
|
111 |
temperature = gr.Slider(0, 2, value=1.0, step=0.1, label="Temperature")
|
112 |
top_p = gr.Slider(0, 1, value=1.0, step=0.1, label="Top-P")
|
113 |
+
max_output_tokens = gr.Slider(0, 16384, value=2048, step=512, label="Max Output Tokens") # Changed default to 2048
|
114 |
|
115 |
with gr.Tabs():
|
116 |
with gr.Tab("Image URL Chat"):
|