- Split monolithic AI prompt into three distinct AI calls:
1. _ai_extract_potential_products: Extract potential products from ticket content and attachments
2. _ai_match_products_to_database: Match extracted products to database products using registered AI tools
3. _ai_format_final_sale_order: Format matched products into final JSON structure
- Added detailed logging at each step for improved debuggability and traceability
- Fixed attribute access for OpenWebUI provider model by using provider.default_model_id.technical_name
instead of provider.model
- Addressed type consistency issues in return statements
- Refactored _get_sale_order_values method to orchestrate these three steps sequentially,
maintaining existing functionality while improving modularity and debuggability
- Modified _ai_extract_potential_products method to use 'product_code' field for product references/codes
instead of putting them in the 'name' field
- Updated _ai_match_products_to_database to properly handle the new field structure
- Fixed KeyError in template formatting by implementing safe template substitution using string.Template
with safe_substitute() method to handle missing placeholders gracefully
- Updated AI integration to use openwebui_base module directly instead of bridge model approach
This commit represents a significant architectural improvement:
- Completely replaced openwebui_connector with a more robust openwebui_base module
- Centralized OpenWebUI API integration for better maintainability
- Redesigned helpdesk_sale_order_ai to use the new openwebui_base module
- Added support for multiple OpenWebUI providers and models
- Improved error handling and response parsing
- Added proper template management with openwebui_prompt_template
- Fixed KeyError issues with safe template substitution
- Streamlined API client initialization and usage
This commit introduces AI integration for helpdesk tickets to automatically generate sales orders:
- openwebui_connector: New module providing integration with OpenWebUI AI service
* Configurable API connection (key, base URL, model)
* AI prompt template system for reusable prompts
* Uses Claude 3 Sonnet model by default
- helpdesk_sale_order_ai: Extends helpdesk_sale_order with AI capabilities
* AI-powered analysis of ticket content to suggest products
* Smart product quantity parsing from various formats
* Dedicated UI tab for AI suggestions in helpdesk tickets
* Auto-creation of sales orders with matched products
The integration streamlines the process of converting customer support requests into sales opportunities.