@fluttensor-ai/evogen
v0.0.10
Published
A gateway for AI models using the Vercel AI SDK, allowing users to choose from various AI providers.
Readme
EvoGen
A TypeScript wrapper to seamlessly route multiple Vercel AI providers by model name, offering unparalleled flexibility and extensibility for managing diverse AI services—inspired by the provider-routing architecture of litellm but optimized for TypeScript/Vercel workflows
Table of Contents
Installation
To install the package, use npm or yarn:
npm install @fluttensor-ai/evogenor
yarn add @fluttensor-ai/evogenUsage
Initialization
First, you need to initialize the EvoGen class with a map of strategies.
import { EvoGen } from 'evogen';
import { BaseEvogenStorage } from 'evogen/core';
// Define your strategies
const strategies = new Map<string, BaseEvogenStorage<{}>>();
strategies.set('default', new YourDefaultStorageStrategy());
// Initialize EvoGen
const evoGen = new EvoGen(strategies);Getting a Provider
You can get a provider by its type and strategy.
const provider = await evoGen.getProviderByType({
type: 'Ollama',
name: 'ollama-provider',
config: { apiKey: 'your-api-key' }
}, 'default');Getting Provider Configs
Retrieve the configuration for a specific provider.
const configs = await evoGen.getProviderConfigs('ollama-provider', 'default');Getting Provider API Key
Get the API key for a specific provider.
const apiKey = await evoGen.getProviderApiKey({
type: 'Ollama',
name: 'ollama-provider',
config: { apiKey: 'your-api-key' }
}, 'default');API Documentation
EvoGen Class
Constructor
constructor(strategies: Map<string, BaseEvogenStorage<{}>>)Initializes the EvoGen instance with a map of strategies.
getStorage
getStorage(strategy: string): BaseEvogenStorage<{}>Retrieves the storage strategy for the given strategy name.
getProviderApiKey
async getProviderApiKey(info: ProviderInfo, strategy: string, metadata?: Record<string, any>): Promise<string>Retrieves the API key for the given provider.
getProviderByType
async getProviderByType(info: ProviderInfo, strategy: string, metadata?: Record<string, any>): Promise<BaseEvogenProvider<any>>Retrieves a provider instance by its type.
getProviderConfigs
async getProviderConfigs(name: string, strategy: string, metadata?: Record<string, any>): Promise<Record<string, any>>Retrieves the configuration for a specific provider.
getProvider
async getProvider(name: string, strategy: string, config?: Record<string, any>, metadata?: Record<string, any>): Promise<BaseEvogenProvider<any>>Retrieves a provider instance by its name.
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
