From 90d10e6f9af50c85fbbf282dd961719d5da7f922 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Mon, 3 Nov 2025 15:31:09 +0100 Subject: [PATCH 01/12] test: Add docs tests. Initial commit, still WIP. --- .github/workflows/docs_tests.yml | 18 ++++++ .../tests/docs/guides/custom_data_models.py | 38 +++++++++++++ cognee/tests/docs/guides/custom_prompts.py | 30 ++++++++++ .../docs/guides/custom_tasks_and_pipelines.py | 53 +++++++++++++++++ .../tests/docs/guides/graph_visualization.py | 13 +++++ cognee/tests/docs/guides/low_level_llm.py | 31 ++++++++++ cognee/tests/docs/guides/memify_quickstart.py | 29 ++++++++++ .../tests/docs/guides/ontology_quickstart.py | 30 ++++++++++ cognee/tests/docs/guides/s3_storage.py | 25 ++++++++ cognee/tests/docs/guides/search_basics.py | 17 ++++++ cognee/tests/docs/guides/temporal_cognify.py | 57 +++++++++++++++++++ 11 files changed, 341 insertions(+) create mode 100644 .github/workflows/docs_tests.yml create mode 100644 cognee/tests/docs/guides/custom_data_models.py create mode 100644 cognee/tests/docs/guides/custom_prompts.py create mode 100644 cognee/tests/docs/guides/custom_tasks_and_pipelines.py create mode 100644 cognee/tests/docs/guides/graph_visualization.py create mode 100644 cognee/tests/docs/guides/low_level_llm.py create mode 100644 cognee/tests/docs/guides/memify_quickstart.py create mode 100644 cognee/tests/docs/guides/ontology_quickstart.py create mode 100644 cognee/tests/docs/guides/s3_storage.py create mode 100644 cognee/tests/docs/guides/search_basics.py create mode 100644 cognee/tests/docs/guides/temporal_cognify.py diff --git a/.github/workflows/docs_tests.yml b/.github/workflows/docs_tests.yml new file mode 100644 index 000000000..b3c538668 --- /dev/null +++ b/.github/workflows/docs_tests.yml @@ -0,0 +1,18 @@ +name: Docs Test Suite +permissions: + contents: read + +on: + release: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + RUNTIME__LOG_LEVEL: ERROR + ENV: 'dev' + +jobs: + diff --git a/cognee/tests/docs/guides/custom_data_models.py b/cognee/tests/docs/guides/custom_data_models.py new file mode 100644 index 000000000..0eb314227 --- /dev/null +++ b/cognee/tests/docs/guides/custom_data_models.py @@ -0,0 +1,38 @@ +import asyncio +from typing import Any +from pydantic import SkipValidation + +import cognee +from cognee.infrastructure.engine import DataPoint +from cognee.infrastructure.engine.models.Edge import Edge +from cognee.tasks.storage import add_data_points + + +class Person(DataPoint): + name: str + # Keep it simple for forward refs / mixed values + knows: SkipValidation[Any] = None # single Person or list[Person] + # Recommended: specify which fields to index for search + metadata: dict = {"index_fields": ["name"]} + + +async def main(): + # Start clean (optional in your app) + await cognee.prune.prune_data() + await cognee.prune.prune_system(metadata=True) + + alice = Person(name="Alice") + bob = Person(name="Bob") + charlie = Person(name="Charlie") + + # Create relationships - field name becomes edge label + alice.knows = bob + # You can also do lists: alice.knows = [bob, charlie] + + # Optional: add weights and custom relationship types + bob.knows = (Edge(weight=0.9, relationship_type="friend_of"), charlie) + + await add_data_points([alice, bob, charlie]) + + +asyncio.run(main()) diff --git a/cognee/tests/docs/guides/custom_prompts.py b/cognee/tests/docs/guides/custom_prompts.py new file mode 100644 index 000000000..0d0a55a80 --- /dev/null +++ b/cognee/tests/docs/guides/custom_prompts.py @@ -0,0 +1,30 @@ +import asyncio +import cognee +from cognee.api.v1.search import SearchType + +custom_prompt = """ +Extract only people and cities as entities. +Connect people to cities with the relationship "lives_in". +Ignore all other entities. +""" + + +async def main(): + await cognee.add( + [ + "Alice moved to Paris in 2010, while Bob has always lived in New York.", + "Andreas was born in Venice, but later settled in Lisbon.", + "Diana and Tom were born and raised in Helsingy. Diana currently resides in Berlin, while Tom never moved.", + ] + ) + await cognee.cognify(custom_prompt=custom_prompt) + + res = await cognee.search( + query_type=SearchType.GRAPH_COMPLETION, + query_text="Where does Alice live?", + ) + print(res) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/cognee/tests/docs/guides/custom_tasks_and_pipelines.py b/cognee/tests/docs/guides/custom_tasks_and_pipelines.py new file mode 100644 index 000000000..202bb128a --- /dev/null +++ b/cognee/tests/docs/guides/custom_tasks_and_pipelines.py @@ -0,0 +1,53 @@ +import asyncio +from typing import Any, Dict, List +from pydantic import BaseModel, SkipValidation + +import cognee +from cognee.modules.engine.operations.setup import setup +from cognee.infrastructure.llm.LLMGateway import LLMGateway +from cognee.infrastructure.engine import DataPoint +from cognee.tasks.storage import add_data_points +from cognee.modules.pipelines import Task, run_pipeline + + +class Person(DataPoint): + name: str + # Optional relationships (we'll let the LLM populate this) + knows: List["Person"] = [] + # Make names searchable in the vector store + metadata: Dict[str, Any] = {"index_fields": ["name"]} + + +class People(BaseModel): + persons: List[Person] + + +async def extract_people(text: str) -> List[Person]: + system_prompt = ( + "Extract people mentioned in the text. " + "Return as `persons: Person[]` with each Person having `name` and optional `knows` relations. " + "If the text says someone knows someone set `knows` accordingly. " + "Only include facts explicitly stated." + ) + people = await LLMGateway.acreate_structured_output(text, system_prompt, People) + return people.persons + + +async def main(): + await cognee.prune.prune_data() + await cognee.prune.prune_system(metadata=True) + await setup() + + text = "Alice knows Bob." + + tasks = [ + Task(extract_people), # input: text -> output: list[Person] + Task(add_data_points), # input: list[Person] -> output: list[Person] + ] + + async for _ in run_pipeline(tasks=tasks, data=text, datasets=["people_demo"]): + pass + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/cognee/tests/docs/guides/graph_visualization.py b/cognee/tests/docs/guides/graph_visualization.py new file mode 100644 index 000000000..d463cbb56 --- /dev/null +++ b/cognee/tests/docs/guides/graph_visualization.py @@ -0,0 +1,13 @@ +import asyncio +import cognee +from cognee.api.v1.visualize.visualize import visualize_graph + + +async def main(): + await cognee.add(["Alice knows Bob.", "NLP is a subfield of CS."]) + await cognee.cognify() + + await visualize_graph("./graph_after_cognify.html") + + +asyncio.run(main()) diff --git a/cognee/tests/docs/guides/low_level_llm.py b/cognee/tests/docs/guides/low_level_llm.py new file mode 100644 index 000000000..454f53f44 --- /dev/null +++ b/cognee/tests/docs/guides/low_level_llm.py @@ -0,0 +1,31 @@ +import asyncio + +from pydantic import BaseModel +from typing import List +from cognee.infrastructure.llm.LLMGateway import LLMGateway + + +class MiniEntity(BaseModel): + name: str + type: str + + +class MiniGraph(BaseModel): + nodes: List[MiniEntity] + + +async def main(): + system_prompt = ( + "Extract entities as nodes with name and type. " + "Use concise, literal values present in the text." + ) + + text = "Apple develops iPhone; Audi produces the R8." + + result = await LLMGateway.acreate_structured_output(text, system_prompt, MiniGraph) + print(result) + # MiniGraph(nodes=[MiniEntity(name='Apple', type='Organization'), ...]) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/cognee/tests/docs/guides/memify_quickstart.py b/cognee/tests/docs/guides/memify_quickstart.py new file mode 100644 index 000000000..040654350 --- /dev/null +++ b/cognee/tests/docs/guides/memify_quickstart.py @@ -0,0 +1,29 @@ +import asyncio +import cognee +from cognee import SearchType + + +async def main(): + # 1) Add two short chats and build a graph + await cognee.add( + [ + "We follow PEP8. Add type hints and docstrings.", + "Releases should not be on Friday. Susan must review PRs.", + ], + dataset_name="rules_demo", + ) + await cognee.cognify(datasets=["rules_demo"]) # builds graph + + # 2) Enrich the graph (uses default memify tasks) + await cognee.memify(dataset="rules_demo") + + # 3) Query the new coding rules + rules = await cognee.search( + query_type=SearchType.CODING_RULES, + query_text="List coding rules", + node_name=["coding_agent_rules"], + ) + print("Rules:", rules) + + +asyncio.run(main()) diff --git a/cognee/tests/docs/guides/ontology_quickstart.py b/cognee/tests/docs/guides/ontology_quickstart.py new file mode 100644 index 000000000..2784dab19 --- /dev/null +++ b/cognee/tests/docs/guides/ontology_quickstart.py @@ -0,0 +1,30 @@ +import asyncio +import cognee + + +async def main(): + texts = ["Audi produces the R8 and e-tron.", "Apple develops iPhone and MacBook."] + + await cognee.add(texts) + # or: await cognee.add("/path/to/folder/of/files") + + import os + from cognee.modules.ontology.ontology_config import Config + from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver + + ontology_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "ontology_input_example/basic_ontology.owl" + ) + + # Create full config structure manually + config: Config = { + "ontology_config": { + "ontology_resolver": RDFLibOntologyResolver(ontology_file=ontology_path) + } + } + + await cognee.cognify(config=config) + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/cognee/tests/docs/guides/s3_storage.py b/cognee/tests/docs/guides/s3_storage.py new file mode 100644 index 000000000..1044e05b4 --- /dev/null +++ b/cognee/tests/docs/guides/s3_storage.py @@ -0,0 +1,25 @@ +import asyncio +import cognee + + +async def main(): + # Single file + await cognee.add("s3://cognee-temp/2024-11-04.md") + + # Folder/prefix (recursively expands) + await cognee.add("s3://cognee-temp") + + # Mixed list + await cognee.add( + [ + "s3://cognee-temp/2024-11-04.md", + "Some inline text to ingest", + ] + ) + + # Process the data + await cognee.cognify() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/cognee/tests/docs/guides/search_basics.py b/cognee/tests/docs/guides/search_basics.py new file mode 100644 index 000000000..67d0c938d --- /dev/null +++ b/cognee/tests/docs/guides/search_basics.py @@ -0,0 +1,17 @@ +import asyncio +import cognee + + +async def main(): + await cognee.prune.prune_data() + await cognee.prune.prune_system(metadata=True) + + text = "First rule of coding: Do not talk about coding." + + # Make sure you've already run cognee.cognify(...) so the graph has content + answers = await cognee.search(query_text="What are the main themes in my data?") + for answer in answers: + print(answer) + + +asyncio.run(main()) diff --git a/cognee/tests/docs/guides/temporal_cognify.py b/cognee/tests/docs/guides/temporal_cognify.py new file mode 100644 index 000000000..34c1ee33c --- /dev/null +++ b/cognee/tests/docs/guides/temporal_cognify.py @@ -0,0 +1,57 @@ +import asyncio +import cognee + + +async def main(): + text = """ + In 1998 the project launched. In 2001 version 1.0 shipped. In 2004 the team merged + with another group. In 2010 support for v1 ended. + """ + + await cognee.add(text, dataset_name="timeline_demo") + + await cognee.cognify(datasets=["timeline_demo"], temporal_cognify=True) + + from cognee.api.v1.search import SearchType + + # Before / after queries + result = await cognee.search( + query_type=SearchType.TEMPORAL, query_text="What happened before 2000?", top_k=10 + ) + + assert result != [] + + result = await cognee.search( + query_type=SearchType.TEMPORAL, query_text="What happened after 2010?", top_k=10 + ) + + assert result != [] + + # Between queries + result = await cognee.search( + query_type=SearchType.TEMPORAL, query_text="Events between 2001 and 2004", top_k=10 + ) + + assert result != [] + + # Scoped descriptions + result = await cognee.search( + query_type=SearchType.TEMPORAL, + query_text="Key project milestones between 1998 and 2010", + top_k=10, + ) + + assert result != [] + + result = await cognee.search( + query_type=SearchType.TEMPORAL, + query_text="What happened after 2004?", + datasets=["timeline_demo"], + top_k=10, + ) + + assert result != [] + + +if __name__ == "__main__": + asyncio.run(main()) From ac3300760b7a521aebe452d041bb7ceaa35f8052 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 12 Nov 2025 12:26:28 +0100 Subject: [PATCH 02/12] test: add search tests docs --- cognee/tests/docs/guides/search_basics.py | 46 +++++++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/cognee/tests/docs/guides/search_basics.py b/cognee/tests/docs/guides/search_basics.py index 67d0c938d..09dee3f92 100644 --- a/cognee/tests/docs/guides/search_basics.py +++ b/cognee/tests/docs/guides/search_basics.py @@ -1,17 +1,57 @@ import asyncio import cognee +from cognee.modules.search.types import SearchType, CombinedSearchResult + async def main(): await cognee.prune.prune_data() await cognee.prune.prune_system(metadata=True) - text = "First rule of coding: Do not talk about coding." + text = """ + Natural language processing (NLP) is an interdisciplinary + subfield of computer science and information retrieval. + First rule of coding: Do not talk about coding. + """ + + text2 = """ + Sandwiches are best served toasted with cheese, ham, mayo, + lettuce, mustard, and salt & pepper. + """ + + await cognee.add(text, dataset_name="NLP_coding") + await cognee.add(text2, dataset_name="Sandwiches") + await cognee.add(text2) + + await cognee.cognify() # Make sure you've already run cognee.cognify(...) so the graph has content answers = await cognee.search(query_text="What are the main themes in my data?") - for answer in answers: - print(answer) + assert len(answers) > 0 + answers = await cognee.search( + query_text="List coding guidelines", + query_type=SearchType.CODING_RULES, + ) + assert len(answers) > 0 + + answers = await cognee.search( + query_text="Give me a confident answer: What is NLP?", + system_prompt="Answer succinctly and state confidence at the end.", + ) + assert len(answers) > 0 + + answers = await cognee.search( + query_text="Tell me about NLP", + only_context=True, + ) + assert len(answers) > 0 + + answers = await cognee.search( + query_text="Quarterly financial highlights", + datasets=["NLP_coding", "Sandwiches"], + use_combined_context=True, + ) + assert isinstance(answers, CombinedSearchResult) asyncio.run(main()) From 503bdc34f38e18e2ec3dccb6e47aaff669702f55 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 12 Nov 2025 13:20:23 +0100 Subject: [PATCH 03/12] test: add tests to workflows --- .github/workflows/docs_tests.yml | 276 ++++++++++++++++++++++++++++- .github/workflows/release_test.yml | 5 + 2 files changed, 274 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docs_tests.yml b/.github/workflows/docs_tests.yml index b3c538668..7f7282bb2 100644 --- a/.github/workflows/docs_tests.yml +++ b/.github/workflows/docs_tests.yml @@ -1,18 +1,280 @@ -name: Docs Test Suite +name: Docs Tests + permissions: contents: read on: - release: workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + workflow_call: + secrets: + LLM_PROVIDER: + required: true + LLM_MODEL: + required: true + LLM_ENDPOINT: + required: true + LLM_API_KEY: + required: true + LLM_API_VERSION: + required: true + EMBEDDING_PROVIDER: + required: true + EMBEDDING_MODEL: + required: true + EMBEDDING_ENDPOINT: + required: true + EMBEDDING_API_KEY: + required: true + EMBEDDING_API_VERSION: + required: true env: - RUNTIME__LOG_LEVEL: ERROR ENV: 'dev' jobs: + test-search-basics: + name: Test Search Basics + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Search Basics Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/search_basics.py + + test-temporal-cognify: + name: Test Temporal Cognify + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Temporal Cognify Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/temporal_cognify.py + + test-ontology-quickstart: + name: Test Temporal Cognify + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Temporal Cognify Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/temporal_cognify.py + + test-s3-storage: + name: Test S3 Docs Guide + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + extra-dependencies: "aws" + + - name: Run S3 Docs Guide Test + env: + ENABLE_BACKEND_ACCESS_CONTROL: True + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + STORAGE_BACKEND: s3 + AWS_REGION: eu-west-1 + AWS_ENDPOINT_URL: https://s3-eu-west-1.amazonaws.com + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_DEV_USER_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_DEV_USER_SECRET_KEY }} + run: uv run python ./cognee/tests/docs/guides/s3_storage.py + + test-graph-visualization: + name: Test Graph Visualization + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Graph Visualization Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/graph_visualization.py + + test-low-level-llm: + name: Test Low Level LLM + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Low Level LLM Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/low_level_llm.py + + test-memify-quickstart: + name: Test Memify Quickstart + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Memify Quickstart Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/memify_quickstart.py + + test-custom-data-models: + name: Test Custom Data Models + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Custom Data Models Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/custom_data_models.py + + test-custom-tasks-and-pipelines: + name: Test Custom Tasks and Pipelines + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Custom Tasks and Pipelines Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/custom_tasks_and_pipelines.py + + test-custom-prompts: + name: Test Custom Prompts + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Cognee Setup + uses: ./.github/actions/cognee_setup + with: + python-version: '3.11.x' + + - name: Run Custom Prompts Test + env: + LLM_MODEL: ${{ secrets.LLM_MODEL }} + LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} + LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} + EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} + EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} + EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} + EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} + run: uv run python ./cognee/tests/docs/guides/custom_prompts.py \ No newline at end of file diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 6ac3ca515..89540fcfb 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -14,4 +14,9 @@ jobs: load-tests: name: Load Tests uses: ./.github/workflows/load_tests.yml + secrets: inherit + + docs-tests: + name: Docs Tests + uses: ./.github/workflows/docs_tests.yml secrets: inherit \ No newline at end of file From 1e56d6dc389e1f33c08a7ee897689a941a7b8a9f Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 12 Nov 2025 13:42:53 +0100 Subject: [PATCH 04/12] chore: ruff format --- cognee/tests/docs/guides/search_basics.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cognee/tests/docs/guides/search_basics.py b/cognee/tests/docs/guides/search_basics.py index 09dee3f92..f1847ad4b 100644 --- a/cognee/tests/docs/guides/search_basics.py +++ b/cognee/tests/docs/guides/search_basics.py @@ -54,4 +54,5 @@ async def main(): ) assert isinstance(answers, CombinedSearchResult) + asyncio.run(main()) From cd60ae31740acc9444f5aaf61fd7720deb2a5c51 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 11 Dec 2025 15:25:44 +0100 Subject: [PATCH 05/12] test: remove docs tests. add trigger to docs repo --- .github/workflows/docs_tests.yml | 280 ------------------ .github/workflows/release_test.yml | 23 +- .../tests/docs/guides/custom_data_models.py | 38 --- cognee/tests/docs/guides/custom_prompts.py | 30 -- .../docs/guides/custom_tasks_and_pipelines.py | 53 ---- .../tests/docs/guides/graph_visualization.py | 13 - cognee/tests/docs/guides/low_level_llm.py | 31 -- cognee/tests/docs/guides/memify_quickstart.py | 29 -- .../tests/docs/guides/ontology_quickstart.py | 30 -- cognee/tests/docs/guides/s3_storage.py | 25 -- cognee/tests/docs/guides/search_basics.py | 58 ---- cognee/tests/docs/guides/temporal_cognify.py | 57 ---- 12 files changed, 16 insertions(+), 651 deletions(-) delete mode 100644 .github/workflows/docs_tests.yml delete mode 100644 cognee/tests/docs/guides/custom_data_models.py delete mode 100644 cognee/tests/docs/guides/custom_prompts.py delete mode 100644 cognee/tests/docs/guides/custom_tasks_and_pipelines.py delete mode 100644 cognee/tests/docs/guides/graph_visualization.py delete mode 100644 cognee/tests/docs/guides/low_level_llm.py delete mode 100644 cognee/tests/docs/guides/memify_quickstart.py delete mode 100644 cognee/tests/docs/guides/ontology_quickstart.py delete mode 100644 cognee/tests/docs/guides/s3_storage.py delete mode 100644 cognee/tests/docs/guides/search_basics.py delete mode 100644 cognee/tests/docs/guides/temporal_cognify.py diff --git a/.github/workflows/docs_tests.yml b/.github/workflows/docs_tests.yml deleted file mode 100644 index 7f7282bb2..000000000 --- a/.github/workflows/docs_tests.yml +++ /dev/null @@ -1,280 +0,0 @@ -name: Docs Tests - -permissions: - contents: read - -on: - workflow_dispatch: - workflow_call: - secrets: - LLM_PROVIDER: - required: true - LLM_MODEL: - required: true - LLM_ENDPOINT: - required: true - LLM_API_KEY: - required: true - LLM_API_VERSION: - required: true - EMBEDDING_PROVIDER: - required: true - EMBEDDING_MODEL: - required: true - EMBEDDING_ENDPOINT: - required: true - EMBEDDING_API_KEY: - required: true - EMBEDDING_API_VERSION: - required: true - -env: - ENV: 'dev' - -jobs: - test-search-basics: - name: Test Search Basics - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Search Basics Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/search_basics.py - - test-temporal-cognify: - name: Test Temporal Cognify - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Temporal Cognify Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/temporal_cognify.py - - test-ontology-quickstart: - name: Test Temporal Cognify - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Temporal Cognify Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/temporal_cognify.py - - test-s3-storage: - name: Test S3 Docs Guide - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - extra-dependencies: "aws" - - - name: Run S3 Docs Guide Test - env: - ENABLE_BACKEND_ACCESS_CONTROL: True - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - STORAGE_BACKEND: s3 - AWS_REGION: eu-west-1 - AWS_ENDPOINT_URL: https://s3-eu-west-1.amazonaws.com - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_DEV_USER_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_DEV_USER_SECRET_KEY }} - run: uv run python ./cognee/tests/docs/guides/s3_storage.py - - test-graph-visualization: - name: Test Graph Visualization - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Graph Visualization Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/graph_visualization.py - - test-low-level-llm: - name: Test Low Level LLM - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Low Level LLM Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/low_level_llm.py - - test-memify-quickstart: - name: Test Memify Quickstart - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Memify Quickstart Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/memify_quickstart.py - - test-custom-data-models: - name: Test Custom Data Models - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Custom Data Models Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/custom_data_models.py - - test-custom-tasks-and-pipelines: - name: Test Custom Tasks and Pipelines - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Custom Tasks and Pipelines Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/custom_tasks_and_pipelines.py - - test-custom-prompts: - name: Test Custom Prompts - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Cognee Setup - uses: ./.github/actions/cognee_setup - with: - python-version: '3.11.x' - - - name: Run Custom Prompts Test - env: - LLM_MODEL: ${{ secrets.LLM_MODEL }} - LLM_ENDPOINT: ${{ secrets.LLM_ENDPOINT }} - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} - LLM_API_VERSION: ${{ secrets.LLM_API_VERSION }} - EMBEDDING_MODEL: ${{ secrets.EMBEDDING_MODEL }} - EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }} - EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }} - EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }} - run: uv run python ./cognee/tests/docs/guides/custom_prompts.py \ No newline at end of file diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 89540fcfb..c6dd68484 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -5,18 +5,27 @@ permissions: contents: read on: + push: + branches: + - feature/cog-3213-docs-set-up-guide-script-tests workflow_dispatch: pull_request: branches: - main jobs: - load-tests: - name: Load Tests - uses: ./.github/workflows/load_tests.yml - secrets: inherit +# load-tests: +# name: Load Tests +# uses: ./.github/workflows/load_tests.yml +# secrets: inherit docs-tests: - name: Docs Tests - uses: ./.github/workflows/docs_tests.yml - secrets: inherit \ No newline at end of file + runs-on: ubuntu-22.04 + steps: + - name: Trigger docs tests + run: | + curl -sS -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.DOCS_REPO_PAT_TOKEN }}" \ + https://api.github.com/repos/your-org/repo-b/dispatches \ + -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' diff --git a/cognee/tests/docs/guides/custom_data_models.py b/cognee/tests/docs/guides/custom_data_models.py deleted file mode 100644 index 0eb314227..000000000 --- a/cognee/tests/docs/guides/custom_data_models.py +++ /dev/null @@ -1,38 +0,0 @@ -import asyncio -from typing import Any -from pydantic import SkipValidation - -import cognee -from cognee.infrastructure.engine import DataPoint -from cognee.infrastructure.engine.models.Edge import Edge -from cognee.tasks.storage import add_data_points - - -class Person(DataPoint): - name: str - # Keep it simple for forward refs / mixed values - knows: SkipValidation[Any] = None # single Person or list[Person] - # Recommended: specify which fields to index for search - metadata: dict = {"index_fields": ["name"]} - - -async def main(): - # Start clean (optional in your app) - await cognee.prune.prune_data() - await cognee.prune.prune_system(metadata=True) - - alice = Person(name="Alice") - bob = Person(name="Bob") - charlie = Person(name="Charlie") - - # Create relationships - field name becomes edge label - alice.knows = bob - # You can also do lists: alice.knows = [bob, charlie] - - # Optional: add weights and custom relationship types - bob.knows = (Edge(weight=0.9, relationship_type="friend_of"), charlie) - - await add_data_points([alice, bob, charlie]) - - -asyncio.run(main()) diff --git a/cognee/tests/docs/guides/custom_prompts.py b/cognee/tests/docs/guides/custom_prompts.py deleted file mode 100644 index 0d0a55a80..000000000 --- a/cognee/tests/docs/guides/custom_prompts.py +++ /dev/null @@ -1,30 +0,0 @@ -import asyncio -import cognee -from cognee.api.v1.search import SearchType - -custom_prompt = """ -Extract only people and cities as entities. -Connect people to cities with the relationship "lives_in". -Ignore all other entities. -""" - - -async def main(): - await cognee.add( - [ - "Alice moved to Paris in 2010, while Bob has always lived in New York.", - "Andreas was born in Venice, but later settled in Lisbon.", - "Diana and Tom were born and raised in Helsingy. Diana currently resides in Berlin, while Tom never moved.", - ] - ) - await cognee.cognify(custom_prompt=custom_prompt) - - res = await cognee.search( - query_type=SearchType.GRAPH_COMPLETION, - query_text="Where does Alice live?", - ) - print(res) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/cognee/tests/docs/guides/custom_tasks_and_pipelines.py b/cognee/tests/docs/guides/custom_tasks_and_pipelines.py deleted file mode 100644 index 202bb128a..000000000 --- a/cognee/tests/docs/guides/custom_tasks_and_pipelines.py +++ /dev/null @@ -1,53 +0,0 @@ -import asyncio -from typing import Any, Dict, List -from pydantic import BaseModel, SkipValidation - -import cognee -from cognee.modules.engine.operations.setup import setup -from cognee.infrastructure.llm.LLMGateway import LLMGateway -from cognee.infrastructure.engine import DataPoint -from cognee.tasks.storage import add_data_points -from cognee.modules.pipelines import Task, run_pipeline - - -class Person(DataPoint): - name: str - # Optional relationships (we'll let the LLM populate this) - knows: List["Person"] = [] - # Make names searchable in the vector store - metadata: Dict[str, Any] = {"index_fields": ["name"]} - - -class People(BaseModel): - persons: List[Person] - - -async def extract_people(text: str) -> List[Person]: - system_prompt = ( - "Extract people mentioned in the text. " - "Return as `persons: Person[]` with each Person having `name` and optional `knows` relations. " - "If the text says someone knows someone set `knows` accordingly. " - "Only include facts explicitly stated." - ) - people = await LLMGateway.acreate_structured_output(text, system_prompt, People) - return people.persons - - -async def main(): - await cognee.prune.prune_data() - await cognee.prune.prune_system(metadata=True) - await setup() - - text = "Alice knows Bob." - - tasks = [ - Task(extract_people), # input: text -> output: list[Person] - Task(add_data_points), # input: list[Person] -> output: list[Person] - ] - - async for _ in run_pipeline(tasks=tasks, data=text, datasets=["people_demo"]): - pass - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/cognee/tests/docs/guides/graph_visualization.py b/cognee/tests/docs/guides/graph_visualization.py deleted file mode 100644 index d463cbb56..000000000 --- a/cognee/tests/docs/guides/graph_visualization.py +++ /dev/null @@ -1,13 +0,0 @@ -import asyncio -import cognee -from cognee.api.v1.visualize.visualize import visualize_graph - - -async def main(): - await cognee.add(["Alice knows Bob.", "NLP is a subfield of CS."]) - await cognee.cognify() - - await visualize_graph("./graph_after_cognify.html") - - -asyncio.run(main()) diff --git a/cognee/tests/docs/guides/low_level_llm.py b/cognee/tests/docs/guides/low_level_llm.py deleted file mode 100644 index 454f53f44..000000000 --- a/cognee/tests/docs/guides/low_level_llm.py +++ /dev/null @@ -1,31 +0,0 @@ -import asyncio - -from pydantic import BaseModel -from typing import List -from cognee.infrastructure.llm.LLMGateway import LLMGateway - - -class MiniEntity(BaseModel): - name: str - type: str - - -class MiniGraph(BaseModel): - nodes: List[MiniEntity] - - -async def main(): - system_prompt = ( - "Extract entities as nodes with name and type. " - "Use concise, literal values present in the text." - ) - - text = "Apple develops iPhone; Audi produces the R8." - - result = await LLMGateway.acreate_structured_output(text, system_prompt, MiniGraph) - print(result) - # MiniGraph(nodes=[MiniEntity(name='Apple', type='Organization'), ...]) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/cognee/tests/docs/guides/memify_quickstart.py b/cognee/tests/docs/guides/memify_quickstart.py deleted file mode 100644 index 040654350..000000000 --- a/cognee/tests/docs/guides/memify_quickstart.py +++ /dev/null @@ -1,29 +0,0 @@ -import asyncio -import cognee -from cognee import SearchType - - -async def main(): - # 1) Add two short chats and build a graph - await cognee.add( - [ - "We follow PEP8. Add type hints and docstrings.", - "Releases should not be on Friday. Susan must review PRs.", - ], - dataset_name="rules_demo", - ) - await cognee.cognify(datasets=["rules_demo"]) # builds graph - - # 2) Enrich the graph (uses default memify tasks) - await cognee.memify(dataset="rules_demo") - - # 3) Query the new coding rules - rules = await cognee.search( - query_type=SearchType.CODING_RULES, - query_text="List coding rules", - node_name=["coding_agent_rules"], - ) - print("Rules:", rules) - - -asyncio.run(main()) diff --git a/cognee/tests/docs/guides/ontology_quickstart.py b/cognee/tests/docs/guides/ontology_quickstart.py deleted file mode 100644 index 2784dab19..000000000 --- a/cognee/tests/docs/guides/ontology_quickstart.py +++ /dev/null @@ -1,30 +0,0 @@ -import asyncio -import cognee - - -async def main(): - texts = ["Audi produces the R8 and e-tron.", "Apple develops iPhone and MacBook."] - - await cognee.add(texts) - # or: await cognee.add("/path/to/folder/of/files") - - import os - from cognee.modules.ontology.ontology_config import Config - from cognee.modules.ontology.rdf_xml.RDFLibOntologyResolver import RDFLibOntologyResolver - - ontology_path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), "ontology_input_example/basic_ontology.owl" - ) - - # Create full config structure manually - config: Config = { - "ontology_config": { - "ontology_resolver": RDFLibOntologyResolver(ontology_file=ontology_path) - } - } - - await cognee.cognify(config=config) - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/cognee/tests/docs/guides/s3_storage.py b/cognee/tests/docs/guides/s3_storage.py deleted file mode 100644 index 1044e05b4..000000000 --- a/cognee/tests/docs/guides/s3_storage.py +++ /dev/null @@ -1,25 +0,0 @@ -import asyncio -import cognee - - -async def main(): - # Single file - await cognee.add("s3://cognee-temp/2024-11-04.md") - - # Folder/prefix (recursively expands) - await cognee.add("s3://cognee-temp") - - # Mixed list - await cognee.add( - [ - "s3://cognee-temp/2024-11-04.md", - "Some inline text to ingest", - ] - ) - - # Process the data - await cognee.cognify() - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/cognee/tests/docs/guides/search_basics.py b/cognee/tests/docs/guides/search_basics.py deleted file mode 100644 index f1847ad4b..000000000 --- a/cognee/tests/docs/guides/search_basics.py +++ /dev/null @@ -1,58 +0,0 @@ -import asyncio -import cognee - -from cognee.modules.search.types import SearchType, CombinedSearchResult - - -async def main(): - await cognee.prune.prune_data() - await cognee.prune.prune_system(metadata=True) - - text = """ - Natural language processing (NLP) is an interdisciplinary - subfield of computer science and information retrieval. - First rule of coding: Do not talk about coding. - """ - - text2 = """ - Sandwiches are best served toasted with cheese, ham, mayo, - lettuce, mustard, and salt & pepper. - """ - - await cognee.add(text, dataset_name="NLP_coding") - await cognee.add(text2, dataset_name="Sandwiches") - await cognee.add(text2) - - await cognee.cognify() - - # Make sure you've already run cognee.cognify(...) so the graph has content - answers = await cognee.search(query_text="What are the main themes in my data?") - assert len(answers) > 0 - - answers = await cognee.search( - query_text="List coding guidelines", - query_type=SearchType.CODING_RULES, - ) - assert len(answers) > 0 - - answers = await cognee.search( - query_text="Give me a confident answer: What is NLP?", - system_prompt="Answer succinctly and state confidence at the end.", - ) - assert len(answers) > 0 - - answers = await cognee.search( - query_text="Tell me about NLP", - only_context=True, - ) - assert len(answers) > 0 - - answers = await cognee.search( - query_text="Quarterly financial highlights", - datasets=["NLP_coding", "Sandwiches"], - use_combined_context=True, - ) - assert isinstance(answers, CombinedSearchResult) - - -asyncio.run(main()) diff --git a/cognee/tests/docs/guides/temporal_cognify.py b/cognee/tests/docs/guides/temporal_cognify.py deleted file mode 100644 index 34c1ee33c..000000000 --- a/cognee/tests/docs/guides/temporal_cognify.py +++ /dev/null @@ -1,57 +0,0 @@ -import asyncio -import cognee - - -async def main(): - text = """ - In 1998 the project launched. In 2001 version 1.0 shipped. In 2004 the team merged - with another group. In 2010 support for v1 ended. - """ - - await cognee.add(text, dataset_name="timeline_demo") - - await cognee.cognify(datasets=["timeline_demo"], temporal_cognify=True) - - from cognee.api.v1.search import SearchType - - # Before / after queries - result = await cognee.search( - query_type=SearchType.TEMPORAL, query_text="What happened before 2000?", top_k=10 - ) - - assert result != [] - - result = await cognee.search( - query_type=SearchType.TEMPORAL, query_text="What happened after 2010?", top_k=10 - ) - - assert result != [] - - # Between queries - result = await cognee.search( - query_type=SearchType.TEMPORAL, query_text="Events between 2001 and 2004", top_k=10 - ) - - assert result != [] - - # Scoped descriptions - result = await cognee.search( - query_type=SearchType.TEMPORAL, - query_text="Key project milestones between 1998 and 2010", - top_k=10, - ) - - assert result != [] - - result = await cognee.search( - query_type=SearchType.TEMPORAL, - query_text="What happened after 2004?", - datasets=["timeline_demo"], - top_k=10, - ) - - assert result != [] - - -if __name__ == "__main__": - asyncio.run(main()) From 41edeb0cf890e0d0b733bcd4befb03b870e70cbc Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 11 Dec 2025 16:01:26 +0100 Subject: [PATCH 06/12] test: change target repo name --- .github/workflows/release_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index c6dd68484..3fef0732a 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -27,5 +27,5 @@ jobs: curl -sS -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.DOCS_REPO_PAT_TOKEN }}" \ - https://api.github.com/repos/your-org/repo-b/dispatches \ + https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' From 0f4cf15d588e5dfa672d680e5258de284d308367 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Thu, 11 Dec 2025 16:24:47 +0100 Subject: [PATCH 07/12] test: fix docs test trigger --- .github/workflows/release_test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 3fef0732a..76ce3b09d 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -24,8 +24,9 @@ jobs: steps: - name: Trigger docs tests run: | - curl -sS -X POST \ + curl -L -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer ${{ secrets.DOCS_REPO_PAT_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' From e92d8f57b56823e0a1a4bf5ccf6734cdda01d56f Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 17 Dec 2025 13:14:14 +0100 Subject: [PATCH 08/12] feat: add comunity test trigger --- .github/workflows/release_test.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 76ce3b09d..be57c7fbf 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -19,14 +19,28 @@ jobs: # uses: ./.github/workflows/load_tests.yml # secrets: inherit - docs-tests: +# docs-tests: +# runs-on: ubuntu-22.04 +# steps: +# - name: Trigger docs tests +# run: | +# curl -L -X POST \ +# -H "Accept: application/vnd.github+json" \ +# -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ +# -H "X-GitHub-Api-Version: 2022-11-28" \ +# https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ +# -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' + + trigger-community-test-suite: + needs: release-pypi-package + if: ${{ inputs.flavour == 'main' }} runs-on: ubuntu-22.04 steps: - - name: Trigger docs tests + - name: Trigger community tests run: | curl -L -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.DOCS_REPO_PAT_TOKEN }}" \ + -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ + https://api.github.com/repos/topoteretes/cognee-community/dispatches \ -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' From 601f74db4fda3c1bc3603d03bfbe22be7c8d6a24 Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 17 Dec 2025 13:15:43 +0100 Subject: [PATCH 09/12] test: remove dependency from community trigger --- .github/workflows/release_test.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index be57c7fbf..dcb709ead 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -14,6 +14,18 @@ on: - main jobs: + trigger-community-test-suite: + if: ${{ inputs.flavour == 'main' }} + runs-on: ubuntu-22.04 + steps: + - name: Trigger community tests + run: | + curl -L -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/topoteretes/cognee-community/dispatches \ + -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' # load-tests: # name: Load Tests # uses: ./.github/workflows/load_tests.yml @@ -30,17 +42,3 @@ jobs: # -H "X-GitHub-Api-Version: 2022-11-28" \ # https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ # -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' - - trigger-community-test-suite: - needs: release-pypi-package - if: ${{ inputs.flavour == 'main' }} - runs-on: ubuntu-22.04 - steps: - - name: Trigger community tests - run: | - curl -L -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/topoteretes/cognee-community/dispatches \ - -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' From a5a7ae2564abd90c0bf9b51b3abfc2a24a067a8f Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 17 Dec 2025 13:16:46 +0100 Subject: [PATCH 10/12] test: remove if --- .github/workflows/release_test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index dcb709ead..08595a01e 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -15,7 +15,6 @@ on: jobs: trigger-community-test-suite: - if: ${{ inputs.flavour == 'main' }} runs-on: ubuntu-22.04 steps: - name: Trigger community tests From 6958b4edd462615e2e973d7cabd369181c030eba Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 17 Dec 2025 13:50:03 +0100 Subject: [PATCH 11/12] feat: add the triggers to release, after pypi publishing --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/release_test.yml | 30 ++++-------------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84601edf7..26ccce1f0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -136,3 +136,31 @@ jobs: flavour=${{ inputs.flavour }} cache-from: type=registry,ref=cognee/cognee:buildcache cache-to: type=registry,ref=cognee/cognee:buildcache,mode=max + + trigger-docs-test-suite: + needs: release-pypi-package + if: ${{ inputs.flavour == 'main' }} + runs-on: ubuntu-22.04 + steps: + - name: Trigger docs tests + run: | + curl -L -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ + -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' + + trigger-community-test-suite: + needs: release-pypi-package + if: ${{ inputs.flavour == 'main' }} + runs-on: ubuntu-22.04 + steps: + - name: Trigger community tests + run: | + curl -L -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/topoteretes/cognee-community/dispatches \ + -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' \ No newline at end of file diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 08595a01e..6090a1217 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -14,30 +14,8 @@ on: - main jobs: - trigger-community-test-suite: - runs-on: ubuntu-22.04 - steps: - - name: Trigger community tests - run: | - curl -L -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/topoteretes/cognee-community/dispatches \ - -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' -# load-tests: -# name: Load Tests -# uses: ./.github/workflows/load_tests.yml -# secrets: inherit + load-tests: + name: Load Tests + uses: ./.github/workflows/load_tests.yml + secrets: inherit -# docs-tests: -# runs-on: ubuntu-22.04 -# steps: -# - name: Trigger docs tests -# run: | -# curl -L -X POST \ -# -H "Accept: application/vnd.github+json" \ -# -H "Authorization: Bearer ${{ secrets.REPO_DISPATCH_PAT_TOKEN }}" \ -# -H "X-GitHub-Api-Version: 2022-11-28" \ -# https://api.github.com/repos/topoteretes/cognee-docs/dispatches \ -# -d '{"event_type":"new-main-release","client_payload":{"caller_repo":"'"${GITHUB_REPOSITORY}"'"}}' From 431a83247fff487357a253cbddb00e779e8bda9b Mon Sep 17 00:00:00 2001 From: Andrej Milicevic Date: Wed, 17 Dec 2025 13:50:43 +0100 Subject: [PATCH 12/12] chore: remove unnecessary 'on push' setting --- .github/workflows/release_test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release_test.yml b/.github/workflows/release_test.yml index 6090a1217..b31b431a4 100644 --- a/.github/workflows/release_test.yml +++ b/.github/workflows/release_test.yml @@ -5,9 +5,6 @@ permissions: contents: read on: - push: - branches: - - feature/cog-3213-docs-set-up-guide-script-tests workflow_dispatch: pull_request: branches: