View Source LangChain.ChatModels.ChatOpenAI (LangChain v0.1.0)
Represents the OpenAI ChatModel.
Parses and validates inputs for making a requests from the OpenAI Chat API.
Converts responses into more specialized LangChain
data structures.
Summary
Functions
Calls the OpenAI API passing the ChatOpenAI struct with configuration, plus either a simple message or the list of messages to act as the prompt.
Return the params formatted for an API request.
Setup a ChatOpenAI client configuration.
Setup a ChatOpenAI client configuration and return it or raise an error if invalid.
Types
@type call_response() :: {:ok, LangChain.Message.t() | [LangChain.Message.t()]} | {:error, String.t()}
@type callback_data() :: {:ok, LangChain.Message.t() | LangChain.MessageDelta.t() | [LangChain.Message.t() | LangChain.MessageDelta.t()]} | {:error, String.t()}
Functions
@spec call( t(), String.t() | [LangChain.Message.t()], [LangChain.Function.t()], nil | (LangChain.Message.t() | LangChain.MessageDelta.t() -> any()) ) :: call_response()
Calls the OpenAI API passing the ChatOpenAI struct with configuration, plus either a simple message or the list of messages to act as the prompt.
Optionally pass in a list of functions available to the LLM for requesting execution in response.
Optionally pass in a callback function that can be executed as data is received from the API.
NOTE: This function can be used directly, but the primary interface
should be through LangChain.Chains.LLMChain
. The ChatOpenAI
module is more focused on
translating the LangChain
data structures to and from the OpenAI API.
Another benefit of using LangChain.Chains.LLMChain
is that it combines the
storage of messages, adding functions, adding custom context that should be
passed to functions, and automatically applying LangChain.MessageDelta
structs as they are are received, then converting those to the full
LangChain.Message
once fully complete.
Return the params formatted for an API request.
@spec new(attrs :: map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}
Setup a ChatOpenAI client configuration.
Setup a ChatOpenAI client configuration and return it or raise an error if invalid.