Facts
The Facts resource allows you to create and manage explicit knowledge as semantic triplets (Source → Edge → Target). Unlike memories, facts are not extracted from conversations—you define them directly.
client.facts.add_triplet()POST /v1/facts/tripletCreate an explicit fact as a semantic triplet in the knowledge graph.
Parameters
group_idstrRequiredThe group ID to add the fact to.
source_namestrRequiredName of the source entity (e.g., "John").
target_namestrRequiredName of the target entity (e.g., "Acme Corp").
edge_namestrRequiredName of the relationship (e.g., "works_at").
factstrRequiredHuman-readable description of the fact.
source_labelslist[str]OptionalLabels for the source node (e.g., ["Person", "Employee"]).
target_labelslist[str]OptionalLabels for the target node (e.g., ["Company", "Organization"]).
valid_atdatetimeOptionalWhen the fact became valid. Defaults to now.
Returns
TripletResponse with:
edges: list[dict]- Created edge(s)nodes: list[dict]- Created or matched nodesget_fact_uuids()- Get edge UUIDsget_node_uuids()- Get node UUIDs
Example
1from memoair import MemoAir2from datetime import datetime34client = MemoAir()56# Create a fact7result = client.facts.add_triplet(8 group_id="user:john",9 source_name="John",10 target_name="Acme Corp",11 edge_name="works_at",12 fact="John works at Acme Corp as a senior software engineer",13 source_labels=["Person", "Employee"],14 target_labels=["Company"],15 valid_at=datetime(2024, 1, 15), # Started on this date16)1718# Get the created edge UUID19fact_uuid = result.get_fact_uuids()[0]20print(f"Created fact: {fact_uuid}")client.facts.get()GET /v1/facts/{uuid}Retrieve a specific fact by its UUID.
1fact = client.facts.get(uuid="fact-uuid-here")23print(f"Fact: {fact.fact}")4print(f"Valid: {fact.is_valid()}")5print(f"Created: {fact.created_at}")6print(f"Source: {fact.source_node.name}")7print(f"Target: {fact.target_node.name}")client.facts.update()PUT /v1/facts/{uuid}Update an existing fact's text, name, or temporal status.
Parameters
uuidstrRequiredUUID of the fact to update.
factstrOptionalUpdated fact text.
namestrOptionalUpdated edge name.
invalid_atdatetimeOptionalMark the fact as no longer valid as of this time.
expired_atdatetimeOptionalSoft-delete the fact as of this time.
attributesdictOptionalAdditional metadata attributes.
Example
1# Update the fact text2updated = client.facts.update(3 uuid="fact-uuid",4 fact="John now works at Acme Corp as a principal engineer",5)Temporal Reasoning
MemoAir tracks when facts are valid using temporal fields. This enables historical reasoning and automatic fact invalidation.
client.facts.invalidate()POST /v1/facts/{uuid}/invalidateMark a fact as no longer true. The fact remains in history but won't be returned in searches for current information.
1# John no longer works at Acme Corp2client.facts.invalidate(uuid="works-at-acme-uuid")34# The fact's invalid_at is set to now5# Searches for "where does John work?" won't return thisclient.facts.expire()POST /v1/facts/{uuid}/expireSoft-delete a fact. It remains in the database but is excluded from all queries.
1# Remove a fact (soft delete)2client.facts.expire(uuid="fact-uuid")34# The fact's expired_at is set to now5# It won't appear in any searchesclient.facts.delete()DELETE /v1/facts/{uuid}Permanently delete a fact from the knowledge graph. Use with caution.
1# Hard delete (permanent)2result = client.facts.delete(uuid="fact-uuid")34if result.success:5 print("Fact permanently deleted")Temporal Fields
| Field | Meaning | Set By |
|---|---|---|
valid_at | When the fact became true | add_triplet() or automatic |
invalid_at | When the fact stopped being true | invalidate() or update() |
expired_at | Soft-delete timestamp | expire() or update() |