Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -568,42 +568,50 @@ def generate(
|
|
| 568 |
output_file = asyncio.run(text_to_speech(final_response, voice))
|
| 569 |
yield gr.Audio(output_file, autoplay=True)
|
| 570 |
|
| 571 |
-
# Gradio Chat Interface Setup and Launch
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
["@3d A birthday cupcake with cherry"],
|
| 585 |
-
[{"text": "summarize the letter", "files": ["examples/1.png"]}],
|
| 586 |
-
["@image Chocolate dripping from a donut against a yellow background, in the style of brocore, hyper-realistic"],
|
| 587 |
-
["@rAgent Explain how a binary search algorithm works."],
|
| 588 |
-
["@web latest breakthroughs in renewable energy"],
|
| 589 |
-
|
| 590 |
-
],
|
| 591 |
-
cache_examples=False,
|
| 592 |
-
type="messages",
|
| 593 |
-
description=DESCRIPTION,
|
| 594 |
-
css=css,
|
| 595 |
-
fill_height=True,
|
| 596 |
-
textbox=gr.MultimodalTextbox(label="Query Input", file_types=["image"], file_count="multiple"),
|
| 597 |
-
stop_btn="Stop Generation",
|
| 598 |
-
multimodal=True,
|
| 599 |
-
)
|
| 600 |
|
| 601 |
-
|
| 602 |
-
|
| 603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 604 |
|
| 605 |
-
|
| 606 |
-
|
|
|
|
| 607 |
|
| 608 |
if __name__ == "__main__":
|
| 609 |
demo.queue(max_size=20).launch(share=True)
|
|
|
|
| 568 |
output_file = asyncio.run(text_to_speech(final_response, voice))
|
| 569 |
yield gr.Audio(output_file, autoplay=True)
|
| 570 |
|
| 571 |
+
# Gradio Chat Interface Setup and Launch using Blocks with Sidebar
|
| 572 |
+
|
| 573 |
+
with gr.Blocks(css=css) as demo:
|
| 574 |
+
with gr.Sidebar(label="Usage", open=True):
|
| 575 |
+
gr.Markdown(
|
| 576 |
+
"### About Space\n\n"
|
| 577 |
+
"This chat interface supports multiple commands:\n"
|
| 578 |
+
"- `@tts1` or `@tts2`: Triggers text-to-speech.\n"
|
| 579 |
+
"- `@image`: Generates an image using Stable Diffusion XL.\n"
|
| 580 |
+
"- `@3d`: Generates a 3D model using the ShapE pipeline.\n"
|
| 581 |
+
"- `@web`: Performs a web search or visits a webpage.\n"
|
| 582 |
+
"- `@rAgent`: Initiates a reasoning chain using Llama mode OpenAI."
|
| 583 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
|
| 585 |
+
chat_interface = gr.ChatInterface(
|
| 586 |
+
fn=generate,
|
| 587 |
+
additional_inputs=[
|
| 588 |
+
gr.Slider(label="Max new tokens", minimum=1, maximum=MAX_MAX_NEW_TOKENS, step=1, value=DEFAULT_MAX_NEW_TOKENS),
|
| 589 |
+
gr.Slider(label="Temperature", minimum=0.1, maximum=4.0, step=0.1, value=0.6),
|
| 590 |
+
gr.Slider(label="Top-p (nucleus sampling)", minimum=0.05, maximum=1.0, step=0.05, value=0.9),
|
| 591 |
+
gr.Slider(label="Top-k", minimum=1, maximum=1000, step=1, value=50),
|
| 592 |
+
gr.Slider(label="Repetition penalty", minimum=1.0, maximum=2.0, step=0.05, value=1.2),
|
| 593 |
+
],
|
| 594 |
+
examples=[
|
| 595 |
+
["@tts2 What causes rainbows to form?"],
|
| 596 |
+
["@3d A birthday cupcake with cherry"],
|
| 597 |
+
[{"text": "summarize the letter", "files": ["examples/1.png"]}],
|
| 598 |
+
["@image Chocolate dripping from a donut against a yellow background, in the style of brocore, hyper-realistic"],
|
| 599 |
+
["@rAgent Explain how a binary search algorithm works."],
|
| 600 |
+
["@web latest breakthroughs in renewable energy"],
|
| 601 |
+
],
|
| 602 |
+
cache_examples=False,
|
| 603 |
+
type="messages",
|
| 604 |
+
description=DESCRIPTION,
|
| 605 |
+
css=css,
|
| 606 |
+
fill_height=True,
|
| 607 |
+
textbox=gr.MultimodalTextbox(label="Query Input", file_types=["image"], file_count="multiple"),
|
| 608 |
+
stop_btn="Stop Generation",
|
| 609 |
+
multimodal=True,
|
| 610 |
+
)
|
| 611 |
|
| 612 |
+
# Ensure the static folder is mounted for serving generated files.
|
| 613 |
+
from fastapi.staticfiles import StaticFiles
|
| 614 |
+
demo.app.mount("/static", StaticFiles(directory="static"), name="static")
|
| 615 |
|
| 616 |
if __name__ == "__main__":
|
| 617 |
demo.queue(max_size=20).launch(share=True)
|