Commit graph

58 commits

Author SHA1 Message Date
Max
2f13dbbffb Enhance attachment model and add local uploader support
- Introduced a new `Groups` field in the `Attachment` struct to support categorization of attachments.
- Integrated `types.MetaInfo` into `ManagerOption` for improved metadata handling.
- Added a local uploader for attachments, enabling file uploads from a specified local path.
- Updated asset management functions to reflect changes in file metadata and structure.
2025-07-25 18:15:51 +08:00
Max
96d2f22e77 Update dependencies in go.mod and go.sum; refactor file handling in neo package
- Added the jsonrepair package to go.mod for enhanced JSON handling capabilities.
- Removed unused dependencies from go.mod and updated existing ones for better performance.
- Refactored file upload and download methods in the neo package to return nil values, indicating a temporary placeholder for future implementation.
- Updated the Message struct to use the new attachment package for better organization of file attachments.
2025-05-31 10:07:19 +08:00
Max
15f3f0adf8 fix: Add support for attachments in message mapping
- Implemented functionality to handle attachments in the Map method of the Message struct.
- Added JSON parsing for attachments, ensuring proper error handling and feedback during the process.
2025-05-12 14:38:37 +08:00
Max
c44c332334 feat: Update asset metadata and enhance Assistant API functionality
- Updated modification times for various asset files in bindata.go to reflect recent changes.
- Refactored the Assistant API to improve result handling and streamline message processing.
- Removed unused stream handling code in the Assistant, simplifying the execution flow.
- Enhanced the Agent class in libsui/agent.ts to better manage message states and improve error handling.
2025-05-09 10:27:31 +08:00
Max
93be3acb97 refactor: Improve asynchronous message processing in WriteMessageAsync
- Introduce a done channel to track message processing completion.
- Increase timeout for message processing to 5 seconds for better reliability.
- Adjust queue timeout to 1 second to enhance responsiveness when the queue is full.
2025-04-27 12:19:54 +08:00
Max
c76024fda1 refactor: Update message writing logic to use message queue
- Modify the Write method in the Message struct to utilize WriteMessageAsync for improved asynchronous message handling.
- Update ignored message types to include "plan" alongside "loading", "error", "action", and "progress" for better message filtering.
2025-04-26 21:25:38 +08:00
Max
57e8389afd refactor: Update message handling to ignore progress messages
- Modify message handling logic to include "progress" in the list of ignored message types alongside "loading", "error", and "action".
- Comment out the loading message sending logic in the Execute method to streamline the process and improve clarity in message flow.
2025-04-19 15:38:12 +08:00
Max
6203b5ccf2 feat: Enhance message structure with ToolID for improved context
- Add ToolID field to Message struct to associate messages with specific tools.
- Update streamChat method to include ToolID in message handling for better tracking.
- Modify message properties to incorporate ToolID, enhancing clarity in message processing.
2025-04-16 16:52:32 +08:00
Max
f1de4c07f8 refactor: Rename BeginAt and EndAt fields for consistency in message handling
- Change BeginAt and EndAt fields to Begin and End in Message struct for improved clarity.
- Update related methods and parameters across the codebase to reflect the new naming convention.
- Ensure consistency in timestamp handling within the ScanTokens function and message processing methods.
2025-04-16 16:40:45 +08:00
Max
712c8ade62 feat: Refactor token management and enhance message scanning
- Update ScanTokens function to utilize ScanCallbackParams for improved clarity and structure in token processing.
- Modify ClearToken method to accept an ID parameter, enhancing token stack management.
- Refactor GenerateWithAI and streamChat methods to leverage new token handling features, improving message flow and context.
- Introduce BeginAt and EndAt fields in message processing for better timing accuracy.
2025-04-16 16:23:00 +08:00
Max
14f447c782 feat: Enhance message handling with timestamps and token management
- Introduce BeginAt and EndAt fields in Message struct to track message timing.
- Update NewText and NewType methods in Contents to accept Extra struct for better metadata handling.
- Modify ScanTokens function to manage token IDs and beginning timestamps, improving token processing accuracy.
- Refactor GenerateWithAI and streamChat methods to utilize new timestamp features, enhancing message context and flow.
2025-04-16 14:29:50 +08:00
Max
f1e6c2c62f Add result handling in assistant streaming and hook responses
- Introduce Result field in ResHookDone struct to support additional data
- Update NextAction.Execute method to pass optional callback arguments
- Modify streamChat method to propagate result data to output messages
- Add Result field to Message struct for flexible result storage
2025-02-25 17:32:58 +08:00
Max
358f327dee Improve native tool calls handling in assistant streaming
- Refactor tool calls processing to handle multiple tool calls more robustly
- Add new message flags (IsBeginTool, IsEndTool) to track tool call stages
- Modify streaming logic to correctly wrap and manage tool call messages
- Ensure only the first tool call is fully processed and displayed
2025-02-24 19:29:57 +08:00
Max
101927e343 Add thread-safe write method with mutex synchronization
- Introduce sync.Mutex to protect concurrent writes to response writer
- Add locking mechanism in Write method to prevent race conditions
- Ensure safe and synchronized message writing in multi-threaded contexts
2025-02-24 17:24:34 +08:00
Max
9c9f137a8a Improve error handling and logging in assistant methods
- Add nil checks for callbacks in message and object methods
- Enhance error logging in plan subscription with more descriptive messages
- Improve write method error handling with additional context logging
- Add safeguards against potential nil function calls
2025-02-24 10:44:15 +08:00
Max
979acb27a8 Add callback support for assistant chat processing
- Introduce optional callback mechanism for chat messages
- Modify Execute and streamChat methods to support callback functions
- Add support for process and script method callbacks
- Update message handling to trigger callbacks during chat streaming
- Enhance flexibility of assistant chat interactions with dynamic callbacks
2025-02-18 18:13:42 +08:00
Max
13c4e65a95 Add retry and silent modes to assistant chat processing
- Introduce retry and silent mode flags in context and message structures
- Modify API and hooks to support new context modes
- Update message handling to propagate retry and silent flags
- Replace debug print statements with structured logging
- Enhance tool call and message processing with new context options
2025-02-18 11:20:20 +08:00
Max
617893a579 Improve tool call parsing and formatting
- Refine tool call text extraction in HookDone method
- Add URL decoding for JSON-encoded tool call arguments
- Enhance error handling for tool call parsing
- Modify tool call tag handling in streaming chat
2025-02-10 11:13:59 +08:00
Max
5be65d91cd Remove debug print statement in OpenAI message parsing
- Remove unnecessary debug print of arguments and finish reason
- Maintain clean and concise message processing logic
- Align with previous refactoring efforts to simplify code
2025-02-09 10:08:51 +08:00
Max
38ee806cff Refactor OpenAI message parsing for improved streaming support
- Completely restructure NewOpenAI method to handle different message types more robustly
- Add support for new ChatCompletionChunk type to parse streaming responses
- Improve error handling and message type detection
- Simplify message processing logic with more explicit type checking
- Remove commented-out legacy code and improve overall readability
2025-02-09 09:46:41 +08:00
Max
142b07b0ce Enhance tool call handling and message processing
- Add support for native tool call streaming with XML-like tags
- Implement stringHash for message name anonymization
- Add debug environment variable for printing request messages
- Remove unused function and arguments fields in message contents
- Modify message type handling for tool calls in streaming chat
2025-02-08 18:09:26 +08:00
Max
a7a05fbec8 Add Azure OpenAI support and improve message parsing
- Implement Azure OpenAI authentication with `azure` flag in OpenAI struct
- Update HTTP request headers to support Azure API key authentication
- Enhance message parsing to handle additional edge cases in OpenAI responses
- Add debug logging for OpenAI messages when debug environment is set
- Improve error and usage detection in stream message processing
2025-02-08 11:18:06 +08:00
Max
b19c5d63ff Enhance message processing and user identification
- Add user ID to input name when not explicitly set
- Update stream chat to mark final message as "think" type
- Modify history retrieval to add system prompts after fetching chat history
- Remove debug print statement in message data mapping
2025-02-07 10:30:12 +08:00
Max
dabba1a744 Refactor chat history and message processing
- Added `Hidden` flag to `Message` struct for controlling message visibility
- Modified `saveChatHistory` to conditionally save messages based on hidden status
- Simplified stream chat processing by removing debug print statements
- Restructured message output and next action handling in stream chat
- Commented out unused process action execution method
2025-02-06 16:39:31 +08:00
Max
96f4b5e55a Add support for reasoning content and thinking state in OpenAI streaming
- Implemented handling of reasoning_content in OpenAI message parsing
- Added support for tracking thinking state with `<think>` tags
- Updated message generation to handle delta messages and thinking states
- Modified OpenAI API to support flexible base URL configuration
- Enhanced token scanning and message processing for reasoning content
2025-02-05 16:55:09 +08:00
Max
5a38cf77c1 Improve message ID tracking in streaming chat processing
- Updated ScanTokens method to preserve and reuse existing message IDs
- Modified streaming chat to track and pass current message ID during token scanning
- Ensured consistent message ID generation when not explicitly provided
2025-02-04 19:22:45 +08:00
Max
75d55ae13b Add unique ID tracking for message contents and streaming
- Introduced UUID generation for message contents during token scanning
- Updated message and contents methods to support optional ID parameter
- Modified streaming chat processing to include message ID tracking
- Enhanced message parsing and appending with ID preservation
2025-02-04 17:17:24 +08:00
Max
991c884d78 Simplify token scanning and streaming logic in chat processing
- Removed unnecessary breakpoint and token tracking variables
- Streamlined token scanning and message processing in assistant API
- Simplified text handling and token parsing in contents scanning
- Reduced complexity of stream chat message generation
2025-02-03 19:24:52 +08:00
Max
b19a6b953a Enhance streaming chat processing with token parsing and delta message handling
- Implemented token scanning for 'think' and 'tool' types in stream chat
- Added support for delta message streaming with improved message chunking
- Updated contents handling to remove last empty data and track token states
- Refined message type processing and streaming logic in assistant API
- Modified message appending and type handling to support new streaming approach
2025-02-03 15:46:25 +08:00
Max
455e39fa54 Refactor assistant types and tools support
- Renamed `Functions` to `Tools` across multiple files
- Added `ConnectorSetting` to support vision and tools flags
- Updated loading and serialization logic for tools
- Modified message contents handling for better JSON parsing
- Adjusted test cases to reflect tool-related changes
2025-02-01 17:04:45 +08:00
Max
6ac0406ad4 Improve OpenAI message parsing and error handling
- Enhanced error handling in OpenAI message processing
- Added colored console output for JSON parsing errors
- Updated Error struct to support flexible code type
- Improved message type and done state setting for various error scenarios
- Added support for parsing different error message formats
2025-02-01 11:26:11 +08:00
Max
54e946c61d Add support for field selection in assistant filtering
- Implemented `select` parameter parsing in `parseAssistantFilter`
- Added support for selecting fields via string, string array, or interface array
- Enhanced `neo/process.go` to handle flexible field selection
- Improved error handling in stream chat processing
- Fixed function message handling in message appending
2025-01-31 11:02:31 +08:00
Max
24b1d11528 Enhance error handling and message processing in Neo API assistant
- Added support for parsing and handling pending and error messages in stream processing
- Improved error message extraction and writing for better error visibility
- Updated message type handling to capture and process raw error messages
- Introduced more flexible input parsing in withHistory and execute methods
- Added environment variable support for connector configuration in assistant loading

