get_usage_callback#

langchain_nvidia_ai_endpoints.callbacks.get_usage_callback(price_map: dict = {}, callback: UsageCallbackHandler | None = None) Generator[UsageCallbackHandler, None, None][source]#

在上下文管理器中获取OpenAI回调处理程序。 它方便地暴露了令牌和成本信息。

Returns:

OpenAI 回调处理程序。

Return type:

OpenAICallbackHandler

Parameters:

示例

>>> with get_openai_callback() as cb:
...     # Use the OpenAI callback handler