decodingdatascience commited on
Commit
a8ecfcf
·
verified ·
1 Parent(s): 437a1c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +275 -261
app.py CHANGED
@@ -1,249 +1,237 @@
1
  import os
2
- import traceback
3
- from typing import Any
4
-
5
  import gradio as gr
6
  from openai import OpenAI
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  GENERATION_MODELS = [
10
- "gpt-4.1-mini",
11
- "gpt-4.1",
12
- "gpt-4o-mini",
13
  "gpt-5.5",
 
 
 
 
14
  ]
15
 
16
  REASONING_MODELS = [
17
  "gpt-5.5",
18
- "o4-mini",
19
- "o3-mini",
 
20
  ]
21
 
22
 
23
- def get_client() -> OpenAI | None:
24
- """
25
- Hugging Face Spaces exposes Secrets as environment variables.
26
- Add your OpenAI key in Space Settings as OPENAI_API_KEY.
27
- The lowercase fallback is included only to help during local testing.
28
- """
29
- api_key = os.getenv("OPENAI_API_KEY") or os.getenv("openai_api_key")
30
- if not api_key:
31
- return None
32
- return OpenAI(api_key=api_key)
33
-
34
 
35
- def extract_output_text(response: Any) -> str:
36
- """Robustly extract text from an OpenAI Responses API response."""
37
- output_text = getattr(response, "output_text", None)
38
- if output_text:
39
- return output_text.strip()
40
 
41
- chunks: list[str] = []
42
- for item in getattr(response, "output", []) or []:
43
- content = getattr(item, "content", None)
44
- if content is None and isinstance(item, dict):
45
- content = item.get("content", [])
46
 
47
- for part in content or []:
48
- if isinstance(part, dict):
49
- text = part.get("text") or part.get("output_text")
50
- else:
51
- text = getattr(part, "text", None) or getattr(part, "output_text", None)
52
- if text:
53
- chunks.append(str(text))
54
 
55
- return "\n".join(chunks).strip() if chunks else str(response)
 
56
 
57
 
58
- def is_gpt5_family(model: str) -> bool:
59
  """
60
- GPT-5 family models may reject custom sampling controls such as temperature.
61
- To avoid the common 400 error, this app does not send those controls to GPT-5.x models.
62
  """
63
- return model.strip().lower().startswith("gpt-5")
 
 
 
64
 
 
 
 
 
 
 
65
 
66
- def format_settings(title: str, settings: dict[str, Any]) -> str:
67
- lines = [f"--- {title} ---"]
68
- for key, value in settings.items():
69
- lines.append(f"{key}: {value}")
70
- lines.append("------------------------\n")
71
- return "\n".join(lines)
72
 
73
 
74
  def run_generation(
75
- prompt: str,
76
- model: str,
77
- system_message: str,
78
- temperature: float,
79
- top_p: float,
80
- max_output_tokens: int,
81
- frequency_penalty: float,
82
- presence_penalty: float,
83
- show_settings: bool,
84
- ) -> str:
85
- client = get_client()
86
- if client is None:
87
- return (
88
- "Missing API key.\n\n"
89
- "In Hugging Face Spaces, go to Settings → Secrets and add:\n"
90
- "Name: OPENAI_API_KEY\n"
91
- "Value: your OpenAI API key"
92
- )
93
 
94
- if not prompt or not prompt.strip():
95
- return "Please enter a prompt."
96
-
97
- params: dict[str, Any] = {
98
- "model": model,
99
- "instructions": system_message or "You are a helpful assistant.",
100
- "input": prompt,
101
- "max_output_tokens": int(max_output_tokens),
102
- }
103
-
104
- settings_note = ""
105
- if is_gpt5_family(model):
106
- settings_note = (
107
- "Note: GPT-5 family models can reject custom sampling controls. "
108
- "Temperature, top_p, frequency_penalty, and presence_penalty were not sent.\n\n"
109
- )
110
- else:
111
- params.update(
112
- {
113
- "temperature": float(temperature),
114
- "top_p": float(top_p),
115
- "frequency_penalty": float(frequency_penalty),
116
- "presence_penalty": float(presence_penalty),
117
- }
118
- )
119
 
120
- try:
121
- response = client.responses.create(**params)
122
- text = extract_output_text(response)
 
 
 
 
 
 
 
 
 
 
123
 
