utils
#
Utility functions for LangChain.
These functions do not depend on any other LangChain module.
Classes
Dummy lock that provides the proper interface but no protection. |
|
|
Create |
|
Async context manager for safely finalizing an asynchronously cleaned-up resource such as an async generator, calling its |
alias of |
|
Formatter that checks for extra keys. |
|
Representation of a callable function to send to an LLM. |
|
Representation of a callable function to the OpenAI API. |
|
Dummy lock that provides the proper interface but no protection. |
|
|
Create |
alias of |
|
Custom exception for Chevron errors. |
Functions
|
Utility batching function for async iterables. |
|
Pure-Python implementation of anext() for testing purposes. |
|
An individual iterator of a |
|
Check if an environment variable is set. |
|
Get a value from a dictionary or an environment variable. |
|
Get a value from a dictionary or an environment variable. |
Convert a raw function/class to an OpenAI function. |
|
Convert a raw function/class to an OpenAI tool. |
|
Convert an example into a list of messages that can be fed into an LLM. |
|
|
Extract all links from a raw HTML string and convert into absolute paths. |
|
Extract all links from a raw HTML string. |
|
Get base64 string from image URI. |
|
Get data URL from image URI. |
Get bolded text. |
|
|
Get mapping for items to a support color. |
|
Get colored text. |
|
Print text with highlighting and no end characters. |
Determine if running within IPython or Jupyter. |
|
|
Utility batching function. |
|
An individual iterator of a |
Parse a JSON string from a Markdown string and check that it contains the expected keys. |
|
|
Parse a JSON string from a Markdown string. |
|
Parse a JSON string that may be missing closing braces. |
|
Try to substitute $refs in JSON Schema. |
|
Parse a literal from the template. |
|
Do a preliminary check to see if a tag could be a standalone. |
|
Parse a tag from a template. |
|
Do a final check to see if a tag could be a standalone. |
|
Render a mustache template. |
|
Tokenize a mustache template. |
Get the field names of a Pydantic model. |
|
Get the major version of Pydantic. |
|
Check if the given class is an instance of Pydantic BaseModel. |
|
Check if the given class is a subclass of Pydantic BaseModel. |
|
Check if the installed Pydantic version is 1.x-like. |
|
Check if the installed Pydantic version is 1.x-like. |
|
|
Decorator to run a function before model initialization. |
|
Convert a list to a comma-separated string. |
Stringify a dictionary. |
|
Stringify a value. |
|
|
Build extra kwargs from values and extra_kwargs. |
|
Check the version of a package. |
Convert a string to a SecretStr if needed. |
|
Create a factory method that gets a value from an environment variable. |
|
Get field names, including aliases, for a pydantic class. |
|
|
Dynamically import a module and raise an exception if the module is not installed. |
|
Context manager for mocking out datetime.now() in unit tests. |
|
Raise an error with the response text. |
Secret from env. |
|
|
Validate specified keyword args are mutually exclusive." |
Deprecated functions
|
Deprecated since version 0.1.16: Use |
Deprecated since version 0.1.16: Use |
|
|
Deprecated since version 0.1.16: Use |
Deprecated since version 0.1.16: Use |
|
Deprecated since version 0.1.16: Use |
|
|
Deprecated since version 0.1.30: Using the hwchase17/langchain-hub repo for prompts is deprecated. Please use <https://smith.langchain.com/hub> instead. |