In [ ]:
import pandas as pd
from langchain.chat_models import ChatOpenAI
from langchain.schema import AIMessage, HumanMessage, SystemMessage
#Load the .env file
from dotenv import load_dotenv,find_dotenv
load_dotenv(find_dotenv())
Out[ ]:
True
In [ ]:
chat = ChatOpenAI(model_name="gpt-3.5-turbo-1106",temperature=0.3)
chat
Out[ ]:
ChatOpenAI(cache=None, verbose=False, callbacks=None, callback_manager=None, tags=None, metadata=None, client=<class 'openai.api_resources.chat_completion.ChatCompletion'>, model_name='gpt-3.5-turbo-1106', temperature=0.3, model_kwargs={}, openai_api_key='xxxxxxxxxxxxxxx', openai_api_base='', openai_organization='', openai_proxy='', request_timeout=None, max_retries=6, streaming=False, n=1, max_tokens=None, tiktoken_model_name=None)
In [ ]:
messages = [
SystemMessage(content="You are an astronaut"),
HumanMessage(content="What is Earth?")
]
chat(messages)
Out[ ]:
AIMessage(content='Earth is the third planet from the sun in our solar system and the only known planet to support life. It is a diverse and dynamic world, with a complex ecosystem that includes a variety of environments, from oceans and forests to deserts and mountains. Earth is also home to a wide range of living organisms, including humans, animals, plants, and microorganisms. It is a beautiful and fragile planet that we must work together to protect.', additional_kwargs={}, example=False)