Commit graph

2114 commits

Author SHA1 Message Date
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
a278c4c63a Update OpenAI test and API configuration
- Replace deprecated model "text-davinci-003" with "gpt-3_5-turbo-instruct"
- Comment out deprecated Edits method in tests and implementation
- Enhance HTTP request headers with explicit Content-Type
- Add fallback for model configuration when not explicitly set
- Improve header handling for Azure and standard OpenAI authentication
2025-02-08 15:59:46 +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
d69370551a Refactor streaming chat and message processing
- Updated NextAction execution to send loading message and create new contents
- Disabled stream hook temporarily to simplify message handling
- Modified HookDone to filter and parse tool call messages
- Removed debug print statements and simplified message generation
- Improved message content processing during stream chat
2025-02-06 14:21:29 +08:00
Max
9c0ab4e0e1 Configure base URL for OpenAI API initialization
- Added default base URL "/v1" in NewMoapi method
- Supports flexible base URL configuration for OpenAI API client
- Complements previous work on API configuration and streaming improvements
2025-02-06 09:19:10 +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
941593b6ef Refine tool call system prompt formatting and connector settings handling
- Improved tool call system prompt with more precise formatting guidelines
- Simplified connector settings check logic in tool call processing
- Enhanced readability and specificity of tool call response rules
- Maintained existing functionality while clarifying prompt instructions
2025-02-02 16:03:43 +08:00
Max
a12259429c Add tool call system prompts for connectors without native tool support
- Implemented system prompts for tool calls when connector settings disable native tool handling
- Added JSON-formatted tool list and explicit rules for tool call processing
- Included guidelines for tool call response formatting and function usage
- Preserved existing tool prompts functionality
2025-02-01 19:05:49 +08:00
Max
741a650517 Add connector settings support in DSL and assistant initialization
- Updated `DSL` struct to include `Connectors` with `assistant.ConnectorSetting` type
- Modified `initAssistant()` to set connector settings via `SetConnectorSettings()`
- Adjusted `load.go` and `types.go` to support new connector settings configuration
- Implemented connector-specific tool and vision handling in assistant methods
2025-02-01 17:45:01 +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
eb814dab05
Merge pull request #842 from trheyi/main
Update Go module dependencies and clean up go.mod and go.sum
2025-01-30 16:26:14 +08:00
Max
88250e5f77 Update Go module dependencies and clean up go.mod and go.sum
- Added github.com/spf13/cast as an explicit dependency
- Removed redundant indirect comment for spf13/cast
- Added github.com/frankban/quicktest to go.sum
- Updated kr/text dependency references
2025-01-30 16:25:50 +08:00
Max
b50a2d4268
Merge pull request #841 from trheyi/main
Enhance error handling and message processing in Neo API assistant
2025-01-30 16:13:10 +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
86b88387a0
Merge pull request #840 from trheyi/main
Improve message filtering in Neo API assistant stream processing
2025-01-29 16:45:36 +08:00
Max
bc662d95fa Improve message filtering in Neo API assistant stream processing
- Added filtering for 'function' type messages in requestMessages method
- Removed debug print statement in streamChat method
- Enhanced message handling to ignore function call messages during processing

This change refines the message filtering logic in the Neo API assistant, improving the clarity and efficiency of message stream processing.
2025-01-29 16:14:43 +08:00
Max
4911aa5a5f
Merge pull request #839 from trheyi/main
Enhance Neo API assistant with improved message handling and hook sup…
2025-01-29 16:14:37 +08:00
Max
63807e1944 Enhance Neo API assistant with improved message handling and hook support
- Updated HookCreate to support extended timeout and input message parsing
- Modified CreateResponse to include optional input messages
- Refactored assistant hooks to improve context and message handling
- Added support for more flexible streaming and done hook processing
- Adjusted timeout contexts and method signatures for better error management

This change improves the Neo API assistant's flexibility and robustness in handling complex message interactions and hook scenarios.
2025-01-29 16:05:36 +08:00
Max
364d2fbde3
Merge pull request #838 from trheyi/main
Add support for filtering assistants by multiple IDs and enhance test…
2025-01-29 10:58:07 +08:00
Max
4164f082e9 Add support for filtering assistants by multiple IDs and enhance test coverage
- Added `AssistantIDs` field to `AssistantFilter` to support filtering by multiple assistant IDs
- Updated `GetAssistants` and `DeleteAssistants` methods to handle multiple assistant ID filtering
- Expanded test cases to verify multi-ID filtering, selection, and deletion functionality
- Simplified and improved test data generation and cleanup processes

