@measey/mycoder-agent
Version:
Agent module for mycoder - an AI-powered software development assistant
48 lines • 1.71 kB
JavaScript
/**
* Provider registry and factory implementations
*/
import { AnthropicProvider } from './providers/anthropic.js';
import { OllamaProvider } from './providers/ollama.js';
import { OpenAIProvider } from './providers/openai.js';
// Provider factory registry
export const providerConfig = {
anthropic: {
keyName: 'ANTHROPIC_API_KEY',
docsUrl: 'https://mycoder.ai/docs/provider/anthropic',
model: 'claude-3-7-sonnet-20250219',
factory: (model, options) => new AnthropicProvider(model, options),
},
openai: {
keyName: 'OPENAI_API_KEY',
docsUrl: 'https://mycoder.ai/docs/provider/openai',
model: 'gpt-4o-2024-05-13',
factory: (model, options) => new OpenAIProvider(model, options),
},
ollama: {
docsUrl: 'https://mycoder.ai/docs/provider/ollama',
model: 'llama3.2',
baseUrl: 'http://localhost:11434',
factory: (model, options) => new OllamaProvider(model, options),
},
xai: {
keyName: 'XAI_API_KEY',
docsUrl: 'https://mycoder.ai/docs/provider/xai',
baseUrl: 'https://api.x.ai/v1',
model: 'grok-2-latest',
factory: (model, options) => new OpenAIProvider(model, options),
},
};
/**
* Create a provider instance
*/
export function createProvider(provider, model, options = {}) {
const config = providerConfig[provider];
if (!config) {
throw new Error(`Provider '${provider}' not found. Available providers: ${Object.keys(providerConfig).join(', ')}`);
}
return config.factory(model ?? config.model, {
...options,
baseUrl: options.baseUrl ?? config.baseUrl,
});
}
//# sourceMappingURL=provider.js.map