Open anifort opened 2 months ago
added a quick PR for a fix here https://github.com/mem0ai/mem0/pull/1717
monitoring the PR for now
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
PR merge in main but there is no new release yet from mem0 - this is still active
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
this seems to be fixed in mem0 -> https://github.com/mem0ai/mem0/pull/1717
Description
Using the example from the official documentation (https://docs.crewai.com/core-concepts/Memory/#using-vertex-ai-embeddings) on how to use vertex ai embeddings with memory fails pydantic validation.
Steps to Reproduce
create a crew using the code snippet provided.
Expected behavior
complete a crew task without error
Screenshots/Code snippets
Operating System
macOS Big Sur
Python Version
3.11
crewAI Version
0.51.1
crewAI Tools Version
0.8.3
Virtual Environment
Venv
Evidence
Traceback (most recent call last): File "", line 1, in
File "/Users/userx/Projects/my_crew_prj/src/my_crew_prj/main.py", line 24, in run
res = CrewaiGcpCrew().crew().kickoff(inputs=inputs)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/crewai/project/annotations.py", line 116, in wrapper
return func(self, args, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/src/my_crew_prj/crew.py", line 54, in crew
return Crew(
^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/pydantic/main.py", line 193, in init
self.pydantic_validator.validate_python(data, self_instance=self)
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/crewai/crew.py", line 220, in create_crew_memory
self._short_term_memory = ShortTermMemory(
^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/crewai/memory/short_term/short_term_memory.py", line 17, in init__
storage = RAGStorage(
^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/crewai/memory/storage/rag_storage.py", line 76, in init__
self.app = App.from_config(config=config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/embedchain/app.py", line 394, in from_config
embedding_model = EmbedderFactory.create(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/embedchain/factory.py", line 86, in create
return embedder_class(config=embedder_config_class(config_data))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/embedchain/embedder/vertexai.py", line 14, in init
embeddings = VertexAIEmbeddings(model_name=config.model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/langchain_core/_api/deprecation.py", line 205, in warn_if_direct_instance
return wrapped(self, args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/langchain_community/embeddings/vertexai.py", line 66, in init
super().init(
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/pydantic/v1/main.py", line 339, in init
values, fields_set, validation_error = validate_model(__pydantic_self.class__, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/pydantic/v1/main.py", line 1074, in validatemodel
v, errors = field.validate(value, values, loc=field.alias, cls=cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/userx/Projects/my_crew_prj/.venv/lib/python3.11/site-packages/pydantic/v1/fields.py", line 857, in validate
raise ConfigError(
pydantic.v1.errors.ConfigError: field "client" not yet prepared so type is still a ForwardRef, you might need to call VertexAIEmbeddings.update_forward_refs().
Possible Solution
The problem seems to be in the embedchain==0.1.120 package. this package uses a depricated feature from langchain that is the route of failure. in this package and file
.venv/lib/python3.11/site-packages/embedchain/embedder/vertexai.py
needs to replace from langchain_community.embeddings import VertexAIEmbeddings with from langchain_google_vertexai import VertexAIEmbeddingsThis fixes the problem
(LangChainDeprecationWarning: The class
VertexAIEmbeddings
was deprecated in LangChain 0.0.12 and will be removed in 0.3.0. An updated version of the class exists in the langchain-google-vertexai package and should be used instead. To use it runpip install -U langchain-google-vertexai
and import asfrom langchain_google_vertexai import VertexAIEmbeddings
.)Additional context
none