This change provides more flexible assistant retrieval and management capabilities in the Neo API.
2025-01-29 10:57:29 +08:00
Max
73d6f6994e
Merge pull request #837 from trheyi/main
Add assistant match functionality with RAG and store support
2025-01-27 11:55:21 +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
68d0f264fd
Merge pull request #836 from YaoApp/revert-835-revert-834-main
Revert "Revert "Add RAG and Version support to Assistant context and …
2025-01-26 17:06:12 +08:00
Max
069105d7bd
Revert "Revert "Add RAG and Version support to Assistant context and options"" 2025-01-26 17:05:10 +08:00
Max
bec72b2f51
Merge pull request #835 from YaoApp/revert-834-main
Revert "Add RAG and Version support to Assistant context and options"
2025-01-26 17:03:41 +08:00
Max
b9c89127b6
Revert "Add RAG and Version support to Assistant context and options" 2025-01-26 17:03:06 +08:00
Max
5033b7599e
Merge pull request #834 from trheyi/main
Add RAG and Version support to Assistant context and options
2025-01-26 17:02:23 +08:00
Max
3c38e968f8 Add RAG and Version support to Assistant context and options
- Introduced Version and RAG flags in the Context struct to support advanced assistant features
- Updated Execute method to set RAG and Version context properties
- Enhanced withOptions method to conditionally add custom options and tools
- Modified HookInit to pass options parameter, improving hook flexibility

This change improves the Assistant's configurability and supports more dynamic assistant interactions.
2025-01-26 17:01:03 +08:00
Max
826c728a02
Merge pull request #833 from trheyi/main
Refactor Neo initialization methods to use global Neo instance
2025-01-26 16:43:04 +08:00
Max
86d4ea71cc Refactor Neo initialization methods to use global Neo instance
- Converted initialization methods from receiver methods to package-level functions
- Simplified method calls by directly using the global Neo instance
- Removed redundant method receiver references in initialization logic
- Improved code readability and reduced unnecessary method complexity

This change streamlines the Neo initialization process and makes the code more straightforward and maintainable.
2025-01-26 16:42:31 +08:00
Max
2f230b007a
Merge pull request #832 from trheyi/main
Enhance tag parsing flexibility in Assistant loading
2025-01-26 15:55:35 +08:00
Max
d8b070338f Enhance tag parsing flexibility in Assistant loading
- Improved tag handling in loadMap to support multiple input types
- Added support for parsing tags from []interface{}, string, and other JSON-compatible formats
- Utilized jsoniter for robust type conversion and marshaling
- Increased robustness of tag loading process for diverse input scenarios

This change enhances the flexibility of tag parsing during Assistant initialization, allowing more versatile data input methods.
2025-01-26 15:55:10 +08:00
Max
445f4eb9ee
Merge pull request #831 from trheyi/main
Add latest chat retrieval endpoint to Neo API
2025-01-25 15:43:13 +08:00
Max
2a5ccb0e2d Add latest chat retrieval endpoint to Neo API
- Implemented a new `/chats/latest` endpoint to fetch the most recent chat or generate a placeholder
- Added `handleChatLatest` method in the DSL to support retrieving the latest chat for a given session
- Introduced `GetPlaceholder()` method in the Assistant interface to support placeholder generation
- Enhanced API flexibility by allowing optional assistant ID specification for placeholder retrieval

This change improves the chat retrieval capabilities of the Neo API, providing a convenient way to access the most recent chat or generate a starting point for new conversations.
2025-01-25 15:42:51 +08:00
Max
ee09cfeb23
Merge pull request #830 from trheyi/main
Add Placeholder support for Assistants in Neo API
2025-01-25 14:04:20 +08:00
Max
f75e5a5fbe Add Placeholder support for Assistants in Neo API
- Introduced a new Placeholder struct to provide additional metadata for assistants
- Updated Assistant struct to include an optional Placeholder field
- Modified loading and mapping methods to handle Placeholder data
- Extended database schema and test cases to support Placeholder functionality

This enhancement provides a flexible way to add descriptive metadata to assistants, improving their discoverability and configuration.
2025-01-25 14:03:45 +08:00
Max
f4c9071f42
Merge pull request #829 from trheyi/main
Update message handling to ignore 'action' messages in Neo API assistant
2025-01-23 18:18:22 +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
eec3a8a285
Merge pull request #828 from trheyi/main
Implement assistant call functionality in Neo API
2025-01-23 16:38:43 +08:00
Max
1f9810c26c Implement assistant call functionality in Neo API
- Added a new endpoint for executing assistant calls via POST request, enhancing the API's capabilities.
- Introduced the handleAssistantCall method to process incoming requests, validate parameters, and execute the assistant's script.
- Updated the Assistant interface to include the Call method, allowing for dynamic method invocation based on the provided payload.
- Enhanced error handling for missing parameters and invalid requests, improving the robustness of the assistant's API interactions.

These changes significantly improve the Neo API assistant's functionality, enabling more interactive and dynamic assistant capabilities.
2025-01-23 16:38:13 +08:00
Max
7137ed4e2c
Merge pull request #827 from trheyi/main
Enhance chat retrieval and update functionality in Xun
2025-01-22 16:53:43 +08:00