04. Using the OpenAI API (GPT-4o multimodal)

# Configuration file for managing API KEY as environment variable
from dotenv import load_dotenv

# ALoad API KEY information
load_dotenv()
 True 
# Set up LangSmith tracking https://smith.langchain.com
# .env Enter LANGCHAIN_API_KEY in the file.
# !pip install -qU langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("CH01-Basic")
 Start tracking LangSmith. 
[Project name] 
CH01-Basic 

ChatOpenAI

Large Language Model (llm) for OpenAI's chat only.

When creating an object, you can specify the following option values: Here is a detailed description of the options:

temperature

  • The sampling temperature to use is selected between 0 and 2. High values like 0.8 make the output more random, and low values like 0.2 make the output more focused and deterministic.

max_tokens

  • The maximum number of tokens to create in the chat completion.

model_name : Applicable model list - gpt-3.5-turbo - gpt-4-turbo - gpt-4o

Last updated