EmbeddingUsage (embedding/_embedding_usage.py)

agentscope · src/agentscope/embedding/_embedding_usage.py · python · Apache-2.0
ai, tag:embed-classified

Dataclass representing usage metrics for an embedding API call.

# Source: https://github.com/agentscope-ai/agentscope | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
# -*- coding: utf-8 -*-
"""The embedding usage class in agentscope."""
from dataclasses import dataclass, field
from typing import Literal

from .._utils._mixin import DictMixin


@dataclass
class EmbeddingUsage(DictMixin):
    """The usage of an embedding model API invocation."""

    time: float
    """The time used in seconds."""

    tokens: int | None = field(default_factory=lambda: None)
    """The number of tokens used, if available."""

    type: Literal["embedding"] = field(default_factory=lambda: "embedding")
    """The type of the usage, must be `embedding`."""

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key