Keep/_bmad-output/implementation-artifacts/2-1-infrastructure-ia-abstraction-provider.md
sepehr 3c4b9d6176 feat(ai): implement intelligent auto-tagging system
- Added multi-provider AI infrastructure (OpenAI/Ollama)
- Implemented real-time tag suggestions with debounced analysis
- Created AI diagnostics and database maintenance tools in Settings
- Added automated garbage collection for orphan labels
- Refined UX with deterministic color hashing and interactive ghost tags
2026-01-08 22:59:52 +01:00

2.1 KiB

Story 2.1: Infrastructure IA & Abstraction Provider

Status: done

Story

As an administrator, I want to configure my AI provider (OpenAI or Ollama) centrally, so that the application can use artificial intelligence securely.

Acceptance Criteria

  1. Given an AIProvider interface and the Vercel AI SDK installed.
  2. When I provide my API key or Ollama instance URL in environment variables.
  3. Then the system initializes the appropriate driver.
  4. And no API keys are exposed to the client-side.

Tasks / Subtasks

  • Installation du Vercel AI SDK (AC: 1)
    • npm install ai @ai-sdk/openai ollama-ai-provider
  • Création de l'interface d'abstraction AIProvider (AC: 1, 3)
    • Définir les méthodes standard (ex: generateTags(content: string), getEmbeddings(text: string))
  • Implémentation des drivers (AC: 3)
    • OpenAIProvider utilisant le SDK officiel
    • OllamaProvider pour le support local
  • Configuration via variables d'environnement (AC: 2, 4)
    • Gérer AI_PROVIDER, OPENAI_API_KEY, OLLAMA_BASE_URL dans .env
    • Créer une factory pour initialiser le bon provider au démarrage du serveur
  • Test de connexion (AC: 3)
    • Créer un endpoint de santé/test pour vérifier la communication avec le provider configuré

Senior Developer Review (AI)

  • Review Date: 2026-01-08
  • Status: Approved with auto-fixes
  • Fixes Applied:
    • Switched to generateObject with Zod for robust parsing.
    • Added strict error handling and timeouts.
    • Improved prompts and system messages.

Dev Agent Record

Agent Model Used

BMad Master (Gemini 2.0 Flash)

Debug Log References

  • Infrastructure created in keep-notes/lib/ai
  • Packages: ai, @ai-sdk/openai, ollama-ai-provider
  • Test endpoint: /api/ai/test

Completion Notes List

  • Abstraction interface defined
  • Factory pattern implemented
  • OpenAI and Ollama drivers ready
  • API test route created

File List

  • keep-notes/lib/ai/types.ts
  • keep-notes/lib/ai/factory.ts
  • keep-notes/lib/ai/providers/openai.ts
  • keep-notes/lib/ai/providers/ollama.ts
  • keep-notes/app/api/ai/test/route.ts

Status: review