Dealing with LangChain deprecation warnings in design file integration

I’m receiving a deprecation warning regarding OpenAIEmbeddings while working on my LangChain project, but I’m unsure of the cause. The warning indicates that langchain_community.embeddings.openai.OpenAIEmbeddings is deprecated and suggests using the version from the langchain-openai package instead. The issue is that I don’t seem to be using OpenAIEmbeddings directly in my code, which makes the source of this warning confusing.

I have already attempted to follow the suggestions provided by the terminal, but the warning persists. Below is my current setup:

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"] = 'my_api_key'

design_loader = FigmaFileLoader(
    access_token="my_token",
    ids="file-id",
    key="project_key",
)

vector_index = VectorstoreIndexCreator().from_loaders([design_loader])
design_retriever = vector_index.vectorstore.as_retriever()

system_template = """You are a skilled UI/UX developer.
Analyze the design components and their functionality.
Provide responses in list format.
Design nodes and metadata: {context}"""

user_template = "Create test scenarios for {text} with mobile compatibility"

system_msg = SystemMessagePromptTemplate.from_template(system_template)
user_msg = HumanMessagePromptTemplate.from_template(user_template)

user_query = 'Generate test cases for the interface elements'
llm_model = ChatOpenAI(api_key='my_key', temperature=0.1, model_name="gpt-4")

related_docs = design_retriever.get_relevant_documents(user_query)
prompt_messages = [system_msg, user_msg]
final_prompt = ChatPromptTemplate.from_messages(prompt_messages)

result = llm_model.invoke(
    final_prompt.format_prompt(
        context=related_docs, text=user_query
    ).to_messages()
)

print(result.content)

Could anyone assist me in understanding the reason behind this deprecation warning and how to resolve it?

same thing happend to me too. VectorstoreIndexCreator has hardcoded default embeddings using the deprecated stuff. u gotta pass the embeddings param when creating the index, even if ur not directly importing OpenAIEmbeddings. thatll fix the warning.

the problem’s with VectorstoreIndexCreator - it’s still using the old OpenAI embeddings even though you imported from langchain-openai. pass the embeddings explicitly: VectorstoreIndexCreator(embeddings=OpenAIEmbeddings()) and make sure ur importing from the langchain_openai package.

I hit this exact issue last month on a similar project. The deprecation warning shows up because VectorstoreIndexCreator defaults to the old OpenAIEmbeddings from langchain_community, no matter what you import at the top. You need to explicitly tell it which embeddings to use when creating the index. Import OpenAIEmbeddings from langchain_openai and pass it directly: from langchain_openai import OpenAIEmbeddings then vector_index = VectorstoreIndexCreator(embeddings=OpenAIEmbeddings()).from_loaders([design_loader]). This makes it use the updated embeddings instead of the deprecated one.

I encountered a similar issue in my project involving LangChain and Figma. The root cause lies with the VectorstoreIndexCreator, which relies on the deprecated OpenAIEmbeddings from the community package by default. Though you may not directly reference OpenAIEmbeddings in your code, it’s still being used internally. To resolve this, ensure you import the updated embeddings explicitly: from langchain_openai import OpenAIEmbeddings. Then, adjust your instantiation of the vector index to include the correct embeddings: vector_index = VectorstoreIndexCreator(embeddings=OpenAIEmbeddings()).from_loaders([design_loader]). This change should eliminate the deprecation warning.

This deprecation warning caught me off guard too when working with document loaders. VectorstoreIndexCreator automatically creates embeddings behind the scenes and defaults to the old implementation from langchain_community. Your imports look fine, but the class constructor doesn’t know to use the newer package version. Here’s what worked for me: create the embeddings object first, then pass it to the creator. Import with from langchain_openai import OpenAIEmbeddings, create your instance embeddings = OpenAIEmbeddings(), then pass it when creating the index vector_index = VectorstoreIndexCreator(embeddings=embeddings).from_loaders([design_loader]). This explicitly tells LangChain which embeddings implementation to use instead of relying on the default.