Commit Graph

6 Commits

  • feat(ai): Rename package to @mariozechner/pi-ai and improve documentation
    - Changed package name from @mariozechner/ai to @mariozechner/pi-ai
    - Fixed generate-models.ts to fetch from models.dev API instead of local file
    - Completely rewrote README with practical examples:
      - Image input with base64 encoding
      - Proper tool calling with context management
      - Streaming with completion indicators
      - Abort signal usage
      - Provider-specific options (reasoning/thinking)
      - Custom model definitions for local/self-hosted LLMs
      - Environment variables explanation
    - Bumped version to 0.5.9 and published
  • feat(ai): Add image input tests for vision-capable models
    - Added image tests to OpenAI Completions (gpt-4o-mini)
    - Added image tests to Anthropic (claude-sonnet-4-0)
    - Added image tests to Google (gemini-2.5-flash)
    - Tests verify models can process and describe the red circle test image
  • refactor(ai): Update LLM implementations to use Model objects
    - LLM constructors now take Model objects instead of string IDs
    - Added provider field to AssistantMessage interface
    - Updated getModel function with type-safe model ID autocomplete
    - Fixed Anthropic model ID mapping for proper API aliases
    - Added baseUrl to Model interface for provider-specific endpoints
    - Updated all tests to use getModel for model instantiation
    - Removed deprecated models.json in favor of generated models
  • fix(ai): Deduplicate models and add Anthropic aliases
    - Add proper Anthropic model aliases (claude-opus-4-1, claude-sonnet-4-0, etc.)
    - Deduplicate models when same ID appears in both models.dev and OpenRouter
    - models.dev takes priority over OpenRouter for duplicate IDs
    - Fix test to use correct claude-3-5-haiku-latest alias
    - Reduces Anthropic models from 11 to 10 (removed duplicate)
  • 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
  • feat(ai): Add auto-generated TypeScript models with factory function
    - Generate models.generated.ts from models.json with proper types
    - Categorize providers: OpenAI (Responses), OpenAI-compatible, Anthropic, Gemini
    - Create createLLM() factory with TypeScript overloads for type safety
    - Auto-detect base URLs and environment variables for providers
    - Support 353 models across 39 providers with full autocompletion
    - Exclude generated file from git (rebuilt on npm build)