langchain-ai / langchain-postgres

LangChain abstractions backed by Postgres Backend
MIT License
125 stars 47 forks source link

ValidationError: 1 validation error for Document metadata Input should be a valid dictionary #118

Open arthberman opened 1 month ago

arthberman commented 1 month ago

Since LangChain 0.3 and within LangGraph Studio container, have the following error : ValidationError: 1 validation error for Document metadata Input should be a valid dictionary [type=dict_type, input_value=Fragment(buf=b'{"name": "...name"}'), input_type=Fragment] For further information visit https://errors.pydantic.dev/2.9/v/dict_type When running the following query :

results = self.vector_store.similarity_search(
            query=name,
            k=1,
            filter={"id": {"$eq": id}, "name": {"$eq": name}},
)

It happens when running vector_store.similarity_search query with metadata filters. Seems to be linked to switch to Pydantic V2?

arthberman commented 1 month ago

pyproject.toml

`[project] name = "" version = "0.0.1" description = "Add your description here" readme = "README.md" requires-python = ">=3.12" dependencies = [ "python-dotenv>=1.0.1", "langchain>=0.3.0", "langchain-community>=0.3.0", "langchainhub>=0.1.21", "langchain-anthropic>=0.2.1", "langchain-groq>=0.2.0", "langchain-core>=0.3.1", "langgraph>=0.2.22", "langchain-openai>=0.2.0", "pydantic>=2.9.2", "temporalio>=1.7.1", "toml>=0.10.2", "packaging>=24.1", "ipykernel>=6.29.5", "langgraph-checkpoint-postgres>=1.0.7", "langgraph-sdk>=0.1.30", "langchain-postgres>=0.0.12", "psycopg2-binary>=2.9.9", ]

[build-system] requires = ["hatchling"] build-backend = "hatchling.build"

[tool.uv] dev-dependencies = ["ipykernel>=6.29.5"]

[tool.hatch.build.targets.wheel] packages = ["src/app", "src/parser", "src/utils"] `