This change improves the robustness of error handling and message processing in the Neo API assistant, providing more comprehensive error reporting and input flexibility.
2025-01-30 16:11:29 +08:00
Max
f14120c446 Add assistant match functionality with RAG and store support
- Implemented `processAssistantMatch` method to handle assistant matching requests
- Added support for limit parameter with default and maximum values
- Introduced `forceStore` flag to control matching method (RAG or store)
- Created placeholder methods `assistantMatchRAG` and `assistantMatchStore`
- Enhanced OpenAI message handling to parse error responses
- Updated message type handling to include error messages

This change adds flexible assistant matching capabilities with initial infrastructure for RAG and store-based matching.
2025-01-27 11:54:39 +08:00
Max
b679771232 Update message handling to ignore 'action' messages in Neo API assistant
- Modified the message handling logic to include 'action' messages in the ignore list alongside 'loading' and 'error' messages, improving the clarity of message processing.
- This change enhances the robustness of the Neo API assistant by ensuring that irrelevant message types are not processed, streamlining the overall message handling workflow.
2025-01-23 18:15:26 +08:00
Max
1404c549a7 Refactor Neo API assistant message handling and content processing
- Enhanced message generation by introducing NewHistory and NewContent methods for improved handling of message content and history.
- Updated the withHistory method to utilize the new NewHistory method, streamlining the addition of historical messages.
- Improved the call method to conditionally save message history based on input parameters, enhancing flexibility in message management.
- Refactored the String method in the Message struct to better represent message types and properties, improving serialization consistency.

