remember(), one question comes back answered with recall(), and nothing else is configured.
Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured β the answer is generated by a language model
- Read Remember and Recall for what the two operations do
- No data is required up front β the script ingests its own passage, but it starts with
cognee.forget(everything=True), which wipes all existing Cognee data; run it against a setup you can afford to reset
Code in Action
What Just Happened
Step 1: Start From a Clean Slate
forget(everything=True) deletes every dataset, graph node, embedding, and session-cache entry the current user owns, so the run starts with an empty graph and the answer can only come from the passage below. Leave this line out of your own application β you rarely want to erase everything before storing something new.
Step 2: Remember the Passage
remember() takes raw text and runs the full ingestion workflow on it: the passage is chunked, entities and relationships are extracted, and the result is written to the graph as memory. self_improvement=False keeps the run to plain ingestion instead of also running improve().
Step 3: Recall an Answer
SearchType.GRAPH_COMPLETION retrieves the graph triplets relevant to query_text, builds a context from them, and asks a language model to answer from that context. recall() returns a list, so the loop prints each result β with this small a graph, expect a single answer describing NLP.
Step 4: Run the Script Quietly
main() runs under asyncio.run(). setup_logging(log_level=ERROR) keeps Cogneeβs own progress logging out of the way, leaving only the printed answer β and any real error β in the output.
Remember
Every way to get data into Cognee memory, and what each option changes.
Recall
Understand recall()βs full parameter surface and auto-routing behavior.
Inspecting Graph Completion Context
See the triplets GRAPH_COMPLETION retrieved before it answered.