Commit graph

6 commits

Author SHA1 Message Date
mathis
014293c548 “Fix date handling and improve AI table parsing
This commit addresses two important issues in the helpdesk_sale_order_ai module:

1. Fixed date handling in sale order creation:
- Resolved timezone-related issue where dates were incorrectly shifted by one day
- Modified datetime conversion to use noon (12:00:00) instead of midnight (00:00:00)
- This provides a 12-hour buffer on either side to prevent timezone conversions from
changing the date when displayed in the UI
- Ensures extracted dates like "07/02/2025" correctly appear as "2025-07-02" in sale orders
- Prevents the previous issue where dates were being displayed as the previous day

2. Enhanced AI prompt for better table parsing:
- Enhanced product extraction from tabular data with better pattern recognition
- Improved parsing of product quantities and codes from structured table formats”
2025-08-01 14:16:16 -04:00
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
mathis
794e800d7c Fix source information message in sale order chatter and attach original files 2025-07-29 10:31:23 -04:00
mathis
c5904a51d7 [REF] Replace openwebui_connector with centralized openwebui_base module
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
2025-07-28 13:27:29 -04:00
mathis
ed9dda9bea [ADD] openwebui_connector, helpdesk_sale_order_ai: AI-powered sales order generation from helpdesk tickets
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.
2025-07-15 15:18:01 -04:00
xtremxpert
aa16543a86 port of durpro_helpdek_sale to helpdesk sale order + base for AI 2025-07-09 08:23:03 -04:00