refactor: Refactor AI SDK and MCP provider types, add utility functions and constants#32
Open
harshpreet931 wants to merge 1 commit intomainfrom
Open
refactor: Refactor AI SDK and MCP provider types, add utility functions and constants#32harshpreet931 wants to merge 1 commit intomainfrom
harshpreet931 wants to merge 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a comprehensive refactor of AI model provider types and utilities, moving from inline type definitions to centralized, reusable modules. The main goal is to improve maintainability, type safety, and modularity across the AI SDK and MCP provider integrations.
- Extracts type definitions into dedicated files (
ai-sdk-types.ts,mcp-types.ts,types.ts) for better organization - Consolidates utility functions and constants into shared modules (
utils.ts,constants.ts) - Improves type safety throughout provider implementations with stronger typing
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/providers/utils.ts |
New utility module with proxy agent creation, vision model detection, and Zod schema conversion functions |
src/providers/types.ts |
New shared type definitions for common provider interfaces and configurations |
src/providers/model.ts |
Refactored to use shared utilities and types, removing duplicate code |
src/providers/mcp.ts |
Updated to use centralized MCP types and improved type safety |
src/providers/mcp-types.ts |
New MCP-specific type definitions module |
src/providers/index.ts |
Added exports for all new type definitions for external consumption |
src/providers/constants.ts |
New constants module for vision model configuration |
src/providers/ai-sdk.ts |
Refactored to use centralized AI SDK types with improved type casting |
src/providers/ai-sdk-types.ts |
New AI SDK-specific type definitions module |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
0debc0d to
3b69dc0
Compare
7fbbb18 to
e05de49
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a significant refactor and modularization of type definitions and utility functions for AI model providers, particularly for the AI SDK and MCP (Model Context Protocol) integrations. The main changes involve moving type definitions into dedicated files, improving type safety, and standardizing schema conversions. This will make the codebase easier to maintain, extend, and use in other parts of the project or externally.
Type Definitions Modularization and Exports:
ai-sdk-types.tsandmcp-types.tsto hold all type definitions for the AI SDK and MCP providers, respectively, and updated imports/exports throughout the provider modules to use these centralized types. This enhances maintainability and reusability. [1] [2] [3] [4] [5]AI SDK Provider Improvements:
ai-sdk-types.ts.generateObjectlogic to use strongly typed options and results, and cleaned up schema conversion.MCP Provider Improvements:
mcp-types.ts, improving type safety for tool definitions, content items, and client interfaces.Provider Utility and Constants Improvements:
constants.tsfile for shared model provider constants, such as vision model cache TTL, API timeout, and known vision models.model.tsto use shared proxy and utility functions, removing redundant proxy agent code and improving clarity. [1] [2]Exports for External Use:
These changes collectively improve code organization, type safety, and extensibility for AI model provider integrations.