trulens.providers.google.endpoint¶
trulens.providers.google.endpoint
¶
Classes¶
GoogleCostComputer
¶
Functions¶
handle_response
staticmethod
¶
handle_response(response: Any) -> Dict[str, Any]
Process Google API response and extract cost/usage metadata.
| PARAMETER | DESCRIPTION |
|---|---|
response
|
GenerateContentResponse object from Google API
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Dictionary with cost and usage attributes for OpenTelemetry span |
GoogleCallback
¶
Bases: EndpointCallback
Attributes¶
endpoint
class-attribute
instance-attribute
¶
endpoint: Endpoint = Field(exclude=True)
The endpoint owning this callback.
cost
class-attribute
instance-attribute
¶
Costs tracked by this callback.
Functions¶
handle_generation
¶
handle_generation(response: Any)
Get the usage information from GoogleGenAI LLM function response's usage_metadata field.
__repr__
¶
__repr__() -> str
Safe repr that handles circular references.
Pydantic's default __repr__ does not guard against
circular references among model instances, which leads to
RecursionError (see GitHub issue #1862). This override
uses the same formatted_objects context-variable that
__rich_repr__ uses so that already-visited objects are
replaced with a short placeholder instead of recursing
infinitely.
handle_generation_chunk
¶
handle_generation_chunk(response: Any) -> None
Called after receiving a chunk from a completion request.
handle_classification
¶
handle_classification(response: Any) -> None
Called after each classification response.