Spaces:
Running
on
Zero
Running
on
Zero
adds interface
Browse files
README.md
CHANGED
|
@@ -5,7 +5,7 @@ colorFrom: blue
|
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
app_file: app.py
|
| 8 |
-
pinned:
|
| 9 |
---
|
| 10 |
|
| 11 |
# Demo: Tonic/med-gpt-oss-20b
|
|
|
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
app_file: app.py
|
| 8 |
+
pinned: true
|
| 9 |
---
|
| 10 |
|
| 11 |
# Demo: Tonic/med-gpt-oss-20b
|
app.py
CHANGED
|
@@ -236,51 +236,10 @@ def generate_response(input_data, chat_history, max_new_tokens, model_identity,
|
|
| 236 |
logging.exception("Generation streaming failed")
|
| 237 |
yield f"❌ Error during generation: {e}"
|
| 238 |
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
additional_inputs=[
|
| 242 |
-
gr.Slider(label="Max new tokens", minimum=64, maximum=4096, step=1, value=2048),
|
| 243 |
-
gr.Textbox(
|
| 244 |
-
label="Model Identity",
|
| 245 |
-
value=MODEL_IDENTITY,
|
| 246 |
-
lines=3,
|
| 247 |
-
placeholder="Optional identity/persona for the model"
|
| 248 |
-
),
|
| 249 |
-
gr.Textbox(
|
| 250 |
-
label="System Prompt",
|
| 251 |
-
value=DEFAULT_SYSTEM_PROMPT,
|
| 252 |
-
lines=4,
|
| 253 |
-
placeholder="Change system prompt"
|
| 254 |
-
),
|
| 255 |
-
gr.Textbox(
|
| 256 |
-
label="Developer Prompt",
|
| 257 |
-
value=DEFAULT_DEVELOPER_PROMPT,
|
| 258 |
-
lines=4,
|
| 259 |
-
placeholder="Optional developer instructions"
|
| 260 |
-
),
|
| 261 |
-
gr.Dropdown(
|
| 262 |
-
label="Reasoning Effort",
|
| 263 |
-
choices=["low", "medium", "high"],
|
| 264 |
-
value=DEFAULT_REASONING_EFFORT,
|
| 265 |
-
interactive=True,
|
| 266 |
-
),
|
| 267 |
-
gr.Slider(label="Temperature", minimum=0.1, maximum=2.0, step=0.1, value=0.7),
|
| 268 |
-
gr.Slider(label="Top-p", minimum=0.05, maximum=1.0, step=0.05, value=0.9),
|
| 269 |
-
gr.Slider(label="Top-k", minimum=1, maximum=100, step=1, value=50),
|
| 270 |
-
gr.Slider(label="Repetition Penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.0)
|
| 271 |
-
],
|
| 272 |
-
examples=[
|
| 273 |
-
[{"text": "Explain Newton's laws clearly and concisely with mathematical formulas"}],
|
| 274 |
-
[{"text": "Write a Python function to calculate the Fibonacci sequence"}],
|
| 275 |
-
[{"text": "What are the benefits of open weight AI models? Include analysis."}],
|
| 276 |
-
[{"text": "Solve this equation: $x^2 + 5x + 6 = 0$"}],
|
| 277 |
-
],
|
| 278 |
-
cache_examples=False,
|
| 279 |
-
type="messages",
|
| 280 |
-
description=f"""
|
| 281 |
-
|
| 282 |
-
# 🙋🏻♂️Welcome to 🌟{MODEL_NAME} Demo !
|
| 283 |
|
|
|
|
| 284 |
**Model**: `{LORA_MODEL_ID}`
|
| 285 |
**Base**: `{BASE_MODEL_ID}`
|
| 286 |
|
|
@@ -294,16 +253,66 @@ demo = gr.ChatInterface(
|
|
| 294 |
- Adjust reasoning level in system prompt (e.g., "Reasoning: high")
|
| 295 |
- Use LaTeX for math: `$E = mc^2$` or `$$\\int x^2 dx$$`
|
| 296 |
- Wait a couple of seconds initially for model loading
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
|
| 308 |
if __name__ == "__main__":
|
| 309 |
demo.launch(share=True)
|
|
|
|
| 236 |
logging.exception("Generation streaming failed")
|
| 237 |
yield f"❌ Error during generation: {e}"
|
| 238 |
|
| 239 |
+
|
| 240 |
+
TITLE_MD = f"# 🙋🏻♂️Welcome to 🌟Tonic's ⚕️{MODEL_NAME} Demo !"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 241 |
|
| 242 |
+
DESCRIPTION_MD = f"""
|
| 243 |
**Model**: `{LORA_MODEL_ID}`
|
| 244 |
**Base**: `{BASE_MODEL_ID}`
|
| 245 |
|
|
|
|
| 253 |
- Adjust reasoning level in system prompt (e.g., "Reasoning: high")
|
| 254 |
- Use LaTeX for math: `$E = mc^2$` or `$$\\int x^2 dx$$`
|
| 255 |
- Wait a couple of seconds initially for model loading
|
| 256 |
+
"""
|
| 257 |
+
|
| 258 |
+
JOIN_US_MD = """
|
| 259 |
+
## Join us :
|
| 260 |
+
🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻 [](https://discord.gg/qdfnvSPcqP) On 🤗Huggingface:[MultiTransformer](https://huggingface.co/MultiTransformer) On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [MultiTonic](https://github.com/MultiTonic)🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
| 261 |
+
"""
|
| 262 |
+
|
| 263 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 264 |
+
gr.Markdown(TITLE_MD)
|
| 265 |
+
with gr.Row():
|
| 266 |
+
with gr.Column(scale=3):
|
| 267 |
+
gr.Markdown(DESCRIPTION_MD)
|
| 268 |
+
with gr.Column(scale=2):
|
| 269 |
+
gr.Markdown(JOIN_US_MD)
|
| 270 |
+
|
| 271 |
+
gr.ChatInterface(
|
| 272 |
+
fn=generate_response,
|
| 273 |
+
additional_inputs=[
|
| 274 |
+
gr.Slider(label="Max new tokens", minimum=64, maximum=4096, step=1, value=2048),
|
| 275 |
+
gr.Textbox(
|
| 276 |
+
label="Model Identity",
|
| 277 |
+
value=MODEL_IDENTITY,
|
| 278 |
+
lines=3,
|
| 279 |
+
placeholder="Optional identity/persona for the model"
|
| 280 |
+
),
|
| 281 |
+
gr.Textbox(
|
| 282 |
+
label="System Prompt",
|
| 283 |
+
value=DEFAULT_SYSTEM_PROMPT,
|
| 284 |
+
lines=4,
|
| 285 |
+
placeholder="Change system prompt"
|
| 286 |
+
),
|
| 287 |
+
gr.Textbox(
|
| 288 |
+
label="Developer Prompt",
|
| 289 |
+
value=DEFAULT_DEVELOPER_PROMPT,
|
| 290 |
+
lines=4,
|
| 291 |
+
placeholder="Optional developer instructions"
|
| 292 |
+
),
|
| 293 |
+
gr.Dropdown(
|
| 294 |
+
label="Reasoning Effort",
|
| 295 |
+
choices=["low", "medium", "high"],
|
| 296 |
+
value=DEFAULT_REASONING_EFFORT,
|
| 297 |
+
interactive=True,
|
| 298 |
+
),
|
| 299 |
+
examples=[
|
| 300 |
+
[{"text": "A 68-year-old man complains of several blisters arising over the back and trunk for the preceding 2 weeks. He takes no medications and has not noted systemic symptoms such as fever, sore throat, weight loss, or fatigue. The general physical examination is normal. The oral mucosa and the lips are normal. Several 2- to 3-cm bullae are present over the trunk and back. A few excoriations where the blisters have ruptured are present. The remainder of the skin is normal, without erythema or scale. What is the best diagnostic approach at this time?"}],
|
| 301 |
+
[{"text": "A 28-year-old woman, gravida 2, para 1, at 40 weeks of gestation is admitted to the hospital in active labor. The patient has attended many prenatal appointments and followed her physician's advice about screening for diseases, laboratory testing, diet, and exercise. Her pregnancy has been uncomplicated. She has no history of a serious illness. Her first child was delivered via normal vaginal delivery. Her vital signs are within normal limits. Cervical examination shows 100% effacement and 10 cm dilation. A cardiotocograph is shown. Which of the following is the most appropriate initial step in management?"}],
|
| 302 |
+
[{"text": "An 18-year-old woman has eaten homemade preserves. Eighteen hours later, she develops diplopia, dysarthria, and dysphagia. She presents to the emergency room for assessment and on examination her blood pressure is 112/74 mmHg, heart rate 110/min, and respirations 20/min. The pertinent findings are abnormal extraocular movements due to cranial nerve palsies, difficulty swallowing and a change in her voice. The strength in her arms is 4/5 and 5/5 in her legs, and the reflexes are normal. Which of the following is the most likely causative organism?"}],
|
| 303 |
+
[{"text": "What are you & who made you?"}],
|
| 304 |
+
],
|
| 305 |
+
|
| 306 |
+
cache_examples=False,
|
| 307 |
+
type="messages",
|
| 308 |
+
fill_height=True,
|
| 309 |
+
textbox=gr.Textbox(
|
| 310 |
+
label="Query Input",
|
| 311 |
+
placeholder="Type your prompt (supports LaTeX: $x^2 + y^2 = z^2$)"
|
| 312 |
+
),
|
| 313 |
+
stop_btn="Stop Generation",
|
| 314 |
+
multimodal=False,
|
| 315 |
+
)
|
| 316 |
|
| 317 |
if __name__ == "__main__":
|
| 318 |
demo.launch(share=True)
|