rag snippet生成入库和写rag
This commit is contained in:
46
app/schemas/rag.py
Normal file
46
app/schemas/rag.py
Normal file
@ -0,0 +1,46 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, List
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class RagItemPayload(BaseModel):
|
||||
"""Payload for creating or updating a single RAG item."""
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
||||
|
||||
id: int = Field(..., description="Unique identifier for the RAG item.")
|
||||
workspace_id: int = Field(..., alias="workspaceId", description="Workspace identifier.")
|
||||
name: str = Field(..., description="Readable name of the item.")
|
||||
embedding_data: str = Field(..., alias="embeddingData", description="Serialized embedding payload.")
|
||||
type: str = Field(..., description='Item type, e.g. "METRIC".')
|
||||
|
||||
|
||||
class RagDeleteRequest(BaseModel):
|
||||
"""Payload for deleting a single RAG item."""
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
||||
|
||||
id: int = Field(..., description="Identifier of the item to delete.")
|
||||
type: str = Field(..., description="Item type matching the stored record.")
|
||||
|
||||
|
||||
class RagRetrieveRequest(BaseModel):
|
||||
"""Payload for retrieving RAG items by semantic query."""
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True, extra="ignore")
|
||||
|
||||
query: str = Field(..., description="Search query text.")
|
||||
num: int = Field(..., description="Number of items to return.")
|
||||
workspace_id: int = Field(..., alias="workspaceId", description="Workspace scope for the search.")
|
||||
type: str = Field(..., description="Item type to search, e.g. METRIC.")
|
||||
|
||||
|
||||
class RagRetrieveResponse(BaseModel):
|
||||
"""Generic RAG retrieval response wrapper."""
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
data: List[Any] = Field(default_factory=list, description="Retrieved items.")
|
||||
|
||||
Reference in New Issue
Block a user