Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -71,11 +71,10 @@ class ToolBase:
|
|
| 71 |
self.json_name = programmatic_name
|
| 72 |
self.json_description = passive_voice_description_of_function
|
| 73 |
|
| 74 |
-
# Fix:
|
| 75 |
parameters_schema = {
|
| 76 |
"type": "object",
|
| 77 |
-
"properties": input_params
|
| 78 |
-
"additionalProperties": False # Explicitly set to False
|
| 79 |
}
|
| 80 |
|
| 81 |
if required_params:
|
|
@@ -173,13 +172,11 @@ class ArxivSearchTool(ToolBase):
|
|
| 173 |
},
|
| 174 |
"max_results": {
|
| 175 |
"type": "integer",
|
| 176 |
-
"description": "Maximum number of results to return (default: 5)"
|
| 177 |
-
"default": 5
|
| 178 |
},
|
| 179 |
"sort_by": {
|
| 180 |
"type": "string",
|
| 181 |
-
"description": "Sort criteria (e.g., 'relevance', 'lastUpdatedDate', 'submittedDate')"
|
| 182 |
-
"default": "relevance"
|
| 183 |
}
|
| 184 |
},
|
| 185 |
required_params=["query"],
|
|
@@ -314,10 +311,12 @@ def get_weather_data(location):
|
|
| 314 |
full_url = base_url + "?" + "&".join([f"{k}={urllib.parse.quote(str(v))}" for k, v in params.items()])
|
| 315 |
try:
|
| 316 |
response = requests.get(full_url)
|
| 317 |
-
|
|
|
|
| 318 |
lgs("FAILED PARAMS: " + str(params))
|
| 319 |
-
lgs("FAILED
|
| 320 |
-
|
|
|
|
| 321 |
if response.status_code != 200:
|
| 322 |
return {"error": f"Failed to retrieve weather data for {location}. Status code: {response.status_code}"}
|
| 323 |
data = response.json()
|
|
@@ -533,25 +532,20 @@ llm = LLM(max_model_len=32000)
|
|
| 533 |
|
| 534 |
lgs("STARTING NEW CHAT")
|
| 535 |
|
| 536 |
-
#
|
| 537 |
with gr.Blocks() as demo:
|
| 538 |
gr.Markdown("<h2>Weather/Arxiv/SNP Multi-tool Calling Bot</h2>")
|
| 539 |
chat_state = gr.State([])
|
| 540 |
-
|
|
|
|
| 541 |
user_input = gr.Textbox(
|
| 542 |
lines=1,
|
| 543 |
placeholder="Type your message here...",
|
| 544 |
)
|
| 545 |
gr.Examples([
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
[
|
| 550 |
-
"List some papers about humor in LLMs",
|
| 551 |
-
],
|
| 552 |
-
[
|
| 553 |
-
"What does this SNP do?: rs429358",
|
| 554 |
-
]
|
| 555 |
],
|
| 556 |
inputs=[user_input],
|
| 557 |
label="Examples",
|
|
@@ -571,4 +565,8 @@ with gr.Blocks() as demo:
|
|
| 571 |
queue=False
|
| 572 |
)
|
| 573 |
|
| 574 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
self.json_name = programmatic_name
|
| 72 |
self.json_description = passive_voice_description_of_function
|
| 73 |
|
| 74 |
+
# Fix: Avoid additionalProperties entirely to prevent Gradio JSON schema parsing issue
|
| 75 |
parameters_schema = {
|
| 76 |
"type": "object",
|
| 77 |
+
"properties": input_params
|
|
|
|
| 78 |
}
|
| 79 |
|
| 80 |
if required_params:
|
|
|
|
| 172 |
},
|
| 173 |
"max_results": {
|
| 174 |
"type": "integer",
|
| 175 |
+
"description": "Maximum number of results to return (default: 5)"
|
|
|
|
| 176 |
},
|
| 177 |
"sort_by": {
|
| 178 |
"type": "string",
|
| 179 |
+
"description": "Sort criteria (e.g., 'relevance', 'lastUpdatedDate', 'submittedDate')"
|
|
|
|
| 180 |
}
|
| 181 |
},
|
| 182 |
required_params=["query"],
|
|
|
|
| 311 |
full_url = base_url + "?" + "&".join([f"{k}={urllib.parse.quote(str(v))}" for k, v in params.items()])
|
| 312 |
try:
|
| 313 |
response = requests.get(full_url)
|
| 314 |
+
lgs("RAW RESPONSE: " + str(response))
|
| 315 |
+
except Exception as e:
|
| 316 |
lgs("FAILED PARAMS: " + str(params))
|
| 317 |
+
lgs("FAILED ERROR: " + str(e))
|
| 318 |
+
return {"error": f"Failed to retrieve weather data for {location}. Error: {str(e)}"}
|
| 319 |
+
|
| 320 |
if response.status_code != 200:
|
| 321 |
return {"error": f"Failed to retrieve weather data for {location}. Status code: {response.status_code}"}
|
| 322 |
data = response.json()
|
|
|
|
| 532 |
|
| 533 |
lgs("STARTING NEW CHAT")
|
| 534 |
|
| 535 |
+
# Fix: Use simpler Gradio configuration to avoid JSON schema parsing issues
|
| 536 |
with gr.Blocks() as demo:
|
| 537 |
gr.Markdown("<h2>Weather/Arxiv/SNP Multi-tool Calling Bot</h2>")
|
| 538 |
chat_state = gr.State([])
|
| 539 |
+
# Use default tuple format instead of messages to avoid schema issues
|
| 540 |
+
chatbot = gr.Chatbot(label="Chat with the multi-tool bot")
|
| 541 |
user_input = gr.Textbox(
|
| 542 |
lines=1,
|
| 543 |
placeholder="Type your message here...",
|
| 544 |
)
|
| 545 |
gr.Examples([
|
| 546 |
+
"What is the current weather in Åfjord?",
|
| 547 |
+
"List some papers about humor in LLMs",
|
| 548 |
+
"What does this SNP do?: rs429358"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 549 |
],
|
| 550 |
inputs=[user_input],
|
| 551 |
label="Examples",
|
|
|
|
| 565 |
queue=False
|
| 566 |
)
|
| 567 |
|
| 568 |
+
# Launch with minimal configuration to avoid schema generation issues
|
| 569 |
+
demo.queue(max_size=99).launch(
|
| 570 |
+
show_api=False, # Disable API documentation generation
|
| 571 |
+
quiet=True # Reduce verbose output
|
| 572 |
+
)
|