Commit Graph

13 Commits

  • feat(ai): Add zAI provider support
    - Add 'zai' as a KnownProvider type
    - Add ZAI_API_KEY environment variable mapping
    - Generate 4 zAI models (glm-4.5-air, glm-4.5v, etc.) using anthropic-messages API
    - Add comprehensive test coverage for zAI provider in generate.test.ts and empty.test.ts
    - Models support reasoning/thinking capabilities and tool calling
  • refactor(ai): Simplify API with new streaming interface and model management
    - Replace createLLM with getModel/getModels/getProviders functions
    - Rename PROVIDERS to MODELS (internal only, not exposed)
    - Add streamSimple/completeSimple for unified reasoning interface
    - Update README with new API examples and comprehensive documentation
    - Remove model registration (models are now fixed from build time)
    - Add proper TypeScript typing for provider-specific options
    - Document context serialization, cross-provider handoffs, and browser usage
  • Massive refactor of API
    - Switch to function based API
    - Anthropic SDK style async generator
    - Fully typed with escape hatches for custom models
  • feat(ai): Add gpt-5-chat-latest model to generated models
    - Added hardcoded gpt-5-chat-latest model since it's not in models.dev yet
    - Model has image input support and proper pricing configuration
  • feat(ai): Fetch Anthropic, Google, and OpenAI models from models.dev instead of OpenRouter
    - Updated generate-models.ts to fetch these providers directly from models.dev API
    - OpenRouter now only used for xAI and other third-party providers
    - Fixed test model IDs to match new model names from models.dev
    - Removed unused import from google.ts
  • 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)