You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
1.6 KiB
97 lines
1.6 KiB
"""
|
|
models/responses.py — Pydantic response schemas for the RAG API.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Any, Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class ChunkResult(BaseModel):
|
|
document_id: str
|
|
chunk_id: str
|
|
title: str
|
|
path: str
|
|
content: str
|
|
score: float
|
|
tags: list[str]
|
|
highlight: Optional[str] = None
|
|
|
|
|
|
class SearchResponse(BaseModel):
|
|
results: list[ChunkResult]
|
|
total: int
|
|
query_time_ms: float
|
|
|
|
|
|
class DocumentResponse(BaseModel):
|
|
id: str
|
|
path: str
|
|
title: str
|
|
content: str
|
|
frontmatter: dict[str, Any]
|
|
tags: list[str]
|
|
aliases: list[str]
|
|
word_count: Optional[int]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
indexed_at: Optional[datetime]
|
|
|
|
|
|
class RelatedDocument(BaseModel):
|
|
document_id: str
|
|
title: str
|
|
path: str
|
|
score: float
|
|
tags: list[str]
|
|
|
|
|
|
class GraphNode(BaseModel):
|
|
id: str
|
|
title: str
|
|
path: str
|
|
tags: list[str]
|
|
word_count: Optional[int]
|
|
|
|
|
|
class GraphEdge(BaseModel):
|
|
source: str
|
|
target: str
|
|
relation_type: str
|
|
label: Optional[str]
|
|
|
|
|
|
class GraphResponse(BaseModel):
|
|
nodes: list[GraphNode]
|
|
edges: list[GraphEdge]
|
|
|
|
|
|
class TagCount(BaseModel):
|
|
tag: str
|
|
count: int
|
|
|
|
|
|
class StatsResponse(BaseModel):
|
|
total_documents: int
|
|
total_chunks: int
|
|
total_relations: int
|
|
total_tags: int
|
|
last_indexed: Optional[datetime]
|
|
embedding_model: str
|
|
chat_model: str
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
status: str
|
|
database: str
|
|
ollama: str
|
|
version: str
|
|
|
|
|
|
class JobResponse(BaseModel):
|
|
job_id: str
|
|
status: str
|
|
message: str
|