Wrapper around OpenAI large language models that use the Chat endpoint.
To use you should have the OPENAI_API_KEY environment variable set.
To use with Azure you should have the:
AZURE_OPENAI_API_KEY,
AZURE_OPENAI_API_INSTANCE_NAME,
AZURE_OPENAI_API_DEPLOYMENT_NAME
and AZURE_OPENAI_API_VERSION environment variables set.
AZURE_OPENAI_BASE_PATH is optional and will override AZURE_OPENAI_API_INSTANCE_NAME if you need to use a custom endpoint.
Remarks
Any parameters that are valid to be passed to openai.createChatCompletion can be passed through modelKwargs, even
if not explicitly available on this class.
Example
// Create a new instance of ChatOpenAI with specific temperature and model name settings constmodel = newChatOpenAI({ temperature:0.9, model:"ft:gpt-3.5-turbo-0613:{ORG_NAME}::{MODEL_ID}", });
// Invoke the model with a message and await the response constmessage = awaitmodel.invoke("Hi there!");
// Log the response to the console console.log(message);
Wrapper around OpenAI large language models that use the Chat endpoint.
To use you should have the
OPENAI_API_KEYenvironment variable set.To use with Azure you should have the:
AZURE_OPENAI_API_KEY,AZURE_OPENAI_API_INSTANCE_NAME,AZURE_OPENAI_API_DEPLOYMENT_NAMEandAZURE_OPENAI_API_VERSIONenvironment variables set.AZURE_OPENAI_BASE_PATHis optional and will overrideAZURE_OPENAI_API_INSTANCE_NAMEif you need to use a custom endpoint.Remarks
Any parameters that are valid to be passed to
openai.createChatCompletioncan be passed through modelKwargs, even if not explicitly available on this class.Example