File size: 2,028 Bytes
4dc3b79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pydantic import BaseModel, Field
from typing import List, Optional, Dict, Any

class QueryRequest(BaseModel):
    question: str = Field(..., description="The question to answer")
    chat_history: Optional[List[Dict[str, str]]] = Field(None, description="Conversation history")
    k: Optional[int] = Field(50, description="Number of documents to retrieve for reranking")

class QueryResponse(BaseModel):
    answer: str = Field(..., description="The generated answer")
    sources: List[Dict[str, Any]] = Field(..., description="Source documents used")
    context_preview: Optional[str] = Field(None, description="Preview of the context used")
    llm_model: Optional[str] = Field(None, description="The LLM model used to generate the answer")

class SearchRequest(BaseModel):
    query: str = Field(..., description="Search query")
    k: Optional[int] = Field(10, description="Number of results to return")

class SearchResponse(BaseModel):
    results: List[Dict[str, Any]] = Field(..., description="Search results")
    total_results: int = Field(..., description="Total number of results")

class DocumentUploadResponse(BaseModel):
    message: str = Field(..., description="Status message")
    documents_processed: int = Field(..., description="Number of files processed")
    chunks_added: int = Field(..., description="Number of document chunks added")

class CollectionStatsResponse(BaseModel):
    total_documents: int = Field(..., description="Total documents in collection")
    collection_name: str = Field(..., description="Collection name")
    metadata: Optional[Dict[str, Any]] = Field(None, description="Collection metadata")

class HealthResponse(BaseModel):
    status: str = Field(..., description="Service status")
    vector_store: bool = Field(..., description="Vector store status")
    chroma_directory: str = Field(..., description="Chroma persistence directory")
    embeddings_model: Optional[str] = Field(None, description="Embeddings model in use")