mirror of
https://github.com/langgenius/dify.git
synced 2026-03-27 01:00:13 +08:00
Signed-off-by: -LAN- <laipz8200@outlook.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: WH-2099 <wh2099@pm.me>
48 lines
903 B
Python
48 lines
903 B
Python
from decimal import Decimal
|
|
from enum import StrEnum, auto
|
|
|
|
from pydantic import BaseModel
|
|
|
|
from dify_graph.model_runtime.entities.model_entities import ModelUsage
|
|
|
|
|
|
class EmbeddingInputType(StrEnum):
|
|
"""Embedding request input variants understood by the model runtime."""
|
|
|
|
DOCUMENT = auto()
|
|
QUERY = auto()
|
|
|
|
|
|
class EmbeddingUsage(ModelUsage):
|
|
"""
|
|
Model class for embedding usage.
|
|
"""
|
|
|
|
tokens: int
|
|
total_tokens: int
|
|
unit_price: Decimal
|
|
price_unit: Decimal
|
|
total_price: Decimal
|
|
currency: str
|
|
latency: float
|
|
|
|
|
|
class EmbeddingResult(BaseModel):
|
|
"""
|
|
Model class for text embedding result.
|
|
"""
|
|
|
|
model: str
|
|
embeddings: list[list[float]]
|
|
usage: EmbeddingUsage
|
|
|
|
|
|
class FileEmbeddingResult(BaseModel):
|
|
"""
|
|
Model class for file embedding result.
|
|
"""
|
|
|
|
model: str
|
|
embeddings: list[list[float]]
|
|
usage: EmbeddingUsage
|