124
  if show_settings:
125
- settings = {
126
- "model": model,
127
- "system_message": system_message,
128
- "max_output_tokens": max_output_tokens,
129
- }
 
 
130
  if is_gpt5_family(model):
131
- settings.update(
132
- {
133
- "sampling_controls": "not sent for GPT-5 family model",
134
- }
135
- )
 
136
  else:
137
- settings.update(
138
- {
139
- "temperature": temperature,
140
- "top_p": top_p,
141
- "frequency_penalty": frequency_penalty,
142
- "presence_penalty": presence_penalty,
143
- }
144
- )
145
- return settings_note + format_settings("Generation Settings", settings) + text
146
 
147
- return settings_note + text
 
148
 
149
- except Exception as exc:
150
- return (
151
- "OpenAI API error:\n"
152
- f"{exc}\n\n"
153
- "Tip: If you selected a GPT-5 family model, try keeping generation controls at default "
154
- "or use the Reasoning Controls tab.\n\n"
155
- f"Technical details:\n{traceback.format_exc()}"
156
- )
157
 
158
 
159
  def run_reasoning(
160
- prompt: str,
161
- model: str,
162
- reasoning_effort: str,
163
- max_output_tokens: int,
164
- show_settings: bool,
165
- ) -> str:
166
- client = get_client()
167
- if client is None:
168
- return (
169
- "Missing API key.\n\n"
170
- "In Hugging Face Spaces, go to Settings → Secrets and add:\n"
171
- "Name: OPENAI_API_KEY\n"
172
- "Value: your OpenAI API key"
173
- )
174
 
175
- if not prompt or not prompt.strip():
176
- return "Please enter a prompt."
 
 
 
 
 
 
177
 
178
- params: dict[str, Any] = {
179
- "model": model,
180
- "input": prompt,
181
- "reasoning": {"effort": reasoning_effort},
182
- "max_output_tokens": int(max_output_tokens),
183
- }
184
 
185
- try:
186
- response = client.responses.create(**params)
187
- text = extract_output_text(response)
188
 
189
  if show_settings:
190
- settings = {
191
- "model": model,
192
- "reasoning_effort": reasoning_effort,
193
- "max_output_tokens": max_output_tokens,
194
- "api": "OpenAI Responses API",
195
- }
196
- return format_settings("Reasoning Settings", settings) + text
197
-
198
- return text
199
-
200
- except Exception as exc:
201
- return (
202
- "OpenAI API error:\n"
203
- f"{exc}\n\n"
204
- "Tip: Make sure your account has access to the selected model, or try another model "
205
- "from the dropdown.\n\n"
206
- f"Technical details:\n{traceback.format_exc()}"
207
- )
208
 
 
209
 
210
- custom_css = """
 
 
 
 
211
  .gradio-container {
212
- max-width: 1180px !important;
213
  margin: auto !important;
214
  }
215
- #main-title {
 
216
  text-align: center;
 
 
 
 
 
 
 
 
 
217
  }
 
218
  .output-box textarea {
219
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
220
  }
221
  """
222
 
223
 
224
- with gr.Blocks(
225
- title="OpenAI LLM Controls",
226
- theme=gr.themes.Soft(),
227
- css=custom_css,
228
- ) as demo:
229
  gr.Markdown(
230
  """
231
- # OpenAI LLM Controls
 
 
 
 
232
 
233
- Experiment with generation settings and reasoning effort using the OpenAI Responses API.
234
- Add your key in Hugging Face Spaces as the secret `OPENAI_API_KEY`.
235
- """,
236
- elem_id="main-title",
237
  )
238
 
239
- with gr.Tab("Generation Controls"):
240
- gr.Markdown(
241
- """
242
- Use this tab to test practical writing and completion tasks.
243
- For GPT-5 family models, the app avoids sending custom sampling controls to prevent unsupported-parameter errors.
244
- """
245
- )
246
 
 
 
 
 
 
 
 
 
 
 
247
  with gr.Row():
248
  with gr.Column(scale=1):
