|
2 | 2 |
|
3 | 3 | from datetime import datetime
|
4 | 4 | from enum import Enum
|
5 |
| -from typing import Any, Dict, List, Optional |
| 5 | +from typing import Any, Dict, List, Optional, Union |
6 | 6 |
|
7 | 7 | from pydantic import BaseModel, Field
|
8 | 8 |
|
@@ -788,3 +788,99 @@ class MemorySearchResult(BaseModel):
|
788 | 788 | relevance_score: float = Field(..., description="Relevance score for the search query")
|
789 | 789 | match_reason: str = Field(..., description="Reason for the match")
|
790 | 790 | highlighted_content: Optional[Dict[str, Any]] = Field(None, description="Content with search highlights")
|
| 791 | + |
| 792 | + |
| 793 | +# ============================================================================= |
| 794 | +# Phase 3 Qdrant Integration Models |
| 795 | +# ============================================================================= |
| 796 | + |
| 797 | +class Vector(BaseModel): |
| 798 | + """Vector representation for Qdrant.""" |
| 799 | + id: Union[str, int] = Field(..., description="Vector identifier") |
| 800 | + values: List[float] = Field(..., description="Vector values/embeddings") |
| 801 | + metadata: Dict[str, Any] = Field(default_factory=dict, description="Vector metadata") |
| 802 | + |
| 803 | + |
| 804 | +class Point(BaseModel): |
| 805 | + """Point representation for Qdrant.""" |
| 806 | + id: Union[str, int] = Field(..., description="Point identifier") |
| 807 | + vector: Union[List[float], Dict[str, List[float]]] = Field(..., description="Vector data") |
| 808 | + payload: Dict[str, Any] = Field(default_factory=dict, description="Point payload/metadata") |
| 809 | + |
| 810 | + |
| 811 | +class SearchQuery(BaseModel): |
| 812 | + """Search query for vector similarity search.""" |
| 813 | + vector: List[float] = Field(..., description="Query vector") |
| 814 | + limit: int = Field(10, description="Maximum number of results") |
| 815 | + score_threshold: Optional[float] = Field(None, description="Minimum similarity score") |
| 816 | + filter: Optional[Dict[str, Any]] = Field(None, description="Payload filter conditions") |
| 817 | + with_payload: bool = Field(True, description="Include payload in results") |
| 818 | + with_vector: bool = Field(False, description="Include vectors in results") |
| 819 | + |
| 820 | + |
| 821 | +class CollectionCreateRequest(BaseModel): |
| 822 | + """Request to create a new vector collection.""" |
| 823 | + name: str = Field(..., description="Collection name") |
| 824 | + vector_size: int = Field(..., description="Vector dimension size") |
| 825 | + distance: str = Field("Cosine", description="Distance metric (Cosine, Euclidean, Dot)") |
| 826 | + on_disk_payload: bool = Field(False, description="Store payload on disk") |
| 827 | + hnsw_config: Optional[Dict[str, Any]] = Field(None, description="HNSW configuration") |
| 828 | + optimizers_config: Optional[Dict[str, Any]] = Field(None, description="Optimizer configuration") |
| 829 | + |
| 830 | + |
| 831 | +class CollectionResponse(BaseModel): |
| 832 | + """Response from collection operations.""" |
| 833 | + collection_name: str = Field(..., description="Collection name") |
| 834 | + status: str = Field(..., description="Operation status") |
| 835 | + result: Optional[Dict[str, Any]] = Field(None, description="Operation result details") |
| 836 | + |
| 837 | + |
| 838 | +class CollectionInfo(BaseModel): |
| 839 | + """Information about a vector collection.""" |
| 840 | + collection_name: str = Field(..., description="Collection name") |
| 841 | + config: Dict[str, Any] = Field(..., description="Collection configuration") |
| 842 | + status: str = Field(..., description="Collection status") |
| 843 | + vectors_count: int = Field(..., description="Number of vectors") |
| 844 | + indexed_vectors_count: int = Field(..., description="Number of indexed vectors") |
| 845 | + points_count: int = Field(..., description="Number of points") |
| 846 | + |
| 847 | + |
| 848 | +class VectorUpsertRequest(BaseModel): |
| 849 | + """Request to upsert vectors into a collection.""" |
| 850 | + collection_name: str = Field(..., description="Target collection name") |
| 851 | + points: List[Point] = Field(..., description="Points to upsert") |
| 852 | + wait: bool = Field(True, description="Wait for operation completion") |
| 853 | + |
| 854 | + |
| 855 | +class UpsertResponse(BaseModel): |
| 856 | + """Response from vector upsert operation.""" |
| 857 | + collection_name: str = Field(..., description="Collection name") |
| 858 | + operation_id: Optional[str] = Field(None, description="Operation identifier") |
| 859 | + status: str = Field(..., description="Operation status") |
| 860 | + points_count: int = Field(..., description="Number of points processed") |
| 861 | + |
| 862 | + |
| 863 | +class VectorPoint(BaseModel): |
| 864 | + """Vector point with metadata.""" |
| 865 | + id: Union[str, int] = Field(..., description="Point identifier") |
| 866 | + vector: List[float] = Field(..., description="Vector values") |
| 867 | + payload: Dict[str, Any] = Field(default_factory=dict, description="Point metadata") |
| 868 | + score: Optional[float] = Field(None, description="Similarity score (for search results)") |
| 869 | + |
| 870 | + |
| 871 | +class EmbeddingRequest(BaseModel): |
| 872 | + """Request to generate embeddings.""" |
| 873 | + texts: List[str] = Field(..., description="Texts to embed") |
| 874 | + model: str = Field("default", description="Embedding model to use") |
| 875 | + collection_name: Optional[str] = Field(None, description="Target collection") |
| 876 | + metadata: Optional[List[Dict[str, Any]]] = Field(None, description="Metadata for each text") |
| 877 | + |
| 878 | + |
| 879 | +class EmbeddingResponse(BaseModel): |
| 880 | + """Response from embedding generation.""" |
| 881 | + embeddings: List[List[float]] = Field(..., description="Generated embeddings") |
| 882 | + model: str = Field(..., description="Model used for embedding") |
| 883 | + processing_time_ms: float = Field(..., description="Processing time in milliseconds") |
| 884 | + token_count: Optional[int] = Field(None, description="Total token count processed") |
| 885 | + |
| 886 | + |
0 commit comments