Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPD5.0.3 - watsonx.ai and langchian program error - model_no_support_for function. #51

Closed
doyoungim999 opened this issue Dec 6, 2024 · 1 comment

Comments

@doyoungim999
Copy link

doyoungim999 commented Dec 6, 2024

Hello,
I am testing small python with langchain and CPD5.0.3.
It looks like embeddings is not supported langchain_ibm.
Is there any other way to run simple application with watsonx.ai ?
I am using cpd5.0.3 in my private environment.

ApiRequestFailure: Failure during generate. (POST https://cp53...../ml/v1/text/embeddings?version=2024-11-27)
Status code: 400, body: {"errors":[{"code":"model_no_support_for_function","message":"Model 'meta-llama/llama-3-1-8b-instruct' does not support function 'function_embedding'","more_info":"https://cloud.ibm.com/apidocs/watsonx-ai-cp"}],"trace":"0f9f152b-19d7-4165-bcc1-7ad75fa35e4e","status_code":400}


from langchain_core.vectorstores import InMemoryVectorStore

text = "LangChain is the framework for building context-aware reasoning applications"

vectorstore = InMemoryVectorStore(embeddings)

from langchain_core.documents import Document
document_1 = Document(id="1", page_content="foo", metadata={"baz": "bar"})
document_2 = Document(id="2", page_content="thud", metadata={"bar": "baz"})
document_3 = Document(id="3", page_content="i will be deleted :(")

documents = [document_1, document_2, document_3]
vectorstore.add_documents(documents=documents)

#vectorstore = InMemoryVectorStore.from_texts(

[text],

embedding=embeddings,

#)

Use the vectorstore as a retriever

retriever = vectorstore.as_retriever()

Retrieve the most similar text

retrieved_documents = retriever.invoke("What is LangChain?")

show the retrieved document's content

retrieved_documents[0].page_content

@Rafal-Chrzanowski-IBM
Copy link
Member

Greetings, sorry for the delayed response.

Generational models, like meta-llama/llama-3-1-8b-instruct, do not support function embedding.
You can find a list of currently supported embedding models using commands mentioned in the documentation:
https://ibm.github.io/watsonx-ai-python-sdk/fm_embeddings.html#EmbeddingModels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants