adapters#

Adapters are used to adapt LangChain models to other APIs.

LangChain integrates with many model providers. While LangChain has its own message and model APIs, LangChain has also made it as easy as possible to explore other models by exposing an adapter to adapt LangChain models to the other APIs, as to the OpenAI API.

Classes

adapters.openai.Chat()

Chat.

adapters.openai.ChatCompletion()

Chat completion.

adapters.openai.ChatCompletionChunk

Chat completion chunk.

adapters.openai.ChatCompletions

Chat completions.

adapters.openai.Choice

Choice.

adapters.openai.ChoiceChunk

Choice chunk.

adapters.openai.Completions()

Completions.

adapters.openai.IndexableBaseModel

Allows a BaseModel to return its fields by string variable indexing.

Functions

adapters.openai.aenumerate(iterable[,Β start])

Async version of enumerate function.

adapters.openai.convert_dict_to_message(_dict)

Convert a dictionary to a LangChain message.

adapters.openai.convert_message_to_dict(message)

Convert a LangChain message to a dictionary.

adapters.openai.convert_messages_for_finetuning(...)

Convert messages to a list of lists of dictionaries for fine-tuning.

adapters.openai.convert_openai_messages(messages)

Convert dictionaries representing OpenAI messages to LangChain format.