-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Bug Description
I get a validation error when running the quickstart_neo4j on the ExtractedEntities
pydantic model.
I am using deepseek-r1:7b
.
LLM response is the following:
'{"$defs": {"ExtractedEntity": {"properties": {"name": {"description": "Name of the extracted entity", "title": "Name", "type": "string"}, "entity_type_id": {"description": "ID of the classified entity type. Must be one of the provided entity_type_id integers.", "title": "Entity Type Id", "type": "integer"}}, "required": ["name", "entity_type_id"], "title": "ExtractedEntity", "type": "object"}}, "properties": {"extracted_entities": {"description": "List of extracted entities", "items": {"$ref": "#/$defs/ExtractedEntity"}, "title": "Extracted Entities", "type": "array"}}, "required": ["extracted_entities"], "title": "ExtractedEntities", "type": "object"}'
that throws the following error:
Field required [type=missing, input_value={'$def': {'ExtractedEntit... 'entity_type_id': 0}]}}, input_type=dict]
Steps to Reproduce
Provide a minimal code example that reproduces the issue:
from datetime import datetime
from graphiti_core import Graphiti
from graphiti_core.nodes import EpisodeType
from graphiti_core.search.search_config_recipes import NODE_HYBRID_SEARCH_RRF
from graphiti_core.llm_client import LLMConfig
from graphiti_core.embedder.openai import OpenAIEmbedder, OpenAIEmbedderConfig
from graphiti_core.cross_encoder.openai_reranker_client import OpenAIRerankerClient
from graphiti_core.llm_client.openai_generic_client import OpenAIGenericClient
# Configure Ollama LLM client
llm_config = LLMConfig(
api_key="ollama", # Ollama doesn't require a real API key, but some placeholder is needed
model="deepseek-r1:7b",
small_model="deepseek-r1:7b",
base_url="http://localhost:11434/v1", # Ollama's OpenAI-compatible endpoint
)
llm_client = OpenAIGenericClient(config=llm_config)
# Initialize Graphiti with Ollama clients
graphiti = Graphiti(
"bolt://localhost:7687",
"neo4j",
"your_password",
llm_client=llm_client,
embedder=OpenAIEmbedder(
config=OpenAIEmbedderConfig(
api_key="ollama", # Placeholder API key
embedding_model="bge-m3",
embedding_dim=1024,
base_url="http://localhost:11434/v1",
)
),
cross_encoder=OpenAIRerankerClient(client=llm_client, config=llm_config),
)
async def main():
# Initialize the graph database with graphiti's indices. This only needs to be done once.
await graphiti.build_indices_and_constraints()
await graphiti.add_episode(
name="tech_innovation_article",
episode_body=(
"MIT researchers have unveiled 'ClimateNet', an AI system capable of predicting "
"climate patterns with unprecedented accuracy. Early tests show it can forecast "
"major weather events up to three weeks in advance, potentially revolutionizing "
"disaster preparedness and agricultural planning."
),
source=EpisodeType.text,
# A description of the source (e.g., "podcast", "news article")
source_description="Technology magazine article",
# The timestamp for when this episode occurred or was created
reference_time=datetime(2023, 11, 15, 9, 30),
)
Expected Behavior
A clear and concise description of what you expected to happen.
Actual Behavior
A clear and concise description of what actually happened.
Environment
- Graphiti Version: 0.20.4
- Python Version: 3.12.11
- Operating System: MacOS 15.6.1
- Database Backend: Neo4j 5.26
- LLM Provider & Model: deepseek-r1:7b
Installation Method
- pip install
- uv add
- Development installation (git clone)
Error Messages/Traceback
2025-09-17 08:53:25 - httpx - INFO - HTTP Request: POST http://localhost:11434/v1/chat/completions "HTTP/1.1 200 OK"
Connection closed
Traceback (most recent call last):
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/scripts/quickstart_neo4j_azure.py", line 327, in <module>
asyncio.run(main())
File "/Users/xxx/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 195, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/xxx/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 691, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/scripts/quickstart_neo4j_azure.py", line 202, in main
await graphiti.add_episode(
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/.venv/lib/python3.12/site-packages/graphiti_core/graphiti.py", line 587, in add_episode
raise e
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/.venv/lib/python3.12/site-packages/graphiti_core/graphiti.py", line 503, in add_episode
extracted_nodes = await extract_nodes(
^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/.venv/lib/python3.12/site-packages/graphiti_core/utils/maintenance/node_operations.py", line 129, in extract_nodes
response_object = ExtractedEntities(**llm_response)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/xxx/projects/xxx/monorepo/apps/backend/ai/agents/xxx-troubleshooting/.venv/lib/python3.12/site-packages/pydantic/main.py", line 253, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ExtractedEntities
extracted_entities
Field required [type=missing, input_value={'$def': {'ExtractedEntit... 'entity_type_id': 0}]}}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.11/v/missing
Configuration
# Relevant configuration or initialization code
Additional Context
- Does this happen consistently or intermittently?
- Which component are you using? (core library, REST server, MCP server)
- Any recent changes to your environment?
- Related issues or similar problems you've encountered?