### Fastest Package Setup Guide Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill This section outlines the recommended path for new users with an OpenAI API key for the fastest package setup. ```markdown ## Fastest package setup Use this path for most first-time users with an OpenAI API key: ``` -------------------------------- ### Install LLM Quickstart Skill (Development Mode) Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill Use this command to install the LLM Quickstart Skill in development mode. This is useful when making changes to the package itself. ```bash uv pip install -e "[dev]" ``` -------------------------------- ### Install Dependencies Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill Install the necessary Python packages for the LLM Quickstart Skill. Ensure you are in the project directory. ```bash pip install -r requirements.txt ``` -------------------------------- ### Full Example Setup and Agent Definitions Source: https://docs.cognee.ai/guides/agent-memory-quickstart Combines the shared setup, support agent, and FAQ bot definitions into a single script for a complete demonstration of agent memory configurations. ```python import asyncio import os import warnings os.environ["LOG_LEVEL"] = "ERROR" os.environ["COGNEE_LOG_FILE"] = "false" warnings.filterwarnings("ignore") import cognee # noqa: E402 from cognee.infrastructure.llm.LLMGateway import LLMGateway # noqa: E402 SESSION_ID = "ticket_001" BUG = "Login fails with error XQ-99." FIX = "Set XQ_TOKEN=1 in the .env file." NO_INFO = "NO INFO AVAILABLE" async def setup() -> None: await cognee.forget(everything=True) await cognee.remember( ["Our app is a web service. Users log in to access their account."], self_improvement=False ) async def ask_llm(question: str, system_prompt: str) -> str: return await LLMGateway.acreate_structured_output( text_input=question, system_prompt=system_prompt, response_model=str, ) @cognee.agent_memory( with_memory=False, with_session_memory=True, save_session_traces=True, session_id=SESSION_ID, session_memory_last_n=2, persist_session_trace_after=3, ) async def support_agent(question: str, system_prompt: str) -> str: return await ask_llm(question, system_prompt) @cognee.agent_memory( with_memory=True, with_session_memory=False, save_session_traces=False, memory_query_from_method="question", ) async def faq_bot(question: str, system_prompt: str) -> str: return await ask_llm(question, system_prompt) async def main() -> None: print("=== Agent Memory Quickstart ===\n") ``` -------------------------------- ### Full Quickstart Example with Improvement Source: https://docs.cognee.ai/guides/memify-quickstart Demonstrates remembering facts, improving the dataset with session memory, and recalling before and after improvement. ```python import asyncio import cognee DATASET = "demo_dataset" SESSION = "demo_session" async def main(): await cognee.forget(everything=True) await cognee.remember( "Einstein developed general relativity.", dataset_name=DATASET, self_improvement=False, ) await cognee.remember( "Niels Bohr worked on atomic structure.", dataset_name=DATASET, session_id=SESSION, self_improvement=False, ) answer_before_improve = await cognee.recall( "What did Bohr work on?", datasets=[DATASET], ) await cognee.improve(dataset=DATASET, session_ids=[SESSION]) answer_after_improve = await cognee.recall( "What did Bohr work on?", datasets=[DATASET], ) print("Before improve:", answer_before_improve) print("After improve:", answer_after_improve) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Local Setup Guide Link Source: https://docs.cognee.ai/setup-configuration/overview Provides a link to the Local Setup guide for running Cognee without a cloud API key, using Ollama and Fastembed. ```text "Want to run Cognee without a cloud API key? See the Local Setup guide for step-by-step instructions using Ollama and Fastembed." ``` -------------------------------- ### Start Redis Server Source: https://docs.cognee.ai/llms-full.txt Instructions for starting a Redis server, either via Docker or a local installation, to be used with the Redis cache adapter. ```bash # Using Docker docker run -d -p 6379:6379 redis:latest # Or using local installation redis-server ``` -------------------------------- ### Start Qdrant Service with Docker Source: https://docs.cognee.ai/setup-configuration/vector-stores Use Docker to start a Qdrant service. This is a basic command to get Qdrant running. ```shellscript docker run -d -p 6333:6333 -v $(pwd)/qdrant_storage:/qdrant/storage qdrant/qdrant ``` -------------------------------- ### LLM Quickstart Skill Recommendation Source: https://docs.cognee.ai/getting-started/installation If using an LLM for setup, it's recommended to copy the LLM Quickstart Skill first. This ensures the assistant checks Python versions, provider settings, and performs the first smoke test correctly. ```text Using Claude Code or another LLM to set up Cognee? Copy the LLM Quickstart Skill first so the assistant checks Python versions, provider settings, extras, and the first smoke test in the right order. ``` -------------------------------- ### Python LLM Quickstart Skill Example Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill This Python code snippet shows how to import the necessary libraries and use the Cognee quickstart skill to manage LLM memory. It includes examples of forgetting all information, remembering a specific piece of text, and recalling information based on a query. ```python import asyncio import cognee async def main(): await cognee.forget(everything=True) await cognee.remember("Cognee turns documents into AI memory.") results = await cognee.recall(query_text="What does Cognee do?") for result in results: ``` -------------------------------- ### Setup Cognee Locally with Python Source: https://docs.cognee.ai/guides/deploy-rest-api-server This snippet shows the initial setup for running Cognee locally. It involves copying the environment template and then starting the server. ```shellscript # Copy environment template cp .env.template .env # Start API server python -m cognee.server ``` -------------------------------- ### Run llama.cpp Server Source: https://docs.cognee.ai/setup-configuration/llm-providers Example command to start a local llama.cpp server. Ensure you have the llama.cpp binary and a model file. ```bash llama_cpp.server --model /path/to/your/model.gguf --port 8000 ``` -------------------------------- ### Basic Ontology Demo Script Link Source: https://docs.cognee.ai/guides/ontology-support Provides a link to the basic ontology demo script for a quickstart guide. This script helps you get started with ontology features. ```markdown Basic ontology demo script can be found on the following [link](https://github.com/topoteretes/cognee/blob/dev/examples/guides/ontology_quickstart.py) ``` -------------------------------- ### Example: Full Application Startup with Migrations Source: https://docs.cognee.ai/llms-full.txt Demonstrates how to apply migrations and then proceed with normal Cognee operations like adding data and cognifying. Ensure migrations are run before other operations. ```python import asyncio import cognee async def main(): # Apply all pending schema migrations before starting await cognee.run_startup_migrations() # Normal usage await cognee.add("Hello, world!", dataset_name="demo") await cognee.cognify() asyncio.run(main()) ``` -------------------------------- ### 401 Unauthorized - Local Authentication Setup Source: https://docs.cognee.ai/api-reference/introduction This example shows how to obtain a Bearer token for local authentication. Refer to the deployment guide for detailed setup. ```bash POST /api/v1/auth/login { "username": "user", "password": "password" } ``` -------------------------------- ### Full Example: Custom Graph Model Guide Source: https://docs.cognee.ai/guides/custom-graph-model A comprehensive example demonstrating the setup and usage of custom graph models for advanced data extraction and analysis within Cognee. ```python import from cognee.api.llm.graph_model import GraphModel from cognee.api.llm.prompt import Prompt from cognee.api.llm.tasks import ingest, visualize_data # Define a custom graph model for specific entities and relationships class CustomGraphModel(GraphModel): def __init__(self): super().__init__( entities=["Person", "Company", "Product"], relationships=["works_at", "produces", "acquires"] ) # Define a custom prompt to guide the LLM on desired relationships CUSTOM_PROMPT = Prompt( "Extract information about people, companies, and products. Identify who works at which company, what products companies produce, and which companies acquire others." ) async def main(): # Example text to ingest text = "John Doe works at Acme Corporation, which produces the "Rocket" widget. Acme Corporation recently acquired Beta Inc." # Ingest the text and build the graph using the custom model and prompt result = await ingest( text=text, graph_model=CustomGraphModel, custom_prompt=CUSTOM_PROMPT ) # Visualize the generated graph await visualize_data() # Print the extracted graph data (optional) print(result) if __name__ == "__main__": import asyncio asyncio.run(main()) ``` -------------------------------- ### Python Example for Dataset Status Source: https://docs.cognee.ai/core-concepts/main-operations/remember Use this Python snippet to get the status of a dataset. Ensure you have the Cognee client library installed. ```python from cognee.api.client import CogneeClient client = CogneeClient() # Get status for a single dataset status = client.datasets.get_status(dataset_uuid='your-dataset-uuid') print(status) # Get status for multiple datasets statuses = client.datasets.get_status(dataset_uuids=['uuid1', 'uuid2']) print(statuses) ``` -------------------------------- ### Quickstart with Docker Source: https://docs.cognee.ai/cognee-cloud/quickstart This section details how to quickly set up Cognee MCP using Docker. ```APIDOC ## Quickstart with Docker ### Description Get Cognee MCP running in minutes with Docker. ### Method Not specified, likely involves running Docker commands. ### Endpoint Not applicable. ### Parameters Not specified. ### Request Example Not specified. ### Response Not specified. ``` -------------------------------- ### Environment Variable for LLM API Key Source: https://docs.cognee.ai/setup-configuration/structured-output-backends Example of setting the BAML_LLM_API_KEY environment variable. Refer to the Local Setup guide for complete Ollama configuration. ```javascript import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const { useMDXComponents: _provideComponents } = arguments[0]; function _createMdxContent(props) { const _components = { a: "a", code: "code", li: "li", p: "p", pre: "pre", span: "span", strong: "strong", ul: "ul", ..._provideComponents(), ...props.components }, { Accordion, Card, CodeBlock, Columns, Heading, Info, Tab, Tabs, Warning } = _components; if (!Accordion) _missingMdxReference("Accordion", true); if (!Card) _missingMdxReference("Card", true); if (!CodeBlock) _missingMdxReference("CodeBlock", true); if (!Columns) _missingMdxReference("Columns", true); if (!Heading) _missingMdxReference("Heading", true); if (!Info) _missingMdxReference("Info", true); if (!Tab) _missingMdxReference("Tab", true); if (!Tabs) _missingMdxReference("Tabs", true); if (!Warning) _missingMdxReference("Warning", true); return _jsxs(_Fragment, { children: [ _jsx(_components.p, { children: "Structured output backends ensure reliable data extraction from LLM responses. Cognee supports two frameworks that convert LLM text into structured Pydantic models for knowledge graph extraction and other tasks." }), "\n", _jsxs(Info, { children: [ _jsx(_components.p, { children: _jsx(_components.strong, { children: "New to configuration?" }) }), _jsxs(_components.p, { children: ["See the ", _jsx(_components.a, { href: "./overview", children: "Setup Configuration Overview" }), " for the complete workflow:"] }) ] }), "\n", _jsxs(_components.p, { children: [ "\n", _jsxs(_components.span, { className: "line", children: [ _jsx(_components.span, { style: { color: "#953800", "--shiki-dark": "#9CDCFE" }, children: "BAML_LLM_API_KEY" }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#D4D4D4" }, children: "=" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "sk-..." }) ] }), "\n" ] }), _jsxs(_components.p, { children: ["See the ", _jsx(_components.a, { href: "/guides/local-setup", children: "Local Setup guide" }), " for a complete Ollama configuration including embeddings."] }) ] }); } function MDXContent(props = {}) { const { wrapper: MDXLayout } = { ..._provideComponents(), ...props.components }; return MDXLayout ? _jsx(MDXLayout, { ...props, children: _jsx(_createMdxContent, { ...props }) }) : _createMdxContent(props); } return { default: MDXContent }; function _missingMdxReference(id, component) { throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it."); } ``` -------------------------------- ### LLM Quickstart Skill Setup Checks Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill This code snippet defines the criteria for confirming a successful LLM setup for Cognee. It checks for the correct Python interpreter, successful Cognee import, presence of a .env file, LLM/embedding configuration, a functional smoke test, and matching installed extras. ```javascript function _createMdxContent(props) { return _jsx(MDXContent, { ... children: _jsxs(_components.wrapper, { children: [ _jsx(_components.h1, { children: "LLM Quickstart Skill" }), _jsx(_components.p, { children: "Copy a Claude-compatible skill that helps an LLM install Cognee, configure dependencies, and run a first smoke test." }), _jsx(_components.hr, {}), _jsx(_components.h2, { children: "OSS" }), _jsx(_components.p, { children: "mponents.span, {\n className: \"line\"\n }), \"\\n\", _jsx(_components.span, { className: \"line\", children: _jsx(_components.span, { style: { color: \"#0550AE\", "--shiki-light-font-weight": \"bold\", "--shiki-dark": \"#569CD6\", "--shiki-dark-font-weight": \"bold" }, children: \"## Finish criteria\" }) }), \"\\n\", _jsx(_components.components.span, { className: \"line\" }), \"\\n\", _jsx(_components.span, { className: \"line\", children: _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \"Before saying the setup is done, confirm:\" }) }), \"\\n\", _jsx(_components.span, { className: \"line\" }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" The intended Python interpreter is active.\" }) ] }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#0550AE\", "--shiki-dark": \"#CE9178\" }, children: \" `import cognee`" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" succeeds.\" }) ] }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#0550AE\", "--shiki-dark": \"#CE9178\" }, children: \" `.env`" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" is in the project root.\" }) ] }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" LLM and embedding configuration are both explicit unless the user is using OpenAI defaults.\" }) ] }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" The smoke test stores text and recalls an answer.\" }) ] }), \"\\n\", _jsxs(_components.span, { className: \"line\", children: [ _jsx(_components.span, { style: { color: \"#953800\", "--shiki-dark": \"#6796E6\" }, children: \"-" }), _jsx(_components.span, { style: { color: \"#1F2328\", "--shiki-dark": \"#D4D4D4\" }, children: \" Any installed extras match the feature the user is actually trying to use.\" }) ] }), \"\\n\" ] }) }) ] }) }); } function MDXContent(props = {}) { const {wrapper: MDXLayout} = { ..._provideComponents(), ...props.components }; return MDXLayout ? _jsx(MDXLayout, { ...props, children: _jsx(_createMdxContent, { ...props }) }) : _createMdxContent(props); } return { default: MDXContent }; function _missingMdxReference(id, component) { throw new Error("Expected " + (component ? "component" : "object") + " `" + id + "` to be defined: you likely forgot to import, pass, or provide it."); } ``` -------------------------------- ### Full Example: Local Cognee UI Setup Source: https://docs.cognee.ai/cognee-cloud/local-ui A complete script combining data addition, knowledge graph building, and UI server launch. Press Ctrl+C to stop the server. ```python import asyncio import time import cognee async def main(): # Add sample data await cognee.add( "Natural language processing (NLP) is an interdisciplinary subfield of computer science and information retrieval." ) await cognee.add( "Machine learning (ML) is a subset of artificial intelligence that focuses on algorithms and statistical models." ) # Build the knowledge graph await cognee.cognify() # Start the UI server = cognee.start_ui( port=3000, open_browser=True, ) if server: print("UI available at http://localhost:3000") print("Press Ctrl+C to stop...") try: while server.poll() is None: time.sleep(1) except KeyboardInterrupt: server.terminate() server.wait() else: print("Failed to start the UI server.") if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Running the LLM Quickstart Skill Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill Execute the LLM Quickstart Skill with a sample input. This command initiates the skill's process. ```bash python main.py --input "What is the capital of France?" ``` -------------------------------- ### Install Provider-Specific Extras Source: https://docs.cognee.ai/getting-started/installation Install Cognee and add provider-specific extras as needed. For example, to install extras for a specific provider. ```shellscript pip install "cognee[provider-name]" ``` -------------------------------- ### Fastest Package Setup Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill This is the recommended setup path for most first-time users with an OpenAI API key. ```bash ```bash ``` -------------------------------- ### Qdrant Initialization Example Source: https://docs.cognee.ai/setup-configuration/community-maintained/qdrant This snippet demonstrates how to initialize the Qdrant client with basic configuration. Ensure you have the necessary Qdrant client library installed. ```javascript import { Qdrant } from "@cognee/vector-stores"; const qdrant = new Qdrant({ url: "http://localhost:6333", apiKey: "YOUR_API_KEY", }); ``` -------------------------------- ### Install Cognee Source: https://docs.cognee.ai/llms-full.txt Install the Cognee library with a specific version. This ensures compatibility with the integration setup. ```bash pip install cognee==0.2.0 ``` -------------------------------- ### Default Setup Recommendation Source: https://docs.cognee.ai/getting-started/llm-quickstart-skill If the user's path is unclear, the default recommendation is to install the package in a fresh virtual environment using OpenAI defaults. ```text If the path is unclear, ask one short question. Otherwise make the conservative default: package install in a fresh virtual environment using OpenAI defaults. ``` -------------------------------- ### Create Tenant and Add Users Source: https://docs.cognee.ai/llms-full.txt Demonstrates the initial setup of a tenant and adding users to it. Ensure users are refreshed to obtain their tenant ID before adding them to a tenant. ```python await create_tenant("acme_corp", user1.id) # Refresh user1 to get tenant_id user1 = await get_user(user1.id) await add_user_to_tenant(user2.id, user1.tenant_id, user1.id) ``` -------------------------------- ### Install Cognee with Extras Source: https://docs.cognee.ai/llms-full.txt Install Cognee with specific extras for additional functionality. For example, to include PostgreSQL support, use `uv pip install "cognee[postgres]"`. ```bash uv pip install "cognee[extra1,extra2]" ``` ```bash uv pip install "cognee[postgres]" ``` ```bash uv pip install "cognee[neo4j,aws]" ``` ```bash uv pip install "cognee[distributed]" ``` ```bash uv pip install "cognee[codegraph]" ``` ```bash uv pip install "cognee[monitoring]" ``` ```bash uv pip install "cognee[scraping,docs]" ``` ```bash uv pip install "cognee[baml]" ``` ```bash uv pip install "cognee[anthropic]" ``` -------------------------------- ### Legacy Memify Quickstart Source: https://docs.cognee.ai/guides/memify-quickstart This is a legacy guide for using Memify, demonstrating the import of necessary modules and the basic structure for running the main function. It includes imports for asyncio and cognee, along with SearchType. ```python import asyncio import cognee from cognee.modules.search.types import SearchType async def main(): pass ``` -------------------------------- ### Install Ollama and Pull LLM Model Source: https://docs.cognee.ai/guides/local-setup Prerequisite step to install Ollama and download a language model before proceeding with local setup. ```shell ollama pull llama3 ``` -------------------------------- ### Setup Python Local Environment Source: https://docs.cognee.ai/llms-full.txt Create a virtual environment using 'uv' and activate it. Then, install Cognee with all extras using 'uv sync'. ```bash uv venv && source .venv/bin/activate uv sync --all-extras ``` -------------------------------- ### Python Agent Memory Quickstart Source: https://docs.cognee.ai/guides/agent-memory-quickstart This snippet demonstrates initializing an agent with memory and performing a query. It shows how to set up the agent and interact with it to retrieve information. ```python from cognee.agent import Agent from cognee.agent.memory import Memory agent = Agent(memory=Memory()) # Example of a query to the agent query = "What is the capital of France?" response = agent.query(query) print(response) ``` -------------------------------- ### Install Redis on Ubuntu Source: https://docs.cognee.ai/setup-configuration/community-maintained/redis Installs the Redis server package on Ubuntu systems using apt. This is a common starting point for many projects. ```bash sudo apt update sudo apt install redis-server ``` -------------------------------- ### Complete Permission Setup Workflow Source: https://docs.cognee.ai/llms-full.txt Demonstrates a full permission setup scenario, including creating users, a tenant, adding users to the tenant, creating a dataset, and granting permissions. ```python from cognee.modules.users.methods import create_user, get_user from cognee.modules.users.tenants.methods import create_tenant, add_user_to_tenant from cognee.modules.data.methods import create_authorized_dataset from cognee.modules.users.permissions.methods import give_permission_on_dataset # 1. Create users user1 = await create_user("alice@company.com", "password123", is_superuser=True) user2 = await create_user("bob@company.com", "password456") ``` -------------------------------- ### Kuzu (Default) Setup Guide Source: https://docs.cognee.ai/setup-configuration/graph-stores Kuzu is a file-based graph database suitable for local development and single-user scenarios. No network setup is required. ```dotenv GRAPH_DATABASE_PROVIDER=kuzu GRAPH_DATABASE_URL=./my_graph.kuzu ``` -------------------------------- ### Server Startup and UI Availability Source: https://docs.cognee.ai/cognee-cloud/local-ui This snippet demonstrates how to start the server and print the UI availability URL. It includes basic server logic and error handling for KeyboardInterrupt. ```python components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: "if" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " server:" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#DCDCAA" }, children: " print" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: "(" }), _jsx(_components.span, { style: { color: "#0A3069", "--shiki-dark": "#CE9178" }, children: "\"UI available at http://localhost:3000\"" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ")" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: " try" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ":" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: " while" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " server.poll() " }), _jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#569CD6" }, children: "is" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#569CD6" }, children: " None" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ":" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " time.sleep(" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#B5CEA8" }, children: "1" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ")" })] }), "\n", _jsxs(_components.span, { className: "line", children: [_jsx(_components.span, { style: { color: "#CF222E", "--shiki-dark": "#C586C0" }, children: " except" }), _jsx(_components.span, { style: { color: "#0550AE", "--shiki-dark": "#4EC9B0" }, children: " KeyboardInterrupt" }), _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: ":" })] }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " server.terminate()" }) }), "\n", _jsx(_components.span, { className: "line", children: _jsx(_components.span, { style: { color: "#1F2328", "--shiki-dark": "#D4D4D4" }, children: " server.wait()" }) }), "\n"] }), _jsxs(_components.p, { children: ["The UI is available at ", _jsx(_components.strong, { children: _jsx(_components.a, { href: "http://localhost:3000", children: "http://localhost:3000" }) }), ". Press ", _jsx(_components.code, { children: "Ctrl+C" }), " to stop the server when you are done."] })] }) ``` -------------------------------- ### Install Redis Source: https://docs.cognee.ai/setup-configuration/community-maintained/redis Install Redis using a package manager like apt for Debian/Ubuntu systems. Ensure the Redis service is running and enabled to start on boot. ```bash sudo apt update sudo apt install redis-server sudo systemctl status redis-server sudo systemctl enable redis-server ``` -------------------------------- ### Install Groq Provider SDK Source: https://docs.cognee.ai/getting-started/installation Installs the 'groq' extra for using Groq-hosted inference. Ensure environment variables are set. ```bash groq>=0.8.0,<1.0.0 ``` -------------------------------- ### Qdrant Client with API Key Example Source: https://docs.cognee.ai/setup-configuration/community-maintained/qdrant Example of initializing the Qdrant client when an API key is required for authentication. Replace 'YOUR_API_KEY' with your actual Qdrant API key. ```javascript const qdrant = new Qdrant({ url: "http://localhost:6333", apiKey: "YOUR_API_KEY", }); ``` -------------------------------- ### Get Cognee Log File Location Source: https://docs.cognee.ai/llms-full.txt Run this snippet after importing cognee to get the exact path to the log file. Ensure the cognee library is installed. ```python from cognee.shared.logging_utils import get_log_file_location print(get_log_file_location()) ``` -------------------------------- ### Full Example Script Source: https://docs.cognee.ai/cognee-cloud/local-ui This is the complete Python script combining all steps for running the local UI server. It includes imports, server setup, and execution logic. ```python import time import sys from cognee.modules.shared.utils.server import Server def main(): server = Server() server.start() print(f"UI available at http://localhost:3000") try: while server.poll() is None: time.sleep(1) except KeyboardInterrupt: server.terminate() server.wait() if __name__ == "__main__": main() ``` -------------------------------- ### Install Cognee Debugging Tools Source: https://docs.cognee.ai/getting-started/installation Install the 'debug' extra, which includes 'debugpy', to enable remote debugging of running Cognee processes, for example, with VS Code. ```bash debugpy>=1.8.9,<2.0.0 ``` -------------------------------- ### Complete Permission Setup Source: https://docs.cognee.ai/guides/permission-snippets Sets up a complete permission scenario from scratch, demonstrating the full workflow for user and permission management. ```python from cognee.modules.users.methods import create_user, get_user from cognee.modules.users.tenants.methods import create_tenant, get_tenant from cognee.modules.users.permissions.methods import create_permission, get_all_user_permission_datasets # Create a tenant tenant = await create_tenant(name="My Tenant") # Create a user within the tenant user = await create_user(tenant=tenant, name="John Doe", email="john.doe@example.com") # Get the created user user = await get_user(tenant=tenant, email="john.doe@example.com") # Create permissions for the user on a dataset await create_permission(user=user, dataset="dataset1", permission="read") await create_permission(user=user, dataset="dataset2", permission="write") # Get all datasets user can read readable_datasets = await get_all_user_permission_datasets(user, "read") print(f"Readable datasets: {readable_datasets}") # Get all datasets user can write writable_datasets = await get_all_user_permission_datasets(user, "write") print(f"Writable datasets: {writable_datasets}") ``` -------------------------------- ### Graphiti Core Requirements and Setup Source: https://docs.cognee.ai/guides/time-awareness When using graphiti-core, Neo4j is a mandatory requirement. This snippet outlines the installation and environment variable setup needed for Neo4j integration. ```shellscript GRAPH_DATABASE_PROVIDER=neo4j GRAPH_DATABASE_URL=bolt://localhost:7687 GRAPH_DATABASE_PASSWORD=your_neo4j_password # Neo4j username is fixed to "neo4j" in this integration ``` -------------------------------- ### Install Cognee with LLM & Embedding Provider Extras Source: https://docs.cognee.ai/llms-full.txt Install extras for specific LLM and embedding providers. Ensure environment variables are set for the chosen provider. For example, to use Claude models, install the `anthropic` extra. ```bash uv pip install "cognee[anthropic]" ``` ```bash uv pip install "cognee[groq]" ``` ```bash uv pip install "cognee[mistral]" ``` ```bash uv pip install "cognee[huggingface]" ``` ```bash uv pip install "cognee[ollama]" ``` ```bash uv pip install "cognee[llama-cpp]" ``` ```bash uv pip install "cognee[azure]" ``` ```bash uv pip install "cognee[fastembed]" ``` -------------------------------- ### Self-Hosted MCP Configuration Example Source: https://docs.cognee.ai/cognee-mcp/mcp-cloud-connection This command-line example shows how to start the Cognee MCP server in a self-hosted configuration, specifying the transport protocol, port, and the URL for serving. ```shellscript cognee-mcp --transport sse --port 8001 --serve-url https://y ``` -------------------------------- ### Full Example of Temporal Awareness Source: https://docs.cognee.ai/guides/time-awareness This example demonstrates the complete setup and usage of temporal awareness within the Cognee framework, including running the main asynchronous function. ```python import asyncio from cognee.infrastructure.services.llm.utils.search_type import SearchType from cognee.api import Cognee async def main(): # Initialize Cognee cognee = Cognee() # Example: Querying data between specific dates await cognee.recall( query_type=SearchType.TEMPORAL, query_text="Events between 2001 and 2004", top_k=10, ) # Example: Querying scoped descriptions await cognee.recall( query_type=SearchType.TEMPORAL, query_text="Key project milestones between 1998 and 2010", top_k=10, ) # Example: Querying data after a specific date with dataset scope await cognee.recall( query_type=SearchType.TEMPORAL, query_text="What happened after 2004?", datasets=["timeline_demo"], top_k=10, ) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Executing a Pipeline Source: https://docs.cognee.ai/guides/custom-tasks-pipelines Shows how to execute a defined pipeline. The 'await setup()' call likely initializes the environment or resources needed for the pipeline execution, followed by the pipeline's execution. ```python await setup() # tasks = [ # Task(extract_people), # Task(add_data_points) # ] # ... (pipeline execution logic would follow) ``` -------------------------------- ### Python SDK Example Source: https://docs.cognee.ai/cognee-cloud/connections/cloud-sdk This example demonstrates a complete workflow using the Cognee SDK, including connecting, processing results, and disconnecting. Ensure you have the necessary imports and setup. ```python import asyncio import cognee async def main(): async with cognee.connect( url="https://your-tenant.aws.cognee.ai", api_key="your-api-key" ) as c: # Use c to interact with Cognee # For example, to get results: results = await c.get_results() print(results) # Disconnect when done await c.disconnect() asyncio.run(main()) ``` -------------------------------- ### Complete Example: Connecting to Cognee Cloud Source: https://docs.cognee.ai/cognee-cloud/connections/connecting-an-agent This Python script demonstrates how to import the necessary libraries and connect to Cognee Cloud using `await cognee.serve()`. Ensure you have the cognee package installed. ```python import asyncio import cognee async def main(): # Connect to Cognee Cloud await cognee.serve() if __name__ == "__main__": asyncio.run(main()) ```