I’m getting a deprecation warning from LangChain but I can’t figure out what’s causing it. The warning message says that langchain_community.embeddings.openai.OpenAIEmbeddings is deprecated and should be replaced with the version from langchain-openai package.
The weird part is that I’m not directly importing or using OpenAIEmbeddings anywhere in my code, but the warning still appears. I already tried following the terminal suggestions but the warning persists.
Here’s my code that triggers this warning:
import os
from langchain.indexes.vectorstore import VectorstoreIndexCreator
from langchain_core.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate
from langchain_community.document_loaders.figma import FigmaFileLoader
from langchain_openai import ChatOpenAI
os.environ["OPENAI_API_KEY"] = 'your_api_key_here'
# Load Figma design file
design_loader = FigmaFileLoader(
access_token="figma_token",
ids="design-file-id",
key="figma_key",
)
vector_index = VectorstoreIndexCreator().from_loaders([design_loader])
design_retriever = vector_index.vectorstore.as_retriever()
# Set up prompts for code generation
system_template = """ You are an expert developer like John Carmack.
Analyze the design and generate comprehensive code.
Include all design functionality.
Format everything as a structured list.
Figma design data: {context} """
user_template = "Generate {text} with full mobile responsiveness"
system_msg = SystemMessagePromptTemplate.from_template(system_template)
user_msg = HumanMessagePromptTemplate.from_template(user_template)
user_query = 'Create test scenarios for this web interface'
chat_model = ChatOpenAI(api_key='your_key', temperature=0.1, model_name="gpt-4")
relevant_design_data = design_retriever.get_relevant_documents(user_query)
message_chain = [system_msg, user_msg]
prompt_template = ChatPromptTemplate.from_messages(message_chain)
ai_response = chat_model.invoke(
prompt_template.format_prompt(
context=relevant_design_data, text=user_query
).to_messages()
)
print(ai_response.content)
Why does this deprecation warning show up even though I’m not using OpenAIEmbeddings directly? How can I fix this issue?