Raven Document Notification conditions, message templates and Jinja
recipients were evaluated with the full server-script frappe object.
Raven Admins can edit these but aren't System Managers, so a Raven
Admin could write any record, for example create a System Manager user,
or make outbound requests.
Use render_safe_globals instead, the read-only set Frappe gives Jinja
templates. On Frappe versions without it (before v15.111 and v16.21),
fall back to frappe.utils only. Simple conditions like
doc.status == "Open" keep working.
Raise the minimum Frappe version to 15.111.0.
* feat: implement OpenAI Agents SDK with local LLM support
## Major Changes
### OpenAI Agents SDK Integration
- Migrate from OpenAI Assistants API to Agents SDK (v0.0.16+)
- Add support for local LLMs (LM Studio, Ollama, LocalAI)
- Implement hybrid architecture supporting both legacy Assistants and new Agents
- Add model provider selection in bot configuration
### File Analysis Enhancement
- Implement Excel/CSV file analysis without Code Interpreter requirement
- Add MarkItDown library integration for document-to-markdown conversion
- Fallback to pandas for spreadsheet conversion when MarkItDown unavailable
- Enable direct LLM analysis of uploaded files
### Function Calling Implementation
- Full support for Raven AI Functions with SDK
- Auto-load bot-specific functions from Raven Bot Functions
- Fix JSON serialization for datetime objects
- Improve function descriptions for better LLM understanding
### Code Cleanup
- Remove debug logging and unnecessary frappe.log_error calls
- Clean up unused SDK implementation files (handler_agents.py, sdk_agents.py, sdk_handler.py)
- Remove debug files (debug_agents.py, debug_thread.py)
- Remove private URL references
### Frontend Updates
- Create unified AI Settings page for OpenAI and Local LLM configuration
- Add model provider selection in bot form
- Hide OpenAI-specific features for Local LLM bots
- Add connection testing for Local LLM endpoints
## Technical Details
- Direct import from `agents` module (not `openai_agents`)
- Maintain conversation context across messages
- Support file search with OpenAI vector stores
- Async/sync pattern for Frappe compatibility
## Files Modified
- Backend: ai.py, agents_integration.py, conversation_file_handler.py, response_formatter.py
- Frontend: AISettings.tsx, AIFeaturesBotFormEnhanced.tsx, App.tsx
- DocTypes: Raven Settings, Raven Bot
- Removed: 5 unused files, 2 debug files
* Remove frappe.log_error
* Update requirements.txt
* remove frappe.log_error and fix bug description tools
* fix vector store IDs
* fix: apply pre-commit hooks and fix code quality issues
- Fixed flake8 errors:
- Removed unnecessary f-string prefixes (F541)
- Replaced bare except with specific exceptions (E722)
- Applied black formatting to Python files
- Fixed import ordering with isort
- Modernized Python syntax with pyupgrade
- Removed trailing whitespace from shell scripts
All pre-commit hooks now pass successfully.
* fix: add translation wrapper for user-facing error messages
- Wrapped all frappe.throw() messages with _() for internationalization
- Fixes frappe-semgrep-rules.rules.frappe-missing-translate-function-python violations
- All user-facing text is now translatable as per Frappe standards
* fix: add missing dependencies to pyproject.toml
- Added openai-agents>=0.0.16
- Added markitdown
- Added pandas
These dependencies are required for the AI features and were missing from pyproject.toml,
causing import errors during Frappe app installation.
* feat: add migration patch for AI bots model provider
- Sets model_provider to 'OpenAI' for all existing AI bots
- Enables enable_openai_services if AI integration is already enabled
- Handles cases where fields might not exist (backward compatibility)
- Only updates bots where model_provider is not already set
- Provides detailed migration logs
This ensures smooth upgrade for existing Raven installations using AI features.
* fix: use set_single_value for Raven Settings in migration patch
- Changed frappe.db.set_value to frappe.db.set_single_value for Raven Settings
- Fixes frappe-semgrep-rules.rules.frappe-set-value-semantics violation
- Single DocTypes require set_single_value method
* fix: add nosemgrep comment for manual commit
- Added explanation for why manual commit is required in AI processing
- The commit is necessary because AI response is processed asynchronously
- Background job needs the message to exist in DB before processing
- Fixes frappe-semgrep-rules.rules.frappe-manual-commit violation
* chore: simplify patch
* chore: remove unused file
* fix: only navigate to thread if on the same channel
* fix: remove unneccessary props
* fix: label in command menu
* chore: delete unused code
* chore: merge bot form enhanced
* fix: colors on sliders
* chore: remove unneccesary checks
* chore: remove unused imports
* fix: check for openai assistant ID for routing
* feat: add support for INR
* chore: remove unused imports
* chore: linting
* fix: apply document permissions when fetching docs using agents
---------
Co-authored-by: Nikhil Kothari <nik.kothari22@live.com>