Issue
Following LangChain
docs in my Jupyter
notebook with the following code :
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
prompt = ChatPromptTemplate.from_template("Tell me a short joke about {topic}")
model = ChatOpenAI(model="gpt-3.5-turbo")
output_parser = StrOutputParser()
chain = prompt | model | output_parser
Docs say that pip install langchain
installs all necessary modules, including langchain-community
and langchain-core
However, I get this error:
ModuleNotFoundError: No module named 'langchain_openai'
Solution
Following solution worked for me.
I referred to the API
docs.
from langchain_community.chat_models import ChatOpenAI
openai = ChatOpenAI(model_name="gpt-3.5-turbo")
Answered By - Ari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.