Spaces:
Running
Running
File size: 5,646 Bytes
77f56a9 9f14662 b234660 345f6b1 25435fb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# 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:**
```python
# 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:**
1. **Enhanced decision function** in `graph_builder.py` to handle tuple formats
2. **Improved tuple handling** in `graph_orchestrator.py` decision node execution
3. **Better reconstruction** of `KnowledgeGapOutput` from 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_complete` from 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 `KnowledgeGapOutput` from 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):
1. ✅ **OCR API URL Attribute Error** - Fixed with defensive coding
2. ✅ **Graph Orchestrator Tuple Handling** - Fixed with enhanced tuple detection and reconstruction
### Non-Critical (Expected Behavior):
3. ⚠️ **Modal TTS Error** - Expected when Modal not configured (graceful degradation)
4. ⚠️ **Asyncio Cleanup Warning** - Python asyncio quirk (non-critical)
5. ⚠️ **MCP State Warning** - Gradio limitation (non-critical)
## Testing Recommendations
1. **Test OCR functionality:**
- Upload an image with text
- Verify OCR processing works
- Check logs for any remaining errors
2. **Test graph execution:**
- Run a research query
- Verify knowledge gap evaluation works
- Check that decision nodes route correctly
- Monitor logs for tuple handling warnings
3. **Test with/without Modal:**
- Verify app works without Modal credentials
- Test TTS if Modal is configured
- Verify graceful degradation
## Files Modified
1. `src/services/image_ocr.py` - Added defensive `ocr_api_url` access
2. `src/orchestrator/graph_orchestrator.py` - Enhanced tuple handling in decision and agent nodes
3. `src/agent_factory/graph_builder.py` - Improved decision function to handle tuples
## Next Steps
1. Test the fixes with the reported error scenarios
2. Monitor logs for any remaining issues
3. Consider adding unit tests for tuple handling edge cases
4. Document the tuple format handling for future reference
|