50 lines
1.9 KiB
Python
50 lines
1.9 KiB
Python
"""
|
|
Knowledge Consolidation models for Librarian processing.
|
|
|
|
Used by the consolidation endpoint to process SearchQuery nodes
|
|
and consolidate knowledge into wiki pages.
|
|
"""
|
|
from pydantic import BaseModel, Field
|
|
from typing import List, Optional, Dict, Any
|
|
|
|
|
|
class ConsolidationRequest(BaseModel):
|
|
"""Request for knowledge consolidation from search results."""
|
|
process_limit: int = Field(default=10, ge=1, le=100, description="Max searches to process")
|
|
lookback_days: int = Field(default=7, ge=1, le=90, description="Process searches from last N days")
|
|
min_web_results: int = Field(default=2, ge=1, le=20, description="Minimum web results needed")
|
|
dry_run: bool = Field(default=False, description="If true, analyze but don't create pages")
|
|
|
|
|
|
class SearchQueryInfo(BaseModel):
|
|
"""Information about a search query to process."""
|
|
id: str
|
|
query: str
|
|
user: str
|
|
timestamp: str
|
|
total_results: int
|
|
web_count: int
|
|
keywords: List[str] = []
|
|
|
|
|
|
class ConsolidationResult(BaseModel):
|
|
"""Result of processing a single search query."""
|
|
search_id: str
|
|
query: str
|
|
pages_created: int = 0
|
|
pages_updated: int = 0
|
|
entities_added: int = 0
|
|
error: Optional[str] = None
|
|
|
|
|
|
class ConsolidationResponse(BaseModel):
|
|
"""Response from knowledge consolidation."""
|
|
total_found: int = Field(description="Total unprocessed searches found")
|
|
processed_count: int = Field(description="Successfully processed searches")
|
|
pages_created: int = Field(description="New wiki pages created")
|
|
pages_updated: int = Field(description="Existing pages updated")
|
|
entities_added: int = Field(description="New entities added to graph")
|
|
errors: List[str] = Field(default=[], description="Error messages")
|
|
results: List[ConsolidationResult] = Field(description="Per-search results")
|
|
dry_run: bool = Field(description="Whether this was a dry run")
|