Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -87,7 +87,7 @@ def image_generation(query):
|
|
87 |
def handle_input(user_prompt, image=None, audio=None, websearch=False):
|
88 |
if audio:
|
89 |
if isinstance(audio, str):
|
90 |
-
audio = open(audio, "rb")
|
91 |
transcription = client.audio.transcriptions.create(
|
92 |
file=(audio.name, audio.read()),
|
93 |
model="whisper-large-v3"
|
@@ -96,9 +96,12 @@ def handle_input(user_prompt, image=None, audio=None, websearch=False):
|
|
96 |
|
97 |
tools = [
|
98 |
FunctionTool.from_defaults(fn=numpy_code_calculator, name="Numpy Code Calculator"),
|
99 |
-
FunctionTool.from_defaults(fn=web_search, name="Web Search"),
|
100 |
FunctionTool.from_defaults(fn=image_generation, name="Image Generation"),
|
101 |
]
|
|
|
|
|
|
|
|
|
102 |
|
103 |
llm = Groq(model=MODEL, api_key=os.environ.get("GROQ_API_KEY"))
|
104 |
agent = ReActAgent.from_tools(tools, llm=llm, verbose=True)
|
@@ -116,6 +119,7 @@ def handle_input(user_prompt, image=None, audio=None, websearch=False):
|
|
116 |
|
117 |
return response
|
118 |
|
|
|
119 |
# Gradio UI Setup
|
120 |
def create_ui():
|
121 |
with gr.Blocks() as demo:
|
|
|
87 |
def handle_input(user_prompt, image=None, audio=None, websearch=False):
|
88 |
if audio:
|
89 |
if isinstance(audio, str):
|
90 |
+
audio = open(audio, "rb")
|
91 |
transcription = client.audio.transcriptions.create(
|
92 |
file=(audio.name, audio.read()),
|
93 |
model="whisper-large-v3"
|
|
|
96 |
|
97 |
tools = [
|
98 |
FunctionTool.from_defaults(fn=numpy_code_calculator, name="Numpy Code Calculator"),
|
|
|
99 |
FunctionTool.from_defaults(fn=image_generation, name="Image Generation"),
|
100 |
]
|
101 |
+
|
102 |
+
# Add the web search tool only if websearch mode is enabled
|
103 |
+
if websearch:
|
104 |
+
tools.append(FunctionTool.from_defaults(fn=web_search, name="Web Search"))
|
105 |
|
106 |
llm = Groq(model=MODEL, api_key=os.environ.get("GROQ_API_KEY"))
|
107 |
agent = ReActAgent.from_tools(tools, llm=llm, verbose=True)
|
|
|
119 |
|
120 |
return response
|
121 |
|
122 |
+
|
123 |
# Gradio UI Setup
|
124 |
def create_ui():
|
125 |
with gr.Blocks() as demo:
|