fix: 8 AI services were not using configured provider

CRITICAL FIX: Auto-labels, notebook summaries, and other AI features
were not working because 8 services were calling getAIProvider() WITHOUT
passing the config parameter.

This caused them to use the default 'ollama' provider instead of
the configured OpenAI provider from the database.

ROOT CAUSE ANALYSIS:
Working features (titles):
- title-suggestions/route.ts: getAIProvider(config) ✓

Broken features (auto-labels, summaries):
- contextual-auto-tag.service.ts: getAIProvider() ✗ (2x)
- notebook-summary.service.ts: getAIProvider() ✗
- auto-label-creation.service.ts: getAIProvider() ✗
- notebook-suggestion.service.ts: getAIProvider() ✗
- batch-organization.service.ts: getAIProvider() ✗
- embedding.service.ts: getAIProvider() ✗ (2x)

FIXED: All 8 services now properly call:
  const config = await getSystemConfig()
  const provider = getAIProvider(config)

This ensures ALL AI features use the provider configured in the admin
interface (OpenAI) instead of defaulting to Ollama.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-12 23:34:16 +01:00
parent 1cbada87f4
commit 3dd48e248c
7 changed files with 85 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
import { prisma } from '@/lib/prisma'
import { getAIProvider } from '@/lib/ai/factory'
import { getSystemConfig } from '@/lib/config'
import type { Notebook } from '@/lib/types'
export class NotebookSuggestionService {
@@ -31,7 +32,8 @@ export class NotebookSuggestionService {
// 3. Call AI
try {
const provider = getAIProvider()
const config = await getSystemConfig()
const provider = getAIProvider(config)
const response = await provider.generateText(prompt)