Commit graph

3058 commits

Author SHA1 Message Date
Max
a7210f027f Refactor trace package tests for improved readability
- Removed unnecessary blank lines in multiple test files to enhance code clarity and maintainability.
- Adjusted formatting in `subscription.go`, `trace_bench_test.go`, `trace_concurrent_test.go`, `trace_mem_test.go`, `trace_node_test.go`, `trace_space_test.go`, and `trace_subscription_test.go` for consistency.
2025-11-18 15:48:21 +08:00
Max
3a46d98663 Enhance trace package functionality and improve concurrency handling
- Updated benchmark and memory leak detection commands in the Makefile to include both agent and trace components.
- Refactored the manager struct in `manager.go` to support cancellable contexts and added per-space locks for improved concurrency safety.
- Enhanced subscription handling in `subscription.go` to only broadcast updates if there are active subscribers, preventing unnecessary operations.
- Implemented comprehensive disk operations in `local/driver.go` and `store/driver.go` for managing trace nodes, spaces, and logs, including loading, saving, and deleting functionalities.
- Improved README documentation to clarify driver configurations and usage examples for trace management.
2025-11-18 15:47:44 +08:00
Max
b582f0c685 Refactor trace package structure and improve trace ID validation
- Updated trace ID validation in `TestEnterStack_RootCreation` to ensure it is at least 8 digits long.
- Changed import path for the trace package in `stack.go` for consistency.
- Removed the entire `manager.go`, `node.go`, `space.go`, `subscription.go`, `trace.go`, `local/driver.go`, `store/driver.go`, and related types and events files to streamline the trace package, focusing on essential functionality.
2025-11-18 14:09:28 +08:00
Max
c02fbcb63e Remove unnecessary blank line in driver.go for improved code readability 2025-11-18 11:50:26 +08:00
Max
652035311d Implement trace management system with local and store drivers
- Introduced a global trace registry to manage active traces with thread-safe access.
- Added support for two storage drivers: Local (file-based) and Store (Gou store).
- Enhanced trace ID generation to include a date prefix and improved uniqueness.
- Implemented functions for creating, loading, and releasing traces, along with checking their existence in both the registry and persistent storage.
- Added functionality to retrieve trace metadata and list active traces, improving trace management capabilities.
2025-11-18 11:50:05 +08:00
Max
a824670def Enhance streaming message handling in DefaultStreamHandler
- Added a new field to track the current message type (text, thinking, tool_call) in the streamState struct.
- Updated message handling methods to set the current message type appropriately.
- Modified the group end handling to use the tracked message type when sending messages, ensuring accurate type representation.
- Enhanced unit tests to verify the correct handling of group end events and their associated types.
2025-11-17 15:17:48 +08:00
Max
796f6437ef Update ModelCapabilities to support flexible vision input handling
- Changed the Vision field in ModelCapabilities from bool to interface{} to accommodate both boolean values and VisionFormat strings.
- Modified the getConnectorCapabilities function to directly assign the Vision capability based on the updated model configuration, enhancing compatibility with various vision input formats.
2025-11-17 10:59:46 +08:00
Max
a8d73f8f7b Add Claude API configuration and enhance vision support in LLM adapters
- Integrated Claude API keys into GitHub workflows for both unit and PR tests.
- Introduced a new VisionFormat type and constants to manage image input formats.
- Updated ModelCapabilities to support vision input, allowing for flexible handling of image formats.
- Enhanced VisionAdapter to preprocess messages and convert image URLs to base64 format for Claude compatibility.
- Improved OpenAI provider to utilize vision support in message preprocessing, ensuring better integration with vision capabilities.
2025-11-17 10:53:08 +08:00
Max
2bdf69a778 Remove unnecessary blank line in temperature_test.go for improved code readability 2025-11-17 09:48:09 +08:00
Max
033d94d96f Refactor connector settings to model capabilities
- Renamed and refactored functions and variables to transition from connector settings to model capabilities, enhancing clarity and consistency.
- Updated the loading mechanism to read model capabilities from `models.yml` instead of `connectors.yml`.
- Adjusted the assistant's global settings to utilize model capabilities, ensuring proper integration with the new configuration structure.
- Enhanced the reasoning adapter to support temperature adjustment based on model capabilities, improving flexibility in handling reasoning parameters.
2025-11-17 09:45:54 +08:00
Max
494c8dc98e Add DeepSeek API configuration and enhance reasoning support in LLM adapters
- Added DeepSeek API keys and model configurations to the GitHub workflows for both unit and PR tests.
- Introduced a new `ReasoningEffort` parameter in the `CompletionOptions` struct to manage reasoning levels for models like o1 and GPT-5.
- Updated the `ReasoningAdapter` to handle the new `ReasoningEffort` parameter, ensuring it is stripped if not supported by the model.
- Enhanced the OpenAI provider to preprocess options through adapters, improving the handling of reasoning content and ensuring compatibility with DeepSeek R1 reasoning format.
2025-11-17 08:07:20 +08:00
Max
3d149057fd Refactor LLM provider architecture to utilize capability adapters
- Removed legacy and audio providers, consolidating functionality into a new architecture that separates API format handling from capability management.
- Updated the OpenAI provider to support capability adapters for tool calls, vision, audio, and reasoning, enhancing modularity and extensibility.
- Introduced a new method for detecting API formats and streamlined the provider selection process.
- Enhanced documentation to reflect the new architecture and clarify provider capabilities and usage.
2025-11-17 06:44:20 +08:00
Max
fa95f32db7 Enhance message handling in OpenAI adapter to skip non-delta "done" messages
- Added logic to ignore "done" messages that are not delta updates, ensuring that final confirmation messages are not sent to OpenAI clients, which rely on finish_reason instead.
2025-11-17 06:22:18 +08:00
Max
b43929210e Implement event message handling and enhance output capabilities
- Added support for lifecycle event messages, including a new event type for tracking stream states (e.g., stream_start, stream_end).
- Introduced a NewEventMessage function to create event messages with structured properties.
- Updated the output package to include event messages in the built-in types, ensuring compatibility with CUI clients while remaining silent for OpenAI clients.
- Enhanced the DefaultStreamHandler to utilize event messages for better lifecycle tracking during streaming operations.
- Improved error handling and logging in the OpenAI provider to capture and report streaming errors effectively.
2025-11-16 10:30:55 +08:00
Max
7ddea66106 Remove unnecessary blank lines in multiple files for improved code readability 2025-11-15 17:56:47 +08:00
Max
91aa109f5b Add streaming support and message handling in DefaultStreamHandler
- Implemented a state management system for handling different streaming chunk types, including stream start, group start, text, thinking, tool calls, metadata, errors, and stream end.
- Introduced a new Send method in the context to facilitate message sending to the client.
- Enhanced the output package with message sending capabilities, including support for message groups and flushing.
- Improved error handling and message ID generation for better streaming reliability and user feedback.
2025-11-15 17:40:03 +08:00
Max
8636b0c842 Enhance context cancellation support in OpenAI provider and tests
- Added context cancellation handling in the OpenAI provider's Stream and Post methods, allowing for graceful termination of operations when the context is cancelled.
- Implemented a new test, TestOpenAIStreamContextCancellation, to validate that streaming respects context cancellation, ensuring proper error handling and event emission during cancellation scenarios.
- Refactored context usage in existing methods to improve consistency and reliability in handling context across streaming operations.
2025-11-15 15:43:57 +08:00
Max
da53917d51 Fix formatting issues in OpenAI stream lifecycle event tests
- Removed unnecessary blank lines in the TestOpenAIStreamLifecycleEvents function to improve code readability.
- Adjusted log formatting for group_end event to ensure consistent output during test execution.
2025-11-15 15:36:31 +08:00
Max
bdbaf011b2 Implement stream lifecycle events in OpenAI provider
- Added support for stream lifecycle events including stream_start, stream_end, group_start, and group_end.
- Introduced new data structures for handling lifecycle event data, enhancing communication of stream boundaries and metadata.
- Updated the OpenAI provider to track and emit these events during streaming operations, improving UI/UX capabilities.
- Added tests to validate the correct emission and order of lifecycle events during streaming.
2025-11-15 15:32:49 +08:00
Max
d705fcc484 Add tests for JSON response formatting and schema validation in OpenAI provider
- Introduced TestOpenAIJSONMode and TestOpenAIJSONModePost to validate JSON response formatting for streaming and non-streaming requests.
- Added TestOpenAIJSONSchema and TestOpenAIJSONSchemaPost to ensure compliance with strict JSON schema validation.
- Enhanced request body construction in the OpenAI provider to support JSON schema details in response formats.
2025-11-15 11:31:17 +08:00
Max
68ed9ece6d Remove unnecessary blank line in accumulatedToolCall struct definition in OpenAI provider types.go 2025-11-15 11:13:26 +08:00
Max
353ad56ddd Implement message preprocessing and enhance OpenAI provider functionality
- Added message preprocessing in the base provider to filter unsupported content types (vision and audio) based on model capabilities.
- Introduced new methods in the OpenAI provider for handling streaming and non-streaming requests with retry logic and tool call validation.
- Enhanced request body building to support various options and improved error handling for API interactions.
- Implemented validation for tool call arguments against JSON schemas, ensuring compliance with expected formats.
2025-11-15 11:12:30 +08:00
Max
cef75ff71b Refactor defaultConnector variable formatting for improved readability 2025-11-15 10:12:00 +08:00
Max
f2099babd9 Update Go module dependencies and enhance assistant context management
- Upgraded Go version to 1.25 and updated several dependencies, including `testify` to v1.11.1 and added new indirect dependencies for JSON schema validation.
- Refactored the assistant's context management to utilize a new `context.Uses` structure, improving the handling of vision, audio, search, and fetch configurations.
- Enhanced the assistant's request building process to support new response formats, including JSON schema validation, ensuring better integration with various tools and services.
2025-11-15 10:05:57 +08:00
Max
124bd38f7a Implement global uses configuration and enhance assistant capabilities
- Added global uses configuration to the assistant, allowing for centralized management of vision, audio, search, and fetch settings.
- Updated the Assistant struct and related methods to support the new Uses configuration, improving flexibility in assistant operations.
- Refactored the Stream method to utilize the new CompletionResponse type, enhancing response handling.
- Introduced new methods for building requests and managing capabilities, streamlining the assistant's interaction with various connectors.
2025-11-14 19:17:21 +08:00
Max
889fba942a Enhance testing and context management in assistant operations
- Refactored the Makefile to include new benchmark and memory leak detection tests, improving test coverage.
- Introduced context adjustments in the Create method, allowing hooks to modify context fields such as AssistantID, Connector, Locale, Theme, Route, and Metadata.
- Added a new test scenario to validate context field adjustments, ensuring proper updates during assistant operations.
- Updated test preparation to support optional V8 mode configuration for improved performance during benchmarks.
2025-11-14 12:38:03 +08:00
Max
31adde43b0 Add test for context field validation in JavaScript integration
- Introduced a new test scenario to verify context fields in the assistant's JavaScript execution.
- Enhanced validation checks for response messages, ensuring proper handling of success and failure indicators.
- Improved logging for detailed validation results, aiding in debugging and verification of context handling.
2025-11-14 08:51:51 +08:00
Max
aa69b693e3 Enhance context handling and metadata management in assistant operations
- Introduced a new test context creation function to streamline test setup for assistant operations.
- Refactored context structure to replace the deprecated 'Data' field with 'Metadata', improving clarity and consistency.
- Updated various methods to utilize the new 'Metadata' field, ensuring proper handling of request metadata across the system.
- Adjusted tests to reflect changes in metadata handling, enhancing validation of context fields in JavaScript integration.
2025-11-14 08:41:40 +08:00
Max
e0f69368fb Refactor assistant creation handling and response types
- Updated the Create method in the Script type to return a structured HookCreateResponse instead of the previous ResponseHookCreate.
- Enhanced the getHookCreateResponse method to handle various response scenarios, including nil and undefined results.
- Refactored context types to introduce the new HookCreateResponse structure, which includes fields for messages, audio configuration, generation parameters, and metadata.
- Adjusted related methods in the Assistant to ensure compatibility with the new response structure.
2025-11-13 18:27:15 +08:00
Max
baf90d374c Add test for assistant creation and script execution
- Implemented TestCreate to validate the creation of the 'tests.create' assistant.
- Added context handling for the assistant, ensuring proper execution of the script with a sample user message.
- Enhanced error handling to check for the presence of the script in the assistant.
2025-11-13 15:23:30 +08:00
Max
73f6fae626 Refactor object registration in Context for improved lifecycle management
- Updated the objectRegister method to generate a new ID internally, simplifying the API by removing the need for an external ID parameter.
- Adjusted the NewObject method to utilize the new object registration mechanism, ensuring proper ID assignment and resource cleanup during instance creation.
2025-11-13 14:57:52 +08:00
Max
b13c40e88d Add concurrent testing and object registration for JsValue function
- Implemented TestJsValueConcurrent to validate the JsValue function under concurrent requests, ensuring proper handling of multiple goroutines.
- Added TestJsValueRegistrationAndCleanup to verify the registration and cleanup of context objects, enhancing resource management.
- Introduced object registration and release mechanisms in the Context type to manage JavaScript object lifecycles effectively.
- Utilized sync.Mutex for thread-safe access to shared resources, improving the robustness of concurrent operations.
2025-11-13 14:43:40 +08:00
Max
240cddbcaf Implement Execute method call in Create function for improved assistant creation handling 2025-11-13 12:20:27 +08:00
Max
71698b1405 Add Execute method to Script type for enhanced script execution 2025-11-13 11:42:36 +08:00
Max
9c97035cc6 Refactor Assistant methods and context handling for improved functionality
- Updated the Stream method to return a structured response, including create, done, and completion hooks.
- Introduced new methods for managing message history and building LLM requests, enhancing modularity.
- Refactored the Script type to utilize a new hook structure, improving code organization.
- Removed the obsolete hooks file to streamline the codebase.
- Enhanced context types with additional fields for better integration with LLM models.
2025-11-13 09:26:45 +08:00
Max
27d4cd9555 Refactor context and assistant methods for improved stack management and resource cleanup
- Updated Stream and Run methods in the Assistant to use pointer receivers for context, enhancing performance and clarity.
- Introduced stack management in context handling, including initialization and cleanup of stack references.
- Enhanced the Release method in Context to ensure proper cleanup of resources, including stacks and writer references.
- Added new stack status constants and validation to improve traceability and error handling in agent operations.
- Removed the obsolete JavaScript API file to streamline the codebase.
2025-11-12 11:24:25 +08:00
Max
67ec5516e4 Refactor assistant and context types for clarity and compatibility
- Removed commented-out methods from the API interface in assistant types to enhance code cleanliness.
- Introduced a new Response type in context types, ensuring compatibility with the OpenAI API.
2025-11-11 17:46:45 +08:00
Max
44d2ba4210 Refactor logging in model tests for consistency
- Updated log formatting in TestListModels, TestGetModelDetails, and TestModelIDFormat to ensure consistent output structure.
- Removed unnecessary blank lines to enhance code readability and maintainability in the test suite.
2025-11-11 16:42:01 +08:00
Max
8b690d37bc Refactor completion request handling in context tests
- Renamed and restructured the TestNewOpenAPI function to TestGetCompletionRequest for clarity.
- Updated test cases to validate completion requests using a structured request body instead of query parameters.
- Enhanced error handling and assertions to ensure comprehensive coverage of various scenarios, including metadata handling and expected outputs.
- Removed the obsolete openapi_chat_test.go file to streamline the test suite.
2025-11-11 16:23:22 +08:00
Max
d0f1f598c9 Refactor GinCreateCompletions function to remove commented-out code
- Cleaned up the GinCreateCompletions function by commenting out extensive debug print statements and session ID handling logic.
- Improved code readability and maintainability by streamlining the function's structure while preserving its core functionality.
2025-11-11 11:28:59 +08:00
Max
8dca4719c0 Remove deprecated agent API files and refactor agent loading logic
- Deleted obsolete agent API files (agent.go, api.go, api_test.go, types.go) to streamline the codebase.
- Refactored the agent loading logic to initialize the API instance correctly, ensuring proper integration with the new structure.
- Updated context handling to improve clarity and maintainability across the agent's functionality.
- Enhanced error handling and cache management in the agent's initialization process.
2025-11-11 11:23:20 +08:00
Max
1c502bfea8 Refactor context handling in agent API and assistant methods
- Updated context creation in handleChat, handleGenerateTitle, and handleGeneratePrompts to use the request context, improving context management.
- Commented out unused context settings for assistant ID, silent mode, history visibility, and client type to streamline the code.
- Refactored context handling in assistant methods to enhance clarity and maintainability.
- Removed deprecated functions and cleaned up the context structure for better performance and readability.
2025-11-10 17:30:53 +08:00
Max
af383dd941 Enhance GetAssistants filtering to include locales
- Updated the GetAssistants method to allow filtering by locales in addition to keywords in name and description.
- Improved query flexibility for retrieving assistants based on multiple criteria, enhancing user search capabilities.
2025-11-08 16:48:08 +08:00
Max
ff41c6555d Refactor CreateAssistant and UpdateAssistant response handling to return only assistant_id
- Updated the CreateAssistant and UpdateAssistant functions to simplify the success response by returning only the assistant_id instead of the full assistant data.
- Removed unnecessary JSON marshaling and unmarshaling, improving performance and clarity in response handling.
2025-11-08 16:26:46 +08:00
Max
2099921cf4 Refactor test cases for assistant updates to improve consistency
- Standardized formatting in TestUpdateAssistant and assistant_update_test.go to enhance readability.
- Ensured comments clearly indicate which fields are ignored during updates, maintaining clarity in test intentions.
2025-11-08 16:22:29 +08:00
Max
fa5b98f5bf Add UpdateAssistant method for modifying assistant fields
- Implemented UpdateAssistant method in Mongo, Redis, and Xun stores to allow partial updates of assistant fields.
- Updated Store interface to include the new UpdateAssistant method, enhancing the flexibility of assistant management.
- Added comprehensive tests for UpdateAssistant functionality, covering various scenarios including single and multiple field updates, JSON field handling, and error cases.
- Updated API routes to support PUT requests for updating assistants, ensuring proper permission checks and response handling.
2025-11-08 16:21:35 +08:00
Max
90386ddb70 Refactor response handling in GetAssistant and ListAssistantTags functions
- Simplified the response structure by directly returning the assistant and tags objects instead of wrapping them in a "data" field.
- Updated corresponding tests to reflect the new response format, ensuring accurate assertions and improved readability.
2025-11-08 15:17:56 +08:00
Max
5ce5baa748 Enhance getBool function to support multiple data types
- Refactored the getBool function to handle boolean values as well as int64, int, and float64 types, returning true for non-zero values.
- Improved type safety and flexibility in data handling within the utility functions.
2025-11-08 14:58:14 +08:00
Max
0f17db74ca Implement GetAssistant endpoint with permission verification
- Added a new GetAssistant function to retrieve assistant details by ID, incorporating permission checks to ensure authorized access.
- Updated the assistant route to use the new GetAssistant handler, enhancing security by verifying user permissions before returning assistant data.
- Introduced a FilterBuiltInAssistant function to clear sensitive fields for built-in assistants, ensuring compliance with data protection standards.
- Enhanced test coverage for the GetAssistant functionality, including tests for successful retrieval, permission filtering, and error handling scenarios.
2025-11-08 13:46:29 +08:00
Max
42b5e17d78 Fix formatting in TestListAssistantTags to improve readability
- Removed unnecessary blank lines in the test function, enhancing code clarity and maintainability.
2025-11-08 11:44:19 +08:00