Pārlūkot izejas kodu

Annotations example (#24304)

tags/1.8.0
Asuka Minato pirms 2 mēnešiem
vecāks
revīzija
1459fded08
Revīzijas autora e-pasta adrese nav piesaistīta nevienam kontam
1 mainītis faili ar 5 papildinājumiem un 3 dzēšanām
  1. 5
    3
      api/core/model_runtime/entities/llm_entities.py

+ 5
- 3
api/core/model_runtime/entities/llm_entities.py Parādīt failu

from __future__ import annotations

from collections.abc import Mapping, Sequence from collections.abc import Mapping, Sequence
from decimal import Decimal from decimal import Decimal
from enum import StrEnum from enum import StrEnum
) )


@classmethod @classmethod
def from_metadata(cls, metadata: dict) -> "LLMUsage":
def from_metadata(cls, metadata: dict) -> LLMUsage:
""" """
Create LLMUsage instance from metadata dictionary with default values. Create LLMUsage instance from metadata dictionary with default values.


latency=metadata.get("latency", 0.0), latency=metadata.get("latency", 0.0),
) )


def plus(self, other: "LLMUsage") -> "LLMUsage":
def plus(self, other: LLMUsage) -> LLMUsage:
""" """
Add two LLMUsage instances together. Add two LLMUsage instances together.


latency=self.latency + other.latency, latency=self.latency + other.latency,
) )


def __add__(self, other: "LLMUsage") -> "LLMUsage":
def __add__(self, other: LLMUsage) -> LLMUsage:
""" """
Overload the + operator to add two LLMUsage instances. Overload the + operator to add two LLMUsage instances.



Notiek ielāde…
Atcelt
Saglabāt