-
Notifications
You must be signed in to change notification settings - Fork 182
Feat/add tool - cognee #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hande-k
wants to merge
9
commits into
agentstack-ai:main
Choose a base branch
from
hande-k:feat/add-tool-cognee-m
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
88621ba
add cognee
hande-k 314e651
update cognee
hande-k e72fffd
update pyproject
hande-k 9734380
Merge branch 'main' into feat/add-tool-cognee-m
hande-k 018e8cf
Delete .python-version
hande-k 16e6b90
Delete pyproject.toml
hande-k 7e311ec
Delete poetry.lock
hande-k 41d9b0d
update docs for cognee
hande-k 1ab2840
Update config.json
hande-k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 3.12.0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| """ | ||
| Implementation of the cognee for AgentStack. | ||
| These functions wrap cognee's asynchronous methods and expose them | ||
| as synchronous functions with typed parameters & docstrings for use by AI agents. | ||
| """ | ||
|
|
||
| import cognee | ||
| import asyncio | ||
| from typing import List | ||
| from cognee.api.v1.search import SearchType | ||
|
|
||
|
|
||
| def prune_data(metadata: bool = False) -> str: | ||
| """ | ||
| Prune the cognee data. If metadata is True, also prune system metadata. | ||
|
|
||
| :param metadata: Whether to prune system metadata as well. | ||
| :return: A confirmation message. | ||
| """ | ||
|
|
||
| async def _prune(): | ||
| await cognee.prune.prune_data() | ||
| if metadata: | ||
| await cognee.prune.prune_system(metadata=True) | ||
| return "Data pruned successfully." | ||
|
|
||
| return asyncio.run(_prune()) | ||
|
|
||
|
|
||
| def add_text(text: str) -> str: | ||
| """ | ||
| Add text to cognee's knowledge system for future 'cognify' operations. | ||
|
|
||
| :param text: The text to add. | ||
| :return: A confirmation message. | ||
| """ | ||
|
|
||
| async def _add(): | ||
| await cognee.add(text) | ||
| return "Text added successfully." | ||
|
|
||
| return asyncio.run(_add()) | ||
|
|
||
|
|
||
| def cognify() -> str: | ||
| """ | ||
| Run cognee's 'cognify' pipeline to build the knowledge graph, | ||
| summaries, and other metadata from previously added text. | ||
|
|
||
| :return: A confirmation message. | ||
| """ | ||
|
|
||
| async def _cognify(): | ||
| await cognee.cognify() | ||
| return "Cognify process complete." | ||
|
|
||
| return asyncio.run(_cognify()) | ||
|
|
||
|
|
||
| def search_insights(query_text: str) -> str: | ||
| """ | ||
| Perform an INSIGHTS search on the knowledge graph for the given query text. | ||
|
|
||
| :param query_text: The query to search for. | ||
| :return: The search results as a (stringified) list of matches. | ||
| """ | ||
|
|
||
| async def _search(): | ||
| results = await cognee.search(SearchType.INSIGHTS, query_text=query_text) | ||
| return str(results) | ||
|
|
||
| return asyncio.run(_search()) | ||
|
|
||
| def search_summaries(query_text: str) -> str: | ||
| """ | ||
| Perform a SUMMARIES search on the knowledge graph for the given query text. | ||
|
|
||
| :param query_text: The query to search for. | ||
| :return: The search results as a (stringified) list of matches. | ||
| """ | ||
|
|
||
| async def _search(): | ||
| results = await cognee.search(SearchType.SUMMARIES, query_text=query_text) | ||
| return str(results) | ||
|
|
||
| return asyncio.run(_search()) | ||
|
|
||
| def search_chunks(query_text: str) -> str: | ||
| """ | ||
| Perform a CHUNKS search on the knowledge graph for the given query text. | ||
|
|
||
| :param query_text: The query to search for. | ||
| :return: The search results as a (stringified) list of matches. | ||
| """ | ||
|
|
||
| async def _search(): | ||
| results = await cognee.search(SearchType.CHUNKS, query_text=query_text) | ||
| return str(results) | ||
|
|
||
| return asyncio.run(_search()) | ||
|
|
||
| def search_completion(query_text: str) -> str: | ||
| """ | ||
| Perform a COMPLETION search on the knowledge graph for the given query text. | ||
|
|
||
| :param query_text: The query to search for. | ||
| :return: The search results as a (stringified) list of matches. | ||
| """ | ||
|
|
||
| async def _search(): | ||
| results = await cognee.search(SearchType.COMPLETION, query_text=query_text) | ||
| return str(results) | ||
|
|
||
| return asyncio.run(_search()) | ||
|
|
||
| def search_graph_completion(query_text: str) -> str: | ||
| """ | ||
| Perform a GRAPH_COMPLETION search on the knowledge graph for the given query text. | ||
|
|
||
| :param query_text: The query to search for. | ||
| :return: The search results as a (stringified) list of matches. | ||
| """ | ||
|
|
||
| async def _search(): | ||
| results = await cognee.search(SearchType.GRAPH_COMPLETION, query_text=query_text) | ||
| return str(results) | ||
|
|
||
| return asyncio.run(_search()) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "name": "cognee", | ||
| "category": "Memory", | ||
| "tools": [ | ||
| "prune_data", | ||
| "add_text", | ||
| "cognify", | ||
| "search_insights", | ||
| "search_summaries", | ||
| "search_chunks", | ||
| "search_completion", | ||
| "search_graph_completion" | ||
| ], | ||
| "url": "https://github.com/topoteretes/cognee", | ||
| "tools_bundled": true, | ||
| "cta": "Cognee installed! Please set your cognee env variables.", | ||
|
|
||
| "env": { | ||
| "ENV": "local", | ||
| "TOKENIZERS_PARALLELISM": "false", | ||
| "LLM_API_KEY": "", | ||
| "LLM_MODEL": "openai/gpt-4o-mini", | ||
| "LLM_PROVIDER": "openai", | ||
| "LLM_ENDPOINT": "", | ||
| "LLM_API_VERSION": "", | ||
| "GRAPHISTRY_USERNAME": "", | ||
| "GRAPHISTRY_PASSWORD": "", | ||
| "SENTRY_REPORTING_URL": "", | ||
| "EMBEDDING_PROVIDER": "openai", | ||
| "EMBEDDING_API_KEY": "", | ||
| "EMBEDDING_MODEL": "openai/text-embedding-3-large", | ||
| "EMBEDDING_ENDPOINT": "", | ||
| "EMBEDDING_API_VERSION": "", | ||
| "EMBEDDING_DIMENSIONS": 3072, | ||
| "EMBEDDING_MAX_TOKENS": 8191, | ||
| "_comment1": "# neo4j or networkx", | ||
| "GRAPH_DATABASE_PROVIDER": "networkx", | ||
| "_comment2": "# Not needed if using networkx", | ||
| "GRAPH_DATABASE_URL": "", | ||
| "GRAPH_DATABASE_USERNAME": "", | ||
| "GRAPH_DATABASE_PASSWORD": "", | ||
| "_comment3": "# qdrant, pgvector, weaviate, milvus or lancedb", | ||
| "VECTOR_DB_PROVIDER": "lancedb", | ||
| "_comment4": "# Not needed if using lancedb or pgvector", | ||
| "VECTOR_DB_URL": "", | ||
| "VECTOR_DB_KEY": "", | ||
| "_comment5": "Relational Database provider sqlite or postgres", | ||
| "DB_PROVIDER": "sqlite", | ||
| "_comment6": "# Database name", | ||
| "DB_NAME": "cognee_db", | ||
| "_comment7": "# Postgres specific parameters (Only if Postgres or PGVector is used)", | ||
| "DB_HOST": "127.0.0.1", | ||
| "DB_PORT": 5432, | ||
| "DB_USERNAME": "cognee", | ||
| "DB_PASSWORD": "cognee" | ||
| }, | ||
|
|
||
| "packages": [ | ||
| "cognee" | ||
| ], | ||
| "post_install": "Now, you can start cognifying!", | ||
| "post_remove": "Cognee is removed!" | ||
| } | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.