249
  gen_prompt = gr.Textbox(
@@ -251,53 +239,66 @@ with gr.Blocks(
251
  label="Prompt",
252
  value="Write a short LinkedIn post explaining why business leaders should learn AI. Maximum 120 words.",
253
  )
 
254
  gen_model = gr.Dropdown(
255
- GENERATION_MODELS,
256
  label="Model",
257
- value="gpt-4.1-mini",
 
 
258
  )
259
- system_message = gr.Textbox(
 
260
  lines=3,
261
  label="System Message",
262
  value="You are a helpful AI instructor. Keep answers clear and practical.",
263
  )
264
- with gr.Accordion("Advanced Generation Settings", open=True):
265
- temperature = gr.Slider(
266
- minimum=0.0,
267
- maximum=2.0,
268
- step=0.01,
269
- value=0.7,
270
- label="Temperature",
271
- )
272
- top_p = gr.Slider(
273
- minimum=0.0,
274
- maximum=1.0,
275
- step=0.01,
276
- value=1.0,
277
- label="Top P",
278
- )
279
- max_output_tokens_gen = gr.Slider(
280
- minimum=50,
281
- maximum=4000,
282
- step=10,
283
- value=300,
284
- label="Max Output Tokens",
285
- )
286
- frequency_penalty = gr.Slider(
287
- minimum=-2.0,
288
- maximum=2.0,
289
- step=0.01,
290
- value=0.0,
291
- label="Frequency Penalty",
292
- )
293
- presence_penalty = gr.Slider(
294
- minimum=-2.0,
295
- maximum=2.0,
296
- step=0.01,
297
- value=0.0,
298
- label="Presence Penalty",
299
- )
300
- show_settings_gen = gr.Checkbox(value=True, label="Show Settings")
 
 
 
 
 
 
 
 
 
301
  gen_button = gr.Button("Generate", variant="primary")
302
 
303
  with gr.Column(scale=1):
@@ -305,7 +306,6 @@ with gr.Blocks(
305
  lines=22,
306
  label="Output",
307
  elem_classes=["output-box"],
308
- show_copy_button=True,
309
  )
310
 
311
  gen_button.click(
@@ -313,55 +313,67 @@ with gr.Blocks(
313
  inputs=[
314
  gen_prompt,
315
  gen_model,
316
- system_message,
317
- temperature,
318
- top_p,
319
- max_output_tokens_gen,
320
- frequency_penalty,
321
- presence_penalty,
322
- show_settings_gen,
323
  ],
324
  outputs=gen_output,
325
  )
326
 
327
  with gr.Tab("Reasoning Controls"):
328
- gr.Markdown(
329
- """
330
- Use this tab for analysis, recommendations, technical trade-offs, planning, and decision-making tasks.
331
- """
332
- )
333
-
334
  with gr.Row():
335
  with gr.Column(scale=1):
336
  reason_prompt = gr.Textbox(
337
  lines=9,
338
  label="Prompt",
339
- value=(
340
- "A telecom company wants to build an AI customer support assistant. "
341
- "They have 50,000 past support tickets, a FAQ website, billing policies, "
342
- "and a small developer team. Should they start with: "
343
- "1. Simple prompt-based chatbot 2. RAG chatbot 3. Fine-tuning "
344
- "4. Agent with tools. Give a practical recommendation with trade-offs."
345
- ),
 
 
 
 
 
 
 
 
346
  )
 
347
  reason_model = gr.Dropdown(
348
- REASONING_MODELS,
349
  label="Model",
350
- value="gpt-5.5",
 
 
351
  )
352
- reasoning_effort = gr.Radio(
353
- ["low", "medium", "high"],
 
354
  label="Reasoning Effort",
355
  value="medium",
356
  )
357
- max_output_tokens_reason = gr.Slider(
 
358
  minimum=100,
359
  maximum=8000,
360
- step=50,
361
- value=900,
362
  label="Max Output Tokens",
363
  )
364
- show_settings_reason = gr.Checkbox(value=True, label="Show Settings")
 
 
 
 
 
365
  reason_button = gr.Button("Reason", variant="primary")
366
 
367
  with gr.Column(scale=1):
@@ -369,7 +381,6 @@ with gr.Blocks(
369
  lines=22,
370
  label="Output",
371
  elem_classes=["output-box"],
372
- show_copy_button=True,
373
  )
374
 
375
  reason_button.click(
@@ -377,17 +388,20 @@ with gr.Blocks(
377
  inputs=[
378
  reason_prompt,
379
  reason_model,
380
- reasoning_effort,
381
- max_output_tokens_reason,
382
- show_settings_reason,
383
  ],
384
  outputs=reason_output,
385
  )
386
 
387
 
388
  if __name__ == "__main__":
389
- demo.queue()
390
  demo.launch(
 
 
391
  server_name="0.0.0.0",
392
- server_port=int(os.getenv("PORT", "7860")),
393
- )
 
 
 
1
  import os
 
 
 
2
  import gradio as gr
3
  from openai import OpenAI
4
 
5
 
6
+ # =========================
7
+ # Hugging Face Secret
8
+ # =========================
9
+ # Add this in Hugging Face Spaces:
10
+ # Settings → Secrets → New secret
11
+ # Name: OPENAI_API_KEY
12
+ # Value: your OpenAI API key
13
+
14
+
15
+ DEFAULT_GENERATION_MODEL = os.getenv("OPENAI_GENERATION_MODEL", "gpt-5.5")
16
+ DEFAULT_REASONING_MODEL = os.getenv("OPENAI_REASONING_MODEL", "gpt-5.5")
17
+
18
+
19
  GENERATION_MODELS = [
 
 
 
20
  "gpt-5.5",
21
+ "gpt-5.1",
22
+ "gpt-5-mini",
23
+ "gpt-4.1",
24
+ "gpt-4.1-mini",
25
  ]
26
 
27
  REASONING_MODELS = [
28
  "gpt-5.5",
29
+ "gpt-5.1",
30
+ "gpt-5-mini",
31
+ "gpt-5-pro",
32
  ]
33
 
34
 
35
+ def get_openai_client():
36
+ api_key = os.getenv("OPENAI_API_KEY")
 
 
 
 
 
 
 
 
 
37
 
38
+ if not api_key:
39
+ raise ValueError(
40
+ "OPENAI_API_KEY is missing. "
41
+ "Please add it in Hugging Face Spaces → Settings → Secrets."
42
+ )
43
 
44
+ return OpenAI(api_key=api_key)
 
 
 
 
45
 
 
 
 
 
 
 
 
46
 
47
+ def is_gpt5_family(model: str) -> bool:
48
+ return model.startswith("gpt-5")
49
 
50
 
51
+ def extract_output_text(response):
52
  """
53
+ Safely extract text from OpenAI Responses API output.
 
54
  """
55
+ if hasattr(response, "output_text") and response.output_text:
56
+ return response.output_text
57
+
58
+ chunks = []
59
 
60
+ if hasattr(response, "output") and response.output:
61
+ for item in response.output:
62
+ if hasattr(item, "content") and item.content:
63
+ for content in item.content:
64
+ if hasattr(content, "text") and content.text:
65
+ chunks.append(content.text)
66
 
67
+ return "\n".join(chunks).strip()
 
 
 
 
 
68
 
69
 
70
  def run_generation(
71
+ prompt,
72
+ model,
73
+ system_message,
74
+ temperature,
75
+ top_p,
76
+ max_output_tokens,
77
+ frequency_penalty,
78
+ presence_penalty,
79
+ show_settings,
80
+ ):
81
+ try:
82
+ client = get_openai_client()
 
 
 
 
 
 
83
 
84
+ request_params = {
85
+ "model": model,
86
+ "instructions": system_message,
87
+ "input": prompt,
88
+ "max_output_tokens": int(max_output_tokens),
89
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ # GPT-5 family models may reject custom temperature/top_p/penalties.
92
+ # Keep defaults for GPT-5 models to avoid unsupported_value errors.
93
+ if not is_gpt5_family(model):
94
+ request_params["temperature"] = float(temperature)
95
+ request_params["top_p"] = float(top_p)
96
+ request_params["frequency_penalty"] = float(frequency_penalty)
97
+ request_params["presence_penalty"] = float(presence_penalty)
98
+
99
+ response = client.responses.create(**request_params)
100
+ output = extract_output_text(response)
101
+
102
+ if not output:
103
+ output = "No output generated."
104
 
105
  if show_settings:
106
+ settings = f"""
107
+ MODEL SETTINGS
108
+ --------------
109
+ Model: {model}
110
+ Max Output Tokens: {max_output_tokens}
111
+ """
112
+
113
  if is_gpt5_family(model):
114
+ settings += """
115
+ Temperature: default only for GPT-5 family
116
+ Top P: default only for GPT-5 family
117
+ Frequency Penalty: default only for GPT-5 family
118
+ Presence Penalty: default only for GPT-5 family
119
+ """
120
  else:
121
+ settings += f"""
122
+ Temperature: {temperature}
123
+ Top P: {top_p}
124
+ Frequency Penalty: {frequency_penalty}
125
+ Presence Penalty: {presence_penalty}
126
+ """
 
 
 
127
 
128
+ settings += "\nOUTPUT\n------\n"
129
+ return settings + output
130
 
131
+ return output
132
+
133
+ except Exception as e:
134
+ return f"Error:\n{str(e)}"
 
 
 
 
135
 
136
 
137
  def run_reasoning(
138
+ prompt,
139
+ model,
140
+ reasoning_effort,
141
+ max_output_tokens,
142
+ show_settings,
143
+ ):
144
+ try:
145
+ client = get_openai_client()
 
 
 
 
 
 
146
 
147
+ request_params = {
148
+ "model": model,
149
+ "input": prompt,
150
+ "max_output_tokens": int(max_output_tokens),
151
+ "reasoning": {
152
+ "effort": reasoning_effort
153
+ },
154
+ }
155
 
156
+ response = client.responses.create(**request_params)
157
+ output = extract_output_text(response)
 
 
 
 
158
 
159
+ if not output:
160
+ output = "No output generated."
 
161
 
162
  if show_settings:
163
+ settings = f"""
164
+ REASONING SETTINGS
165
+ ------------------
166
+ Model: {model}
167
+ Reasoning Effort: {reasoning_effort}
168
+ Max Output Tokens: {max_output_tokens}
169
+
170
+ OUTPUT
171
+ ------
172
+ """
173
+ return settings + output
 
 
 
 
 
 
 
174
 
175
+ return output
176
 
177
+ except Exception as e:
178
+ return f"Error:\n{str(e)}"
179
+
180
+
181
+ CSS = """
182
  .gradio-container {
183
+ max-width: 1200px !important;
184
  margin: auto !important;
185
  }
186
+
187
+ .main-title {
188
  text-align: center;
189
+ margin-bottom: 20px;
190
+ }
191
+
192
+ .helper-box {
193
+ padding: 14px;
194
+ border-radius: 12px;
195
+ background: #f7f7f8;
196
+ border: 1px solid #e5e7eb;
197
+ margin-bottom: 16px;
198
  }
199
+
200
  .output-box textarea {
201
+ font-family: monospace !important;
202
  }
203
  """
204
 
205
 
206
+ with gr.Blocks() as demo:
 
 
 
 
207
  gr.Markdown(
208
  """
209
+ <div class="main-title">
210
+
211
+ # LLM Generation & Reasoning Controls
212
+
213
+ Experiment with OpenAI model settings using a simple Gradio interface.
214
 
215
+ </div>
216
+ """
 
 
217
  )
218
 
219
+ gr.Markdown(
220
+ """
221
+ <div class="helper-box">
222
+
223
+ <b>Important:</b> Add your OpenAI key in Hugging Face Spaces Secrets as:
 
 
224
 
225
+ <code>OPENAI_API_KEY</code>
226
+
227
+ GPT-5 family models may only support default values for temperature, top-p, and penalties.
228
+ This app automatically skips those settings for GPT-5 models to avoid API errors.
229
+
230
+ </div>
231
+ """
232
+ )
233
+
234
+ with gr.Tab("Generation Controls"):
235
  with gr.Row():
236
  with gr.Column(scale=1):
237
  gen_prompt = gr.Textbox(
 
239
  label="Prompt",
240
  value="Write a short LinkedIn post explaining why business leaders should learn AI. Maximum 120 words.",
241
  )
242
+
243
  gen_model = gr.Dropdown(
244
+ choices=GENERATION_MODELS,
245
  label="Model",
246
+ value=DEFAULT_GENERATION_MODEL
247
+ if DEFAULT_GENERATION_MODEL in GENERATION_MODELS
248
+ else "gpt-5.5",
249
  )
250
+
251
+ gen_system_message = gr.Textbox(
252
  lines=3,
253
  label="System Message",
254
  value="You are a helpful AI instructor. Keep answers clear and practical.",
255
  )
256
+
257
+ gen_temperature = gr.Slider(
258
+ minimum=0.0,
259
+ maximum=2.0,
260
+ step=0.01,
261
+ value=0.7,
262
+ label="Temperature",
263
+ )
264
+
265
+ gen_top_p = gr.Slider(
266
+ minimum=0.0,
267
+ maximum=1.0,
268
+ step=0.01,
269
+ value=1.0,
270
+ label="Top P",
271
+ )
272
+
273
+ gen_max_output_tokens = gr.Slider(
274
+ minimum=50,
275
+ maximum=4000,
276
+ step=50,
277
+ value=500,
278
+ label="Max Output Tokens",
279
+ )
280
+
281
+ gen_frequency_penalty = gr.Slider(
282
+ minimum=-2.0,
283
+ maximum=2.0,
284
+ step=0.01,
285
+ value=0.0,
286
+ label="Frequency Penalty",
287
+ )
288
+
289
+ gen_presence_penalty = gr.Slider(
290
+ minimum=-2.0,
291
+ maximum=2.0,
292
+ step=0.01,
293
+ value=0.0,
294
+ label="Presence Penalty",
295
+ )
296
+
297
+ gen_show_settings = gr.Checkbox(
298
+ value=True,
299
+ label="Show Settings",
300
+ )
301
+
302
  gen_button = gr.Button("Generate", variant="primary")
303
 
304
  with gr.Column(scale=1):
 
306
  lines=22,
307
  label="Output",
308
  elem_classes=["output-box"],
 
309
  )
310
 
311
  gen_button.click(
 
313
  inputs=[
314
  gen_prompt,
315
  gen_model,
316
+ gen_system_message,
317
+ gen_temperature,
318
+ gen_top_p,
319
+ gen_max_output_tokens,
320
+ gen_frequency_penalty,
321
+ gen_presence_penalty,
322
+ gen_show_settings,
323
  ],
324
  outputs=gen_output,
325
  )
326
 
327
  with gr.Tab("Reasoning Controls"):
 
 
 
 
 
 
328
  with gr.Row():
329
  with gr.Column(scale=1):
330
  reason_prompt = gr.Textbox(
331
  lines=9,
332
  label="Prompt",
333
+ value="""A telecom company wants to build an AI customer support assistant.
334
+
335
+ They have:
336
+ - 50,000 past support tickets
337
+ - A FAQ website
338
+ - Billing policies
339
+ - A small developer team
340
+
341
+ Should they start with:
342
+ 1. Simple prompt-based chatbot
343
+ 2. RAG chatbot
344
+ 3. Fine-tuning
345
+ 4. Agent with tools
346
+
347
+ Give a practical recommendation with trade-offs.""",
348
  )
349
+
350
  reason_model = gr.Dropdown(
351
+ choices=REASONING_MODELS,
352
  label="Model",
353
+ value=DEFAULT_REASONING_MODEL
354
+ if DEFAULT_REASONING_MODEL in REASONING_MODELS
355
+ else "gpt-5.5",
356
  )
357
+
358
+ reason_effort = gr.Radio(
359
+ choices=["low", "medium", "high"],
360
  label="Reasoning Effort",
361
  value="medium",
362
  )
363
+
364
+ reason_max_output_tokens = gr.Slider(
365
  minimum=100,
366
  maximum=8000,
367
+ step=100,
368
+ value=1000,
369
  label="Max Output Tokens",
370
  )
371
+
372
+ reason_show_settings = gr.Checkbox(
373
+ value=True,
374
+ label="Show Settings",
375
+ )
376
+
377
  reason_button = gr.Button("Reason", variant="primary")
378
 
379
  with gr.Column(scale=1):
 
381
  lines=22,
382
  label="Output",
383
  elem_classes=["output-box"],
 
384
  )
385
 
386
  reason_button.click(
 
388
  inputs=[
389
  reason_prompt,
390
  reason_model,
391
+ reason_effort,
392
+ reason_max_output_tokens,
393
+ reason_show_settings,
394
  ],
395
  outputs=reason_output,
396
  )
397
 
398
 
399
  if __name__ == "__main__":
 
400
  demo.launch(
401
+ theme=gr.themes.Soft(),
402
+ css=CSS,
403
  server_name="0.0.0.0",
404
+ server_port=int(os.getenv("PORT", 7860)),
405
+ debug=False,
406
+ share=False,
407
+ )