Spaces:
Running
A newer version of the Gradio SDK is available:
6.0.2
Error Fixes Summary
Issues Identified and Fixed
1. ✅ 'Settings' object has no attribute 'ocr_api_url'
Error Location: src/services/image_ocr.py:33
Root Cause:
The code was trying to access settings.ocr_api_url which doesn't exist in older versions of the config. This happens when running a previous version of the app where ocr_api_url wasn't added to the Settings class yet.
Fix Applied:
- Added defensive coding using
getattr()with a fallback default URL - Default URL:
"https://prithivmlmods-multimodal-ocr3.hf.space"
Code Change:
# Before:
self.api_url = api_url or settings.ocr_api_url
# After:
default_url = getattr(settings, "ocr_api_url", None) or "https://prithivmlmods-multimodal-ocr3.hf.space"
self.api_url = api_url or default_url
File: src/services/image_ocr.py
2. ✅ Expected code to be unreachable, but got: ('research_complete', False)
Error Location: src/orchestrator/graph_orchestrator.py (decision node execution)
Root Cause:
When Pydantic AI encounters a validation error or returns an unexpected format, it may return a tuple like ('research_complete', False) instead of the expected KnowledgeGapOutput object. The decision function was trying to access result.research_complete on a tuple, causing the error.
Fix Applied:
- Enhanced decision function in
graph_builder.pyto handle tuple formats - Improved tuple handling in
graph_orchestrator.pydecision node execution - Better reconstruction of
KnowledgeGapOutputfrom validation error tuples
Code Changes:
File: src/agent_factory/graph_builder.py
- Replaced lambda with named function
_decision_function()that handles tuples - Added logic to extract
research_completefrom various tuple formats - Handles:
('research_complete', False), dicts in tuples, boolean values in tuples
File: src/orchestrator/graph_orchestrator.py
- Enhanced tuple detection and reconstruction in
_execute_decision_node() - Added specific handling for
('research_complete', False)format - Improved fallback logic for unexpected tuple formats
- Better error messages and logging
File: src/orchestrator/graph_orchestrator.py (agent node execution)
- Improved handling of tuple outputs in
_execute_agent_node() - Better reconstruction of
KnowledgeGapOutputfrom validation errors - More graceful fallback for non-knowledge_gap nodes
3. ⚠️ Local state is not initialized - app is not locally available (Modal TTS)
Error Location: Modal TTS service
Root Cause: This is expected behavior when Modal credentials are not configured or the app is not running in a Modal environment. It's not a critical error - TTS will simply be unavailable.
Status:
- This is not an error - it's expected when Modal isn't configured
- The app gracefully degrades and continues without TTS
- Users can still use the app, just without audio output
No Fix Needed: This is working as designed with graceful degradation.
4. ⚠️ Invalid file descriptor: -1 (Asyncio cleanup)
Error Location: Python asyncio event loop cleanup
Root Cause: This is a Python asyncio cleanup warning that occurs during shutdown. It's not critical and doesn't affect functionality.
Status:
- This is a warning, not an error
- Occurs during application shutdown
- Doesn't affect runtime functionality
- Common in Python 3.11+ with certain asyncio patterns
No Fix Needed: This is a known Python asyncio quirk and doesn't impact functionality.
5. ⚠️ MCP Server Warning: gr.State input will not be updated between tool calls
Error Location: Gradio MCP server setup
Root Cause:
Some MCP tools use gr.State inputs, which Gradio warns won't update between tool calls. This is a limitation of how MCP tools interact with Gradio state.
Status:
- This is a warning, not an error
- MCP tools will still work, but state won't persist between calls
- This is a known Gradio MCP limitation
No Fix Needed: This is a Gradio limitation, not a bug in our code.
Summary of Fixes
Critical Fixes (Applied):
- ✅ OCR API URL Attribute Error - Fixed with defensive coding
- ✅ Graph Orchestrator Tuple Handling - Fixed with enhanced tuple detection and reconstruction
Non-Critical (Expected Behavior):
- ⚠️ Modal TTS Error - Expected when Modal not configured (graceful degradation)
- ⚠️ Asyncio Cleanup Warning - Python asyncio quirk (non-critical)
- ⚠️ MCP State Warning - Gradio limitation (non-critical)
Testing Recommendations
Test OCR functionality:
- Upload an image with text
- Verify OCR processing works
- Check logs for any remaining errors
Test graph execution:
- Run a research query
- Verify knowledge gap evaluation works
- Check that decision nodes route correctly
- Monitor logs for tuple handling warnings
Test with/without Modal:
- Verify app works without Modal credentials
- Test TTS if Modal is configured
- Verify graceful degradation
Files Modified
src/services/image_ocr.py- Added defensiveocr_api_urlaccesssrc/orchestrator/graph_orchestrator.py- Enhanced tuple handling in decision and agent nodessrc/agent_factory/graph_builder.py- Improved decision function to handle tuples
Next Steps
- Test the fixes with the reported error scenarios
- Monitor logs for any remaining issues
- Consider adding unit tests for tuple handling edge cases
- Document the tuple format handling for future reference