Commit cedde92
authored
Data fusion (#46)
* test: Enhance testing capabilities by adding coverage script and updating dependencies
* chore: Update .gitignore and vitest configuration to include coverage settings and additional test files
* refactor: move example to examples
* feat: Implement SentientAI tests and mock services
- Added unit tests for SentientAI to validate response handling.
- Created mock services for LLM and weather tools to facilitate testing.
- Cleaned up import paths in SentientAI.ts for consistency.
* refactor: Simplify Agent and Workflow classes, introduce LLMService
- Removed direct LLM instantiation from Agent, now using LLMService for LLM management.
- Refactored Workflow to utilize LLMService for LLM calls.
- Added unit tests for Agent to validate prompt generation and execution with tools.
- Introduced LLMService to encapsulate LLM initialization logic.
* feat: Enhance LLM functionality and add unit tests
- Updated TogetherLLM to require an API key during instantiation, improving error handling.
- Removed unnecessary console log from OpenAILLM's generate method.
- Added unit tests for DummyLLM, OpenAILLM, and TogetherLLM to validate response generation and error scenarios.
* chore: Update vitest configuration to include additional test directories and coverage files
* refactor: add types.ts
* refactor: Simplify Agent class and enhance SentientAI integration
- Refactored the Agent class to implement IAgent and streamline the constructor.
- Removed the previous prompt generation logic from the Agent class.
- Updated SentientAI to initialize the Agent with a name, description, and a comprehensive set of tools.
- Adjusted unit tests for the Agent to reflect the new structure and ensure proper functionality.
* refactor: Update Workflow class and add unit tests
- Introduced a new prompt generation template for tool selection.
- Updated the constructor to accept tools and a prompt function.
- Added unit tests for Workflow to validate tool execution and prompt generation with various scenarios.
- Improved error handling in the execute method.
* fix: Correct import path for callDify in depin_tool.ts
* feat: Add docker-compose configuration for application deployment
* refactor: Remove Agent class and integrate its functionality into SentientAI
* test: Update vitest configuration and add server tests
* refactor: Rename Workflow class to QueryOrchestrator and update related functionality
* feat: Add templates file and unit tests for templates
* refactor: Simplify QueryOrchestrator by moving templates to separate file
* refactor: Enhance QueryOrchestrator to improve tool selection and processing logic
- Removed unused ActionResult import and streamlined the process method.
- Refactored tool selection logic to utilize a new extraction function for tool names from LLM responses.
- Updated the selectTools method to return an array of selected tools based on user input.
- Added unit tests for process and selectTools methods to validate tool execution and selection scenarios.
- Improved error handling for cases with no tools selected.
* refactor: Update finalResponseTemplate and toolSelectionTemplate for improved tool handling
- Refactored finalResponseTemplate to support multiple tools and outputs, enhancing prompt generation.
- Updated toolSelectionTemplate to return a list of selected tool names instead of a JSON object format.
- Added a new test case for generating prompts with multiple tools in templates.test.ts.
- Improved handling of Twitter accounts for multiple tools in the final response.
* refactor: Update mockWeatherTools to use simplified tool selection format
* refactor: Update PromptContext to support multiple tools and outputs
* refactor: Enhance QueryOrchestrator process method to handle tool selection more effectively
- Introduced proceedWithoutTools and proceedWithTools methods to streamline processing.
- Updated unit tests to validate new behavior, including a test for processing input without tools.
- Removed outdated test case that checked for "No tools selected" message, aligning with new logic.
* refactor: Update APITool class to make twitterAccount optional and add unit tests
- Modified APITool constructor to accept twitterAccount as an optional parameter, defaulting to an empty string.
- Removed apiKey from the constructor, removing security risk where serialization of the class could include api key.
- Added a new test suite for APITool to validate initialization, execution, and optional twitterAccount handling.
- Ensured proper serialization to JSON without including apiKey.
* test: Remove JSON serialization test for APITool
* refactor: Update APITool to support generic input type and enhance execution logic
- Modified APITool class to accept a generic type parameter for input parsing.
- Implemented parseInput method in TestAPITool to handle specific input format.
- Updated execute method to utilize parsed input, improving execution output.
- Enhanced unit tests to validate new input handling and execution behavior.
* refactor: Update APITool constructor to include baseUrl parameter
* feat: Add extractContentFromTags utility and corresponding tests
* refactor: Migrate weather API tools to new structure and update imports
- Replaced references to the old weather API tools with the new Nubila API tools in multiple files.
- Deleted the outdated weatherapi.ts file and created a new nubila.ts file to encapsulate the current and forecast weather tools.
- Updated tests to mock the new Nubila API tools and ensure compatibility with the refactored structure.
- Enhanced the CurrentWeatherAPITool to include improved input parsing and error handling.
- Added new types for weather data to support the updated API response structure.
* refactor: import extractContentFromTags utility into QueryOrchestrator
* refactor: mock classes locally
* refactor: Enhance Nubila weather tools with improved input handling and new data types
- Updated CurrentWeatherAPITool and ForecastWeatherAPITool to utilize a new Coordinates class for input parsing.
- Introduced WeatherForecast type to accommodate the updated API response structure.
- Refactored input parsing logic to streamline extraction of latitude and longitude from user queries.
- Enhanced error handling for API requests and input validation in both weather tools.
- Updated unit tests to cover new functionality and ensure compatibility with the refactored structure.
* refactor: Restructure weather API tools to use a base class and improve error messages
- Introduced BaseWeatherAPITool class to encapsulate common functionality for CurrentWeatherAPITool and ForecastWeatherAPITool.
- Updated error messages to include tool names for better clarity in logs.
- Refactored fetchWeatherData and formatWeatherData methods to be protected and abstract where appropriate.
- Adjusted unit tests to reflect changes in error message formatting and class structure.
* feat: move NewsAPITool and add unit tests for news api
* refactor: move dify tool, add unit tests
* refactor: update import paths for Tool interface in ioId and tool files
* test: add unit tests for LLMService
* refactor: clean up LLMService initialization logic
* refactor: update SentientAI remove agent from sentientai
* test: add TypeScript ignore comments for private method mocking in workflow and weather tests
* refactor: enhance tool with tool output information
- Updated finalResponseTemplate and toolSelectionTemplate to include an output property for tools.
- Refactored APITool constructor to accept an object for better clarity and maintainability.
- Introduced new unit tests for templates to ensure correct prompt generation with and without Twitter accounts.
- Improved error handling in NewsAPITool and added output descriptions for better context in tool usage.
* refactor: overhaul finalResponseTemplate for enhanced user interaction
- Updated finalResponseTemplate to provide a structured response format, including detailed analysis and response sections.
- Improved clarity by replacing raw data outputs with tagged sections for user input, tools used, and tool outputs.
- Enhanced the response generation process with a step-by-step analysis guide to ensure accurate and relevant answers.
- Adjusted unit tests to validate the new response structure and ensure proper handling of tool outputs and Twitter accounts.
* refactor: enhance DePINTool with LLMService integration and improved input parsing
* refactor: integrate LLMService into weather tools for improved input parsing and response handling
- Updated execute and parseInput methods to accept LLMService as a parameter for enhanced functionality.
- Modified the input parsing logic to derive coordinates more effectively from user queries.
- Adjusted unit tests to reflect changes in method signatures and ensure proper LLMService integration.
- Changed response format in coordinate extraction to improve clarity and consistency.
* feat: add DEPIN_API_KEY environment variable to vitest setup for enhanced testing capabilities
* refactor: update QueryOrchestrator to enhance tool output handling and response parsing
- Added output property to tools in QueryOrchestrator for better context.
- Changed tool selection logic to extract tool names from the updated response format.
- Modified proceedWithTools method to include LLMService in tool execution and improved output parsing.
- Introduced a TestAPITool for unit testing, ensuring proper integration with the updated workflow.
- Updated unit tests to validate new tool handling and response formats.
* refactor: integrate LLMService into APITool for enhanced method functionality
- Updated execute and parseInput methods in APITool to accept LLMService as a parameter, improving integration with language model services.
- Added output property to Tool interface for better context in tool usage.
- Adjusted related types and imports to ensure consistency across the codebase.
* refactor: update mock data format in tests for improved response clarity
* feat: integrate Anthropic SDK into LLM service
- Added @anthropic-ai/sdk as a dependency in package.json and pnpm-lock.yaml.
- Refactored LLM classes to replace OpenAILLM and TogetherLLM with AnthropicLLM for improved functionality.
- Updated LLMService to initialize with AnthropicLLM, ensuring compatibility with new model configurations.
- Modified tests to reflect the removal of OpenAILLM and TogetherLLM, focusing on AnthropicLLM integration.
* refactor: move tools in one dir
* chore: remove unused dependencies and API key checks
- Removed Together AI and EmbedJS related dependencies from package.json
- Deleted TOGETHER_API_KEY environment variable check in LLMService constructor
* refactor: update AnthropicLLM constructor to accept model parameter
- Modified AnthropicLLM class to use a more flexible constructor
- Added explicit model parameter to improve configuration control
- Simplified object assignment in constructor initialization
* feat: add OpenAI LLM implementation to support multiple language models
- Integrated OpenAI SDK as a dependency in package.json
- Created OpenAILLM class implementing the LLM interface
- Added support for configurable model, API key, and optional base URL
- Improved type safety and error handling in LLM generation method
* refactor: optimize Nubila weather tool parameters and coordinate extraction
- Simplified weather tool field selection to focus on essential weather data
- Extracted coordinate extraction template to a separate module
- Improved coordinate parsing with a more concise LLM prompt template
* feat: enhance LLMService with flexible provider configuration
- Implemented support for multiple LLM providers (Anthropic, OpenAI, Deepseek)
- Added configurable fast and main LLM providers with custom model selection
- Updated LLMService constructor to accept provider parameters
- Expanded test coverage for different LLM provider scenarios
- Introduced DummyLLM as a fallback for unknown providers
* refactor: update SentientAI and QueryOrchestrator with DePINScan tools and LLM configuration
- Replaced DePINTool with DePINScanMetricsTool and DePINScanProjectsTool
- Modified QueryOrchestrator to accept LLMService as a constructor parameter
- Updated SentientAI to configure LLMService with OpenAI and Anthropic providers
- Simplified test mocks for LLMService and weather tools
* feat: add performance logging to LLM generation method
* feat: add performance timing to Anthropic LLM generation method
* feat: add DePINScan metrics and projects tools
- Implemented DePINScanMetricsTool to fetch global decentralized physical infrastructure (DePIN) metrics
- Created DePINScanProjectsTool to retrieve and analyze DePIN project information
- Added supporting template for project data extraction
- Included comprehensive test suite for both tools covering API interactions and error handling
* refactor: improve final response template readability
- Simplified template text by breaking long lines
- Removed redundant instructions and comments
- Cleaned up example output structure
* feat: add L1DataTool for IoTeX blockchain metrics
- Implemented L1DataTool to fetch comprehensive IoTeX L1 chain statistics
- Added support for retrieving metrics like TVL, contracts, staked tokens, nodes, dapps, and cross-chain transactions
- Created comprehensive test suite covering API interactions and error handling
- Integrated L1DataTool into SentientAI's tool collection
* chore: update Dockerfile and add .dockerignore for improved build process
- Optimized Dockerfile to copy project files before running bun install
- Added .dockerignore to exclude node_modules and npm-debug.log from Docker context
* chore: update .env.template with new LLM and API keys
- Added Deepseek and Anthropic API keys
- Configured default fast and main LLM models
- Included API V2 key for IoTeX L1 data
- Maintained template structure for easy configuration
* chore: update LLM provider configuration in SentientAI
- Switched main LLM provider from Anthropic to Deepseek
- Maintained existing configuration structure for LLMService1 parent 7a1933c commit cedde92
File tree
46 files changed
+2972
-1363
lines changed- __tests__
- example
- src
- __tests__
- services
- templates
- tools
- __tests__
- types
- types
- utils
- __test__
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
46 files changed
+2972
-1363
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
| 5 | + | |
7 | 6 | | |
8 | 7 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
16 | 14 | | |
17 | 15 | | |
18 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | | - | |
| 22 | + | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
| 28 | + | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
0 commit comments