uasername commited on
Commit
2383300
·
verified ·
1 Parent(s): cfb5578

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -75,7 +75,7 @@ with open("prompts.yaml", 'r') as stream:
75
 
76
  agent = CodeAgent(
77
  model=model,
78
- tools=[visit_webpage_tool, web_search_tool, final_answer, image_generation_tool, get_current_time_in_timezone, get_random_cocktail, search_dad_jokes, text_to_speech_kokoro], ## add your tools here (don't remove final answer)
79
  max_steps=6,
80
  verbosity_level=1,
81
  grammar=None,
@@ -86,21 +86,22 @@ agent = CodeAgent(
86
  )
87
 
88
  # Gradio interface with text and audio output
89
- def gradio_define_word(word):
90
- """Wrapper function for Gradio to call the define_word tool."""
91
- response_text, audio_file = define_word(word)
92
  return response_text, audio_file
93
 
94
  # Define the Gradio UI
95
  with gr.Blocks() as demo:
96
- gr.Markdown("### Dictionary Lookup with AI & Text-to-Speech 🎙️")
 
97
  with gr.Row():
98
  input_box = gr.Textbox(label="Enter a word")
99
- output_text = gr.Textbox(label="Definition")
100
  output_audio = gr.Audio(label="Audio Pronunciation", type="filepath")
101
 
102
- btn = gr.Button("Get Definition")
103
- btn.click(gradio_define_word, inputs=input_box, outputs=[output_text, output_audio])
104
 
105
  demo.launch()
106
 
 
75
 
76
  agent = CodeAgent(
77
  model=model,
78
+ tools=[visit_webpage_tool, web_search_tool, final_answer, image_generation_tool, search_dad_jokes], ## add your tools here (don't remove final answer)
79
  max_steps=6,
80
  verbosity_level=1,
81
  grammar=None,
 
86
  )
87
 
88
  # Gradio interface with text and audio output
89
+ def gradio_search_jokes(word):
90
+ """Wrapper function for Gradio to call search_dad_jokes and generate audio."""
91
+ response_text, audio_file = search_dad_jokes(word) # Ensure search_dad_jokes returns (text, file path)
92
  return response_text, audio_file
93
 
94
  # Define the Gradio UI
95
  with gr.Blocks() as demo:
96
+ gr.Markdown("### Dad Jokes Finder with AI & Text-to-Speech 🎙️")
97
+
98
  with gr.Row():
99
  input_box = gr.Textbox(label="Enter a word")
100
+ output_text = gr.Textbox(label="Jokes Found")
101
  output_audio = gr.Audio(label="Audio Pronunciation", type="filepath")
102
 
103
+ btn = gr.Button("Get Jokes")
104
+ btn.click(gradio_search_jokes, inputs=input_box, outputs=[output_text, output_audio])
105
 
106
  demo.launch()
107