Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Neo API and Enhance Assistant Capabilities (Dev) #816

Merged
merged 11 commits into from
Jan 13, 2025

Conversation

trheyi
Copy link
Contributor

@trheyi trheyi commented Jan 13, 2025

This PR includes several improvements to the Neo API and assistant functionality:

Key Changes:

  • Refactored assistant initialization and message handling
  • Enhanced context management and RAG/Vision integration
  • Improved environment variable handling and upload functionality
  • Added new hook methods for response handling
  • Streamlined message context processing in streamChat method

The changes focus on improving code maintainability and expanding assistant capabilities while ensuring better integration with RAG and Vision modules.

trheyi added 11 commits January 6, 2025 11:05
- Removed obsolete file upload/download functions and related constants from the Assistant struct, streamlining the codebase.
- Updated the connector type in load tests to use "gpt-3_5-turbo" for improved compatibility with current models.
- Introduced VisionCapableModels to support a range of models with vision capabilities, enhancing AI functionality.
- Enhanced the File struct to include additional fields for description, URL, and document IDs, improving data management for file handling.

These changes improve the overall structure and maintainability of the Neo API, paving the way for future enhancements in assistant capabilities.
…e handling

- Updated the Upload method in the DSL to default to the assistant in context, improving error handling for missing assistant IDs.
- Introduced parseEnvValue and convertOptions functions in the Vision module to support parsing environment variables in configuration options, enhancing flexibility.
- Refactored storage and model initialization in the Vision service to utilize converted options, ensuring environment variables are correctly applied.

These changes improve the robustness and maintainability of the Neo API, paving the way for better configuration management and error handling in assistant functionalities.
… tests

- Refactored the Analyze method in the Vision and OpenAI model to accept a variadic prompt parameter, allowing for optional custom prompts while defaulting to a predefined prompt if none is provided.
- Added multiple test cases in vision_test.go and model_test.go to validate image analysis with default, custom, and empty prompts, ensuring robust functionality and error handling.
- Updated the Model interface to reflect the new prompt handling, improving clarity and usability.

These changes enhance the flexibility of the Vision module, paving the way for improved user experience and functionality in image analysis.
- Updated the TestUpload and TestUploadWithRAG functions to remove unnecessary parameters and improve clarity.
- Enhanced RAG handling by adding options for enabling/disabling RAG processing during file uploads.
- Improved test cases for RAG functionality, ensuring proper indexing behavior based on RAG settings.
- Refactored vision-related tests to include options for enabling/disabling vision processing, ensuring accurate responses based on the model capabilities.
- Streamlined the setup of test assistants to simplify the testing process.

These changes improve the maintainability and clarity of the attachment handling code, paving the way for better functionality in file uploads and processing.
- Replaced the custom context creation functions with a new context package, enhancing consistency and maintainability across the API.
- Updated multiple methods in the DSL to utilize the new context package, ensuring a unified approach to context management.
- Removed the obsolete context.go file, streamlining the codebase and reducing redundancy.

These changes improve the overall structure and clarity of the Neo API, paving the way for future enhancements in context handling and assistant functionalities.
… API

- Updated the Answer method to improve assistant initialization by directly calling the new HookInit method, streamlining the process of selecting and initializing assistants based on context.
- Introduced ResHookInit struct to encapsulate the response from the assistant initialization hook, enhancing clarity and maintainability.
- Enhanced the context package by adding a Map method to facilitate easier mapping of context data, improving the overall structure of context management.
- Refactored the assistant interface to include the new HookInit method, ensuring a consistent approach to assistant interactions.

These changes improve the robustness and maintainability of the Neo API, paving the way for future enhancements in assistant functionalities and context management.
- 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.
- Updated the Answer method to utilize the new Execute method, simplifying the assistant interaction process.
- Introduced a new Execute method in the Assistant struct to encapsulate the chat execution logic, enhancing clarity and maintainability.
- Refactored the HookInit method to accept input messages and options, improving the initialization process for assistants.
- Enhanced the ResHookInit struct to include next action handling and input messages, providing better control over assistant responses.
- Removed obsolete chat handling methods, streamlining the codebase and improving overall structure.

These changes improve the robustness and maintainability of the Neo API, paving the way for future enhancements in assistant functionalities and message management.
…and streaming support

- Added message handling in the Execute method to support input messages from the response.
- Updated the handleChatStream method to pass the context to the streamChat method, improving context management during chat streaming.
- Introduced the HookStream method to handle streaming responses, allowing for custom output and next action handling based on the assistant's response.
- Enhanced the ResHookStream struct to include silent output control and next action management, providing better flexibility in assistant interactions.

These changes improve the robustness and maintainability of the Neo API, paving the way for enhanced assistant functionalities and message management.
- Introduced HookDone and HookFail methods to manage completion and failure scenarios in assistant responses, improving error handling and output customization.
- Updated streamChat method to utilize these hooks, allowing for more flexible response management based on the assistant's output and error states.
- Enhanced ResHookDone and ResHookFail structs to include next action handling, input messages, and error information, providing better control over assistant interactions.

These changes improve the robustness and maintainability of the Neo API, paving the way for enhanced assistant functionalities and message management.
…mpletion handling

- Commented out the message writing logic in the streamChat method to prevent unintended output when the message is marked as done.
- This change enhances the control over the response flow, allowing for better integration with the newly introduced hook methods for managing assistant interactions.

These modifications contribute to the overall robustness and maintainability of the Neo API, aligning with recent enhancements in assistant functionalities.
@trheyi trheyi merged commit 9c7b9cf into YaoApp:main Jan 13, 2025
1 of 2 checks passed
Copy link

Thank you for the PR! The db: MySQL5.7 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL5.7 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL5.7 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL5.7 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL5.7 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL5.7 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: MySQL8.0 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 6 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 5 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

Thank you for the PR! The db: SQLite3 redis: 4 mongo: 6.0 test workflow is running, the results of the run will be commented later.

Copy link

✨DONE✨ db: MySQL8.0 redis: 6 mongo: 6.0 passed.

Copy link

✨DONE✨ db: MySQL5.7 redis: 5 mongo: 6.0 passed.

Copy link

✨DONE✨ db: MySQL5.7 redis: 4 mongo: 6.0 passed.

Copy link

✨DONE✨ db: MySQL5.7 redis: 6 mongo: 6.0 passed.

Copy link

✨DONE✨ db: SQLite3 redis: 5 mongo: 6.0 passed.

Copy link

✨DONE✨ db: MySQL8.0 redis: 4 mongo: 6.0 passed.

Copy link

✨DONE✨ db: SQLite3 redis: 6 mongo: 6.0 passed.

Copy link

✨DONE✨ db: MySQL8.0 redis: 5 mongo: 6.0 passed.

Copy link

✨DONE✨ db: SQLite3 redis: 4 mongo: 6.0 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant