janus.llm.model_callbacks#
Attributes#
Classes#
Callback Handler that tracks metadata on model cost, retries, etc. |
Functions#
Module Contents#
- janus.llm.model_callbacks.log#
- janus.llm.model_callbacks.openai_model_reroutes#
- janus.llm.model_callbacks.azure_model_reroutes#
- class janus.llm.model_callbacks.TokenUsageCallbackHandler#
Bases:
langchain_core.callbacks.BaseCallbackHandler
Callback Handler that tracks metadata on model cost, retries, etc. Based on https://github.com/langchain-ai/langchain/blob/master/libs
/community/langchain_community/callbacks/openai_info.py
- property always_verbose: bool#
Whether to call verbose callbacks even if verbose is False.
- Return type:
- on_chat_model_start(*args, **kwargs)#
- on_llm_start(serialized, prompts, **kwargs)#
Print out the prompts.
- on_llm_new_token(token, **kwargs)#
Print out the token.
- Parameters:
token (str) –
kwargs (Any) –
- Return type:
None
- on_llm_end(response, **kwargs)#
Collect token usage.
- Parameters:
response (langchain_core.outputs.LLMResult) –
kwargs (Any) –
- Return type:
None
- janus.llm.model_callbacks.token_usage_callback_var: contextvars.ContextVar[TokenUsageCallbackHandler | None]#
- janus.llm.model_callbacks.get_model_callback()#
- Return type:
Generator[TokenUsageCallbackHandler, None, None]