These changes enhance the maintainability and robustness of the Neo API assistant, paving the way for improved message handling and content processing.
2025-01-22 16:09:01 +08:00
Max
1eba627e38 Enhance Neo API assistant with improved content handling and hook integration
- Updated the Assistant methods to include a new Contents parameter in HookInit, HookStream, HookDone, and HookFail, improving message context management.
- Refactored handleChatStream to utilize the new Contents structure, enhancing the clarity and efficiency of chat interactions.
- Introduced new methods in the Contents struct for better type management and properties handling, streamlining message processing.
- Updated the Message struct to support new content types and properties, improving the overall message structure and serialization.

These changes enhance the maintainability and robustness of the Neo API assistant, paving the way for improved message handling and assistant functionalities.
2025-01-22 11:38:37 +08:00
Max
e3285923e6 Update Message struct to improve JSON serialization
- Renamed the 'is_new' field to 'new' in the Message struct for better clarity and consistency in JSON output.
- This change enhances the maintainability of the Neo API assistant by streamlining the message structure and improving data representation.
2025-01-21 15:11:09 +08:00
Max
830bbf7a0e Refactor Neo API assistant message handling and data structures
- Updated message appending methods to use AppendTo for improved clarity and consistency.
- Changed output types in HookStream and HookDone methods from string to []message.Data, enhancing data handling capabilities.
- Introduced a new Map method in the Data struct for better representation of message data.
- Streamlined JSON marshaling in the Data struct to ensure accurate data serialization.

