Knowledge Graph
client.graph provides access to the knowledge graph automatically built from your memories. Entities — people, organizations, places, and things — are extracted from memories and linked by their relationships. You can search for entities, traverse their connections, or ask natural language questions answered from the graph.
graph.search
Searches for entities in the knowledge graph by text. Returns entities ranked by relevance.
Signature
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Text query to search for entities |
userId | string | No | Restrict search to entities linked to a specific user |
type | EntityType | No | Filter by entity type: PERSON, ORGANIZATION, PLACE, or THING |
limit | number | No | Maximum results to return (default 10) |
Example
Example — searching for organizations
graph.traverse
Traverses relationships outward from a known entity. Returns the paths connecting the entity to others within the specified number of hops.
Use graph.search first if you need to find the entityId for an entity.
Signature
| Parameter | Type | Required | Description |
|---|---|---|---|
entityId | string | Yes | ID of the entity to start traversal from |
direction | string | No | outgoing, incoming, or both (default both) |
hops | number | No | Depth of traversal: 1, 2, or 3 (default 2) |
Example
Example — finding who else works at the same company
graph.query
Answers a natural language question using the knowledge graph. The question is interpreted, relevant entities and relationships are retrieved, and a natural language answer is generated with a confidence score.
Signature
| Parameter | Type | Required | Description |
|---|---|---|---|
question | string | Yes | Natural language question about the knowledge graph |
Example
Example — relational questions
A low confidence score (below 0.5) means the graph does not have enough information to answer reliably. In that case, try searching memories directly with client.memories.search.
When to use each method
| Question | Recommended method |
|---|---|
| "Who is João Silva?" | graph.search with type: 'PERSON' |
| "What is João connected to?" | graph.traverse from João's entity ID |
| "What projects is João working on?" | graph.query with a natural language question |
| "Who works at Acme Corp?" | graph.traverse from Acme's entity ID, direction: 'incoming' |
| "What tools does the team use?" | graph.search with type: 'THING' |
Related
- Memories — create memories that populate the graph
- Knowledge — structured knowledge derived from memories
- Type Reference —
Entity,TraversalResult,GraphQueryResult, and related types