- langchain_nvidia_ai_endpoints.callbacks.get_usage_callback(price_map: dict = {}, callback: Optional[UsageCallbackHandler] = None) Generator[UsageCallbackHandler, None, None] [source]¶
获取OpenAI回调处理程序的上下文管理器,方便地公开令牌和成本信息。
- 返回
OpenAI回调处理程序。
- 返回类型
- 参数
price_map (dict) –
callback (Optional[UsageCallbackHandler]) –
示例
>>> with get_openai_callback() as cb: ... # Use the OpenAI callback handler