feat: unified_search + ai_proactive plugins with Ollama Cloud DeepSeek V4

- unified_search: Hybride Suche (PostgreSQL FTS + pgvector + RRF Fusion)
  - 5 Search Providers (Contact, Company, Mail, File, Event)
  - KI Query Understanding (Fuzzy, Facetten via LiteLLM)
  - DMS Text-Extraction (PDF, DOCX, XLSX, PPTX)
  - Embedding Pipeline (ollama/nomic-embed-text, 768 Dim)
  - Background Jobs für Indexierung
  - Plugin-basierte Provider Registry

- ai_proactive: Proaktiver KI-Agent
  - Context-Tracking (Frontend → Backend → Event Bus)
  - Proactive Engine mit LLM Suggestion-Generierung
  - SSE Real-time Push an Frontend
  - 6 AI Tools für Tool Registry
  - Rate-Limiting + User Settings
  - Deep Analysis Background Jobs

- Frontend Integration:
  - useAIContext Hook, SuggestionSidebar, SuggestionBadge
  - ProactiveAISettings Page, Search API Client
  - Globale Suche auf neue API umgestellt

- Tests: test_unified_search.py + test_ai_proactive.py (alle bestanden)
- Config: Ollama Cloud DeepSeek V4 als Default, konfigurierbar
- Dependencies: PyMuPDF, python-docx, python-pptx, pgvector
- Bugfixes: notification type_key length, migration IF NOT EXISTS
This commit is contained in:
Agent Zero
2026-07-18 11:21:51 +02:00
parent 4c9295de21
commit 8cebb4f4e9
52 changed files with 6493 additions and 41 deletions
@@ -0,0 +1,103 @@
"""Pydantic v2 schemas for the AI Proactive plugin API."""
from __future__ import annotations
from datetime import datetime
from typing import Any
from pydantic import BaseModel, Field
class ContextReport(BaseModel):
"""Frontend reports the current page/entity context."""
page: str = Field(..., description="Current page path")
entity_type: str | None = Field(None, description="Entity type being viewed")
entity_id: str | None = Field(None, description="Entity ID being viewed")
entity_data: dict[str, Any] | None = Field(
None, description="Additional entity metadata"
)
class SuggestionAction(BaseModel):
"""A suggested CRM action."""
method: str = Field(..., description="HTTP method")
path: str = Field(..., description="API path")
body: dict[str, Any] | None = Field(None, description="Request body")
description: str = Field(..., description="Human-readable description")
class SuggestionResponse(BaseModel):
"""API response for a single suggestion."""
id: str
entity_type: str
entity_id: str | None
suggestion_type: str
title: str
content: str
confidence: float
actions: list[dict[str, Any]]
created_at: datetime
is_dismissed: bool
is_acted_upon: bool = False
class SuggestionListResponse(BaseModel):
"""Paginated list of suggestions."""
items: list[SuggestionResponse]
total: int
class ActRequest(BaseModel):
"""Execute a suggested action by index."""
action_index: int = Field(..., ge=0, description="Index into actions array")
class ActResponse(BaseModel):
"""Result of executing a suggested action."""
success: bool
data: dict[str, Any] | None = None
error: str | None = None
class SettingsResponse(BaseModel):
"""Proactive AI settings for the current user."""
enabled: bool
suggestion_categories: list[str]
confidence_threshold: float
rate_limit_seconds: int
model: str
available_models: list[str] = Field(default_factory=lambda: [
'ollama/deepseek-v4',
'ollama/deepseek-v4-pro',
'ollama/llama3.2',
'ollama/gpt-4o-mini',
'gpt-4o-mini',
])
class SettingsUpdate(BaseModel):
"""Partial update for proactive AI settings."""
enabled: bool | None = None
suggestion_categories: list[str] | None = None
confidence_threshold: float | None = None
rate_limit_seconds: int | None = None
model: str | None = None
class StatsResponse(BaseModel):
"""Proactive AI usage statistics."""
total_suggestions: int = 0
dismissed: int = 0
acted_upon: int = 0
active: int = 0
dismiss_rate: float = 0.0
act_rate: float = 0.0