add_data_points
.
Before you start:
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Have some structured data you want to model
What Custom Data Models Do
- Define your own Pydantic models that inherit from
DataPoint
- Insert structured data directly into the knowledge graph without
cognify
- Create relationships between data points programmatically
- Control exactly what gets indexed and how
Full Working Example
This example shows the complete workflow with metadata for indexing and optional edge weights. In practice, you can create complex nested models with multiple relationships and sophisticated data structures.
What Just Happened
Step 1: Define Your Data Model
DataPoint
. Use SkipValidation[Any]
for fields that will hold other DataPoints to avoid forward reference issues. Metadata is recommended - it tells Cognee which fields to embed and store in the vector database for search.
Step 2: Create Data Instances
Step 3: Create Relationships
Edge
to add weights, custom relationship types, or other metadata to your relationships.
Step 4: Insert into Graph
name
field gets embedded and stored in the vector database for search.
Use in Custom Tasks and Pipelines
This approach is particularly useful when creating custom tasks and pipelines where you need to:- Insert structured data programmatically
- Define specific relationships between known entities
- Control exactly what gets indexed and how
- Integrate with external data sources or APIs
cognify
to extract knowledge from unstructured text, then add your own structured data on top.