Skip to content

feat: add Openmeter support#74

Merged
nicky-ru merged 17 commits intomainfrom
openmeter
May 2, 2025
Merged

feat: add Openmeter support#74
nicky-ru merged 17 commits intomainfrom
openmeter

Conversation

@nicky-ru
Copy link
Contributor

@nicky-ru nicky-ru commented May 2, 2025

Added

  • track token usage with openmeter

nicky-ru added 17 commits May 1, 2025 11:42
- Introduced a new HonoSSETransport class for managing Server-Sent Events (SSE) connections, enabling real-time communication with the MCP server.
- Created endpoints for establishing SSE connections and handling incoming messages, ensuring robust error handling and response management.
- Integrated the MCP server with the Hono framework, allowing for streamlined message processing and transport management.
- Updated package.json to include the @modelcontextprotocol/sdk dependency for necessary SDK functionalities.
- Changed the import path for addMCPTools from 'mcp/initTools' to './src/mcp/registry.js' to improve module organization and maintainability.
- Changed the MCP server name from 'weather' to 'askSentientAI' for better alignment with project goals.
- Refactored tool registration by replacing addMCPTools with ToolRegistry.registerMcpTools to enhance modularity and maintainability.
- Updated package.json to include a new script for starting the MCP server, improving usability for developers.
- Introduced the `registerMcpTools` static method in `ToolRegistry` to facilitate the registration of tools with the MCP server.
- Enhanced the tool registration process by iterating over enabled tools and their schemas, allowing for dynamic tool setup.
- Improved the execution handling of registered tools, ensuring proper response formatting and error management.
- Added Calculator and Timestamp Converter tools to multiple specialty domains, improving functionality and versatility.
- Updated the tools array in the domains configuration to include these new tools, ensuring comprehensive coverage across relevant domains.
…ion files

- Added configs/*.json to both .dockerignore and .gitignore to prevent JSON configuration files from being included in Docker builds and version control, enhancing project cleanliness and maintainability.
- Updated the test suite for AskSpecialtyTool to include new tools: Calculator and Timestamp Converter.
- Enhanced test coverage by verifying the integration of these tools in the toolset, ensuring comprehensive validation of functionality.
- Upgraded the "ai" package from version 4.1.45 to 4.3 to ensure compatibility with the latest features and improvements.
- This change supports ongoing efforts to maintain an up-to-date and efficient codebase.
- Refined the available tools section by standardizing formatting and enhancing descriptions for better readability.
- Improved API reference details, including clearer parameter descriptions and examples for various endpoints.
- Added whitespace for better visual separation and clarity throughout the document.
- Enhanced overall structure and organization to facilitate easier navigation and understanding for users.
- Added '@modelcontextprotocol/sdk' version 1.11.0 to the lock file for improved functionality.
- Upgraded 'ai' package from version 4.1.45 to 4.3.13 to ensure compatibility with the latest features.
- Updated various other dependencies to their latest versions, enhancing overall project stability and performance.
- Added detailed instructions for running in MCP (Model Context Protocol) mode, including command examples and client configuration.
- Introduced new API endpoints specific to MCP mode, with request and response examples for better clarity.
- Enhanced overall documentation structure to improve user understanding of MCP functionalities.
- Introduced a new Metering class that implements the IMetering interface, providing functionality to track events, create standardized event formats, and manage event flushing to a remote API.
- Added support for auto-flushing events based on configurable intervals and batch sizes, enhancing the efficiency of event processing.
- Implemented error handling for API interactions, ensuring robust logging and retry mechanisms for failed event submissions.
- Created comprehensive unit tests to validate the Metering class functionality, covering various scenarios including event tracking, API error handling, and configuration options.
- Enhanced the ModelAdapter class to include metering functionality, allowing for tracking of prompt usage during text generation and streaming processes.
- Implemented metering calls in both the generate and stream methods to log input and output token usage, improving observability of model interactions.
- Ensured that metering is initialized with a configurable source, aligning with the new Metering class introduced in the previous commit.
- Removed redundant import of Logger from 'winston' in metering.test.ts.
- Streamlined the import statements for better readability and maintainability.
- Moved the event sending logic from the main processing function to a new private method `sendEvents`, improving code readability and maintainability.
- This refactor adheres to the Single Responsibility Principle by isolating the event handling functionality, making the codebase cleaner and easier to test.
- Moved the import of IMetering above the Metering import in llm.ts to enhance the organization of dependencies.
- This change improves code readability and maintains a consistent import structure.
@nicky-ru nicky-ru merged commit 7170636 into main May 2, 2025
2 checks passed
@nicky-ru nicky-ru deleted the openmeter branch May 2, 2025 16:11
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