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 to wrap an AsyncGenerator that has a |
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 schema representation to a JSON schema. | |
Convert a raw function/class to an OpenAI function. | |
Convert a tool-like object to an OpenAI tool schema. | |
| Extract all links from a raw HTML string and convert into absolute paths. |
| Extract all links from a raw HTML string. |
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 and check a JSON string from a Markdown string. | |
| 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. |
| Create a pydantic model with the given field definitions. |
| Create a pydantic model with the given field definitions. |
Get the field names of a Pydantic model. | |
DEPRECATED - 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. |
| 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