88c1ea297e
All feature containers now POST messages to ai-service (port 8010) instead of calling AI providers directly. ai-service routes to LM Studio, Ollama, or Anthropic based on /config/ai_service_config.json. doc-service AI providers removed; replaced by httpx ai_client.py. Backend settings restructured to /api/settings/ai. Frontend gets dedicated AIAdminSettingsPage and AI Service card in AppsPage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
699 B
Python
31 lines
699 B
Python
from typing import Literal
|
|
|
|
from pydantic import BaseModel, field_validator
|
|
|
|
|
|
class ChatMessage(BaseModel):
|
|
role: Literal["system", "user", "assistant"]
|
|
content: str
|
|
|
|
|
|
class ChatRequest(BaseModel):
|
|
messages: list[ChatMessage]
|
|
max_tokens: int = 2048
|
|
temperature: float = 0.0
|
|
response_format: Literal["json", "text"] = "text"
|
|
|
|
@field_validator("messages")
|
|
@classmethod
|
|
def messages_not_empty(cls, v: list) -> list:
|
|
if not v:
|
|
raise ValueError("messages must not be empty")
|
|
return v
|
|
|
|
|
|
class ChatResponse(BaseModel):
|
|
content: str
|
|
provider: str
|
|
model: str
|
|
input_tokens: int | None = None
|
|
output_tokens: int | None = None
|