bemade-addons/helpdesk_sale_order_ai/models
mathis 7815fb55a6 Refactor AI-driven sales order creation logic in helpdesk_ticket.py
- 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
2025-07-31 13:57:58 -04:00
..
__init__.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
ai_openwebui_client.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
ai_openwebui_prompt_template.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
helpdesk_team.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
helpdesk_ticket.py Refactor AI-driven sales order creation logic in helpdesk_ticket.py 2025-07-31 13:57:58 -04:00
helpdesk_ticket.py.bak [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
res_config_settings.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00
sale_order.py [REF] Replace openwebui_connector with centralized openwebui_base module 2025-07-28 13:27:29 -04:00