These changes enhance the maintainability and robustness of the Neo API assistant, paving the way for improved message handling and data processing.
2025-01-19 15:19:08 +08:00
Max
5d5fa4c270 Refactor Neo API assistant message handling and content structure
- Replaced the Content struct with a new Contents struct to improve message handling and organization.
- Updated methods across the Assistant and Message structs to utilize the new Contents structure, enhancing the clarity and efficiency of message processing.
- Improved error handling by ensuring proper message appending and content management during chat streaming.
- Removed the deprecated Content struct, streamlining the codebase and reducing complexity.

These changes enhance the maintainability and robustness of the Neo API assistant, paving the way for improved message handling and assistant functionalities.
2025-01-19 12:23:23 +08:00
Max
e874e8dfb4 Enhance Neo API assistant with improved error handling and message structure
- Added nil check for script context in the call method to prevent potential nil pointer dereference.
- Updated the String method in the Content struct to include additional properties (text and props) for better message representation.

These changes improve the robustness and maintainability of the Neo API, paving the way for enhanced message handling and assistant functionalities.
2025-01-18 15:01:44 +08:00
Max
228e8cf482 Enhance Neo API assistant message handling and response structure
- Added nil checks for response objects in the Execute method to prevent potential nil pointer dereferences.
- Updated the streamChat method to include assistant identification details (ID, name, avatar) in the message structure, improving context for messages.
- Introduced a new field in the Message struct to mark messages as new, enhancing message tracking capabilities.

These changes improve the robustness and maintainability of the Neo API, paving the way for better message handling and assistant functionalities.
2025-01-18 11:20:55 +08:00
Max
d43b7b8927 Enhance Neo API assistant message storage and structure
- Removed unused utility imports and streamlined the saveChatHistory method to improve message storage efficiency.
- Updated the Message struct to include new fields for assistant identification and mentions, enhancing message context and traceability.
- Modified the history table structure to accommodate new assistant-related fields and mentions, ensuring comprehensive data storage.
- Improved the SaveHistory method to process and store mentions alongside messages, providing better context for user interactions.

