genai.extensions.langchain.utils module#

class genai.extensions.langchain.utils.CustomAIMessageChunk[source]#

Bases: AIMessageChunk

Replaces LangChain’s ‘merge_dicts’ with our simplified ‘merge_objects’ utility

class genai.extensions.langchain.utils.CustomChatGenerationChunk[source]#

Bases: ChatGenerationChunk

class genai.extensions.langchain.utils.CustomGenerationChunk[source]#

Bases: GenerationChunk

genai.extensions.langchain.utils.create_llm_output(*, model, token_usages=None, **kwargs)[source]#
Parameters:
  • model (str) –

  • token_usages (list[dict | None] | None) –

Return type:

dict[str, Any]

genai.extensions.langchain.utils.dump_optional_model(model)[source]#
Parameters:

model (BaseModel | None) –

Return type:

Mapping[str, Any] | None

genai.extensions.langchain.utils.load_config(file)[source]#
Parameters:

file (str | Path) –

Return type:

dict

genai.extensions.langchain.utils.update_token_usage(*, target, source)[source]#
Parameters:
  • target (dict[str, Any]) –

  • source (dict[str, Any] | None) –

genai.extensions.langchain.utils.update_token_usage_stream(*, target, source)[source]#
Parameters:
  • target (dict[str, Any]) –

  • source (dict | None) –