refactor(ai): Implement unified model system with type-safe createLLM
- Add Model interface to types.ts with normalized structure - Create type-safe generic createLLM function with provider-specific model constraints - Generate models from OpenRouter API and models.dev data - Strip provider prefixes for direct providers (google, openai, anthropic, xai) - Keep full model IDs for OpenRouter-proxied models - Clean separation: types.ts (Model interface), models.ts (factory logic), models.generated.ts (data) - Remove old model scripts and unused dependencies - Rename GeminiLLM to GoogleLLM for consistency - Add tests for new providers (xAI, Groq, Cerebras, OpenRouter) - Support 181 tool-capable models across 7 providers with full type safety
This commit is contained in:
@@ -13,12 +13,12 @@ npm install @mariozechner/ai
|
||||
```typescript
|
||||
import { AnthropicLLM } from '@mariozechner/ai/providers/anthropic';
|
||||
import { OpenAICompletionsLLM } from '@mariozechner/ai/providers/openai-completions';
|
||||
import { GeminiLLM } from '@mariozechner/ai/providers/gemini';
|
||||
import { GoogleLLM } from '@mariozechner/ai/providers/gemini';
|
||||
|
||||
// Pick your provider - same API for all
|
||||
const llm = new AnthropicLLM('claude-sonnet-4-0');
|
||||
// const llm = new OpenAICompletionsLLM('gpt-5-mini');
|
||||
// const llm = new GeminiLLM('gemini-2.5-flash');
|
||||
// const llm = new GoogleLLM('gemini-2.5-flash');
|
||||
|
||||
// Basic completion
|
||||
const response = await llm.complete({
|
||||
|
||||
Reference in New Issue
Block a user