prithivMLmods commited on
Commit
f76444e
·
verified ·
1 Parent(s): 49d0c17

Update app.py

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