feat: RAG service (#1220)

This commit is contained in:
yetone
2025-02-23 01:37:26 +08:00
committed by GitHub
parent 437d36920d
commit fd84c91cdb
32 changed files with 2339 additions and 15 deletions

View File

View File

@@ -0,0 +1,19 @@
"""Indexing History Model."""
from datetime import datetime
from typing import Any
from pydantic import BaseModel, Field
class IndexingHistory(BaseModel):
"""Model for indexing history record."""
id: int | None = Field(None, description="Record ID")
uri: str = Field(..., description="URI of the indexed file")
content_hash: str = Field(..., description="MD5 hash of the file content")
status: str = Field(..., description="Indexing status (indexing/completed/failed)")
timestamp: datetime = Field(default_factory=datetime.now, description="Record timestamp")
error_message: str | None = Field(None, description="Error message if failed")
document_id: str | None = Field(None, description="Document ID in the index")
metadata: dict[str, Any] | None = Field(None, description="Additional metadata")

View File

@@ -0,0 +1,25 @@
"""Resource Model."""
from datetime import datetime
from typing import Literal
from pydantic import BaseModel, Field
class Resource(BaseModel):
"""Model for resource record."""
id: int | None = Field(None, description="Resource ID")
name: str = Field(..., description="Name of the resource")
uri: str = Field(..., description="URI of the resource")
type: Literal["local", "remote"] = Field(..., description="Type of resource (path/https)")
status: str = Field("active", description="Status of resource (active/inactive)")
indexing_status: Literal["pending", "indexing", "indexed", "failed"] = Field(
"pending",
description="Indexing status (pending/indexing/indexed/failed)",
)
indexing_status_message: str | None = Field(None, description="Indexing status message")
created_at: datetime = Field(default_factory=datetime.now, description="Creation timestamp")
indexing_started_at: datetime | None = Field(None, description="Indexing start timestamp")
last_indexed_at: datetime | None = Field(None, description="Last indexing timestamp")
last_error: str | None = Field(None, description="Last error message if any")