初始化
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"""Embedding 向量生成数据模型 (M5)。"""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class EmbeddingResult(BaseModel):
|
||||
"""单篇文章的嵌入向量结果,M5 最终落盘格式。"""
|
||||
|
||||
# 来源标识
|
||||
url_hash: str
|
||||
source_id: str
|
||||
|
||||
# 嵌入向量(1024 维 float 列表)
|
||||
vector: list[float] = Field(..., description="1024 维浮点向量")
|
||||
dimension: int = 1024
|
||||
|
||||
# 嵌入文本(用于检索时调试/可视化)
|
||||
embedded_text: str = Field(default="", description="拼接后送入 embedder 的文本")
|
||||
|
||||
# 调用元信息
|
||||
provider: str = "dashscope"
|
||||
model: str = ""
|
||||
embedded_at: datetime = Field(default_factory=datetime.now)
|
||||
|
||||
|
||||
class EmbeddingError(Exception):
|
||||
"""Embedding 调用失败。"""
|
||||
|
||||
def __init__(self, reason: str, *, attempts: int = 0) -> None:
|
||||
super().__init__(reason)
|
||||
self.reason = reason
|
||||
self.attempts = attempts
|
||||
Reference in New Issue
Block a user