These changes enhance the robustness and maintainability of the Neo API, paving the way for improved message handling and assistant functionalities.
2025-01-18 10:19:17 +08:00
Max
17c18e7d56 Refactor Neo API assistant to enhance vision support and message handling
- Updated the Assistant struct to include a vision capability flag and an init hook indicator, allowing for better management of vision-enabled functionalities.
- Refactored message handling throughout the assistant methods to utilize the chatMessage package, improving consistency and type safety.
- Enhanced the handleVision method to support dynamic vision processing options, including improved handling of image descriptions and uploads.
- Streamlined the requestMessages and withAttachments methods to better accommodate vision capabilities, ensuring proper integration with image handling.
- Improved the initialize method to check for vision support based on the model, enhancing the assistant's adaptability.

These changes improve the robustness and maintainability of the Neo API, paving the way for enhanced assistant functionalities and better integration of vision capabilities.
2025-01-17 15:16:26 +08:00
Max
5e5524293f Refactor Neo API assistant message handling and function integration
- Updated streamChat method to utilize content.Type for function handling, enhancing the interaction with function calls.
- Improved the String method in Content struct to handle function arguments more robustly, including JSON unmarshalling for completed content.
- Set default message type to "text" in NewOpenAI function, ensuring consistent message processing.

These changes enhance the flexibility and maintainability of the Neo API, paving the way for improved assistant functionalities and message management.
2025-01-15 16:35:58 +08:00
Max
e7185aad10 Enhance Neo API assistant with function support and improved message handling
- Introduced a new Function type to define assistant functions, enhancing the assistant's capabilities.
- Updated the Assistant struct to include a Functions field, allowing for dynamic function management.
- Refactored the streamChat method to handle tool calls, improving interaction with functions during chat streaming.
- Enhanced message handling in the NewOpenAI function to support tool call responses, ensuring proper message parsing.
- Implemented loading and saving of functions from a JSON file, streamlining function management within the assistant.

These changes improve the robustness and maintainability of the Neo API, paving the way for more flexible and powerful assistant functionalities.
2025-01-15 11:20:55 +08:00
Max
ffb9ede647 Refactor Neo API message handling and enhance assistant interaction
- Updated the Answer method to utilize the new withHistory function, improving message retrieval and context management.
- Refactored the chat method to accept a slice of message.Message instead of a map, enhancing type safety and clarity.
- Introduced a new withHistory function to streamline the process of retrieving chat history and user messages, improving maintainability.
- Enhanced the HookInit method to accept a gin.Context, allowing for better context handling during assistant initialization.
- Updated the assistant API interface to reflect changes in message handling, ensuring consistency across the codebase.

These changes improve the robustness and maintainability of the Neo API, paving the way for future enhancements in assistant functionalities and message management.
2025-01-13 14:47:17 +08:00
Max
238347c834 Refactor message handling and enhance file reading capabilities in Neo API
- Updated the message handling logic to improve error reporting and content management, ensuring more robust communication with clients.
- Introduced a new ReadBase64 method in both Local and OpenAI assistant implementations to read files and return their base64 encoded content, enhancing file handling capabilities.
- Removed the deprecated JSON message handling code, streamlining the message processing structure.
- Refactored message struct to include new fields and methods for better data management and response handling.
- Improved the chat functionality to handle attachments and user messages more effectively, ensuring a smoother user experience.
2024-12-31 16:01:48 +08:00
Max
c98a402e54 Refactor Neo API chat handling to improve AI interaction and error management. Introduce background processing for chat with AI, enhancing responsiveness and client handling. Update assistant initialization logic to streamline the creation of OpenAI assistants and ensure proper error handling. Modify message struct to support structured error responses, improving clarity in communication. Additionally, clean up unused code and enhance overall maintainability of the assistant management system. 2024-12-14 17:45:40 +08:00
Max
79ee5b75f9 Refactor error handling in Neo API to streamline message creation. Replace map-based error responses with a more concise error method in the message struct, enhancing readability and maintainability. Update related functions to ensure consistent error messaging across chat handling and response writing. 2024-12-13 19:49:54 +08:00