fix: unified_search + ai_proactive get API key from DB, fix model names for Ollama Cloud

- query_understanding.py: get API key/base_url/provider_type from ai_providers DB
- embedding.py: get API key from DB, pass db+tenant_id through call chain
- routes.py: pass db+tenant_id to llm_analyze_query and llm_aggregate_results
- search_engine.py: pass db+tenant_id to generate_embedding
- unified_search/jobs.py: pass db+tenant_id to generate_embedding
- Fix all default model names: ollama/deepseek-v4 -> ollama/deepseek-v4-flash
- Ollama Cloud has no embedding endpoint; embedding calls fail gracefully
This commit is contained in:
Agent Zero
2026-07-19 02:22:25 +02:00
parent ef4f0cc494
commit 4a43745b50
9 changed files with 147 additions and 37 deletions
+2 -2
View File
@@ -186,7 +186,7 @@ async def deep_analysis(
extended_context["similar"] = {}
# Generate extended suggestion with deep analysis prompt
model = settings.model or "ollama/deepseek-v4"
model = settings.model or "ollama/deepseek-v4-flash"
# Get API key from DB (like ai_assistant does) or fall back to env
from app.plugins.builtins.ai_proactive.services import _get_llm_api_key
@@ -195,7 +195,7 @@ async def deep_analysis(
api_key = os.environ.get('API_KEY_OLLAMA_CLOUD', '') or None
# Build model string with provider prefix
model = settings.model or "ollama/deepseek-v4"
model = settings.model or "ollama/deepseek-v4-flash"
if provider_type:
model_parts = model.split("/", 1)
model = f"{provider_type}/{model_parts[-1]}"
+1 -1
View File
@@ -108,4 +108,4 @@ class ProactiveSettings(Base, TenantMixin):
rate_limit_seconds: Mapped[int] = mapped_column(
Integer, nullable=False, default=10
)
model: Mapped[str] = mapped_column(String(100), nullable=False, default="ollama/deepseek-v4")
model: Mapped[str] = mapped_column(String(100), nullable=False, default="ollama/deepseek-v4-flash")
+1 -1
View File
@@ -74,7 +74,7 @@ class SettingsResponse(BaseModel):
rate_limit_seconds: int
model: str
available_models: list[str] = Field(default_factory=lambda: [
'ollama/deepseek-v4',
'ollama/deepseek-v4-flash',
'ollama/deepseek-v4-pro',
'ollama/llama3.2',
'ollama/gpt-4o-mini',
@@ -113,7 +113,7 @@ async def get_user_settings(
suggestion_categories=["mail", "tasks", "contacts", "companies", "insights"],
confidence_threshold=0.5,
rate_limit_seconds=10,
model="ollama/deepseek-v4",
model="ollama/deepseek-v4-flash",
)
db.add(settings)
await db.flush()
@@ -395,7 +395,7 @@ async def generate_suggestion(
Returns dict with suggestion_type, title, content, confidence, actions
or None on failure.
"""
model = settings.model or "ollama/deepseek-v4"
model = settings.model or "ollama/deepseek-v4-flash"
# Get API key from DB (like ai_assistant does) or fall back to env
api_key = None
@@ -407,7 +407,7 @@ async def generate_suggestion(
api_key = os.environ.get('API_KEY_OLLAMA_CLOUD', '') or None
# Build model string with provider prefix (like ai_assistant build_litellm_params)
model = settings.model or "ollama/deepseek-v4"
model = settings.model or "ollama/deepseek-v4-flash"
if provider_type:
model_parts = model.split("/", 1)
model = f"{provider_type}/{model_parts[-1]}"