cognee/docs/quickstart.md
2024-05-26 21:42:54 +02:00

1 KiB

QUICKSTART

!!! tip "To understand how cognee works check out the conceptual overview"

Setup

You will need a Weaviate instance and an OpenAI API key to use cognee. Weaviate let's you run an instance for 14 days for free. You can sign up at their website: Weaviate

You can also use Ollama or Anyscale as your LLM provider. For more info on local models check here

import os

os.environ["LLM_API_KEY"] = "YOUR_OPENAI_API_KEY"

or

cognee.config.llm_api_key = "YOUR_OPENAI_API_KEY"

Run

import cognee

text = """Natural language processing (NLP) is an interdisciplinary
       subfield of computer science and information retrieval"""

cognee.add(text) # Add a new piece of information

cognee.cognify() # Use LLMs and cognee to create knowledge

search_results = cognee.search("SIMILARITY", "computer science") # Query cognee for the knowledge

for result_text in search_results[0]:
    print(result_text)