utils#

Utility functions for LangChain.

Classes

utils.ernie_functions.FunctionDescription

Representation of a callable function to the Ernie API.

utils.ernie_functions.ToolDescription

Representation of a callable function to the Ernie API.

Functions

utils.ernie_functions.convert_pydantic_to_ernie_function(...)

Convert a Pydantic model to a function description for the Ernie API.

utils.ernie_functions.convert_pydantic_to_ernie_tool(...)

Convert a Pydantic model to a function description for the Ernie API.

utils.google.get_client_info([module])

Return a custom user agent header.

utils.math.cosine_similarity(X, Y)

Row-wise cosine similarity between two equal-width matrices.

utils.math.cosine_similarity_top_k(X, Y[, ...])

Row-wise cosine similarity with optional top-k and score threshold filtering.

utils.openai.is_openai_v1()

Return whether OpenAI API is v1 or more.

utils.user_agent.get_user_agent()

Get user agent from environment variable.