Skip to content

Add Ollama support for local LLM inference#44

Open
schereroz wants to merge 1 commit intoviperrcrypto:mainfrom
schereroz:claude/setup-siftly-ollama-2cQ3C
Open

Add Ollama support for local LLM inference#44
schereroz wants to merge 1 commit intoviperrcrypto:mainfrom
schereroz:claude/setup-siftly-ollama-2cQ3C

Conversation

@schereroz
Copy link

Summary

Adds support for Ollama as a third AI provider option, enabling users to run local LLMs completely offline without API keys. Users can now switch between Anthropic, OpenAI, and Ollama in Settings.

Changes

  • New Provider Type: Added AIProvider type supporting 'anthropic' | 'openai' | 'ollama'
  • Settings Management:
    • Added getOllamaModel() and getOllamaBaseUrl() functions with 5-minute caching
    • Extended settings API to save/retrieve Ollama configuration (model name and server URL)
    • Updated provider validation to accept 'ollama' as valid provider
  • UI Components:
    • Added OllamaSettingsPanel component with model selection, base URL configuration, and connection testing
    • Updated ProviderToggle to include Ollama button alongside Anthropic and OpenAI
    • Simplified button labels (removed parenthetical descriptions)
  • AI Client Integration:
    • Added resolveOllamaClient() function that creates an OpenAI SDK instance pointing to Ollama's /v1 endpoint
    • Extended OpenAIAIClient to support Ollama as a provider variant
    • Updated resolveAIClient() to instantiate Ollama client when provider is 'ollama'
  • API Endpoints:
    • /api/settings: Added Ollama model and base URL persistence
    • /api/settings/cli-status: Added Ollama availability detection via /api/tags endpoint, returns available models
    • /api/settings/test: Added Ollama connection test with friendly error messages
  • Downstream Updates: Updated categorization, search, and image analysis routes to skip API key handling for Ollama
  • Documentation: Updated CLAUDE.md with Ollama setup instructions and provider overview

Related Issues

Checklist

  • Tested locally
  • npx tsc --noEmit passes
  • No new warnings

https://claude.ai/code/session_01HFSAKuoayERDciumSrRUyt

Adds full Ollama integration so users can run Siftly with local models
(llama3.1, mistral, etc.) — completely free, no API keys needed.

Changes:
- lib/settings.ts: New AIProvider type ('anthropic'|'openai'|'ollama'),
  getOllamaModel(), getOllamaBaseUrl() with caching
- lib/ai-client.ts: resolveOllamaClient() using OpenAI-compatible API,
  OpenAIAIClient now accepts provider parameter
- app/api/settings/route.ts: GET/POST handlers for ollamaModel & ollamaBaseUrl
- app/api/settings/test/route.ts: Ollama connection test with friendly errors
- app/api/settings/cli-status/route.ts: Ollama availability check via /api/tags
- app/settings/page.tsx: Three-tab provider toggle (Anthropic/OpenAI/Ollama),
  OllamaSettingsPanel with auto-detected models dropdown, base URL config,
  and connection test button
- app/api/categorize/route.ts, search/ai/route.ts, analyze/images/route.ts,
  lib/categorizer.ts: Handle 'ollama' provider in API key resolution
- .env.example: Document OLLAMA_BASE_URL
- CLAUDE.md: Ollama setup instructions

https://claude.ai/code/session_01HFSAKuoayERDciumSrRUyt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants