Lokeshwar V
Lokeshwar V

Reputation: 27

Langchain decprecation waring in Figma Usecase

This is langchain code i get langchain deprecation warning but dont know why.

C:\Users\ADMIN\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_core_api\deprecation.py:117: LangChainDeprecationWarning: The class langchain_community.embeddings.openai.OpenAIEmbeddings was deprecated in langchain-community 0.0.9 and will be removed in 0.2.0. An updated version of the class exists in the langchain-openai package and should be used instead. To use it run pip install -U langchain-openai and import as from langchain_openai import OpenAIEmbeddings. warn_deprecated(

Im not using openAIembedding in code but still it shows this , what can i do?

FYI, I tired everything that terminal said.

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"] ='api key'
figma_loader = FigmaFileLoader(
    access_token="Token",
    ids="0-1",
    key=key,
)
index = VectorstoreIndexCreator().from_loaders([figma_loader])
figma_doc_retriever = index.vectorstore.as_retriever()

# I have no idea if the Jon Carmack thing makes for better code. YMMV.
# See https://python.langchain.com/en/latest/modules/models/chat/getting_started.html for chat info
system_prompt_template = """ You are expert Jon Carmack. 
It should also include the functionality of the design.
Everything must be as a List.
Figma file nodes and metadata: {context} """
human_prompt_template = "Code the {text}. Ensure it's mobile responsive"
system_message_prompt = SystemMessagePromptTemplate.from_template(
    system_prompt_template
)
human_message_prompt = HumanMessagePromptTemplate.from_template(
    human_prompt_template
)
# delete the gpt-4 model_name to use the default gpt-3.5 turbo for faster results
human_input='Give me a list of test cases for the current webpage'
gpt_4 = ChatOpenAI(api_key='api key',temperature=0.02, model_name="gpt-4")
# Use the retriever's 'get_relevant_documents' method if needed to filter down longer docs
relevant_nodes = figma_doc_retriever.get_relevant_documents(human_input)
conversation = [system_message_prompt, human_message_prompt]
chat_prompt = ChatPromptTemplate.from_messages(conversation)
response = gpt_4.invoke(
    chat_prompt.format_prompt(
        context=relevant_nodes, text=human_input
    ).to_messages()
)
print(response.content)

Upvotes: 0

Views: 367

Answers (1)

Lokeshwar V
Lokeshwar V

Reputation: 27

Alt and click VectorstoreIndexCreator(). It will show Vectorstore.py file in that Change the import langchain_community.embeddings.openai.OpenAIEmbeddings to from langchain_openai import OpenAIEmbeddings Now you will not see Deprecation warning

Upvotes: -1

Related Questions