QUICKSTART¶
To understand how cognee works check out the conceptual overview
Setup¶
To run cognee, you will need the following:
- OpenAI API key (Ollama or Anyscale could work as well)
Add your LLM API key to the environment variables
or If you are using Networkx, create an account on Graphistry to visualize results:If you want to run Postgres instead of Sqlite, run postgres Docker container. Navigate to cognee folder and run:
Add the following environment variables to .env file
DB_HOST=127.0.0.1
DB_PORT=5432
DB_USERNAME=cognee # or any username you want
DB_PASSWORD=cognee # or any password you want
DB_NAME=cognee_db # or any db name you want
DB_PROVIDER=postgres
Run¶
cognee is asynchronous by design, meaning that operations like adding information, processing it, and querying it can run concurrently without blocking the execution of other tasks. Make sure to await the results of the functions that you call.
import cognee
text = """Natural language processing (NLP) is an interdisciplinary
subfield of computer science and information retrieval"""
await cognee.add(text) # Add a new piece of information
await cognee.cognify() # Use LLMs and cognee to create knowledge
search_results = await cognee.search("INSIGHTS", {'query': 'Tell me about NLP'}) # Query cognee for the knowledge
for result_text in search_results:
print(result_text)
In the example above, we add a piece of information to cognee, use LLMs to create a GraphRAG, and then query cognee for the knowledge. cognee is composable and you can build your own cognee pipelines using our templates.