langchain_community.callbacks.manager
.get_openai_callback¶
- langchain_community.callbacks.manager.get_openai_callback() Generator[OpenAICallbackHandler, None, None] [source]¶
在上下文中获取 OpenAI 回调处理器,方便地公开令牌和成本信息。
- 返回
OpenAI 回调处理器。
- 返回类型
示例
>>> with get_openai_callback() as cb: ... # Use the OpenAI callback handler