Update docs
This commit is contained in:
parent
6096733892
commit
750e665292
4 changed files with 723 additions and 689 deletions
|
|
@ -108,6 +108,10 @@ poetry add cognee
|
|||
```
|
||||
|
||||
## 💻 Usage
|
||||
|
||||
Check out our demo notebook [here](cognee%20-%20Get%20Started.ipynb)
|
||||
|
||||
|
||||
- Add a new piece of information to storage
|
||||
```
|
||||
import cognee
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
118
cognee.ipynb
118
cognee.ipynb
|
|
@ -1,118 +0,0 @@
|
|||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "c4d5a399",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from os import listdir, path\n",
|
||||
"from uuid import uuid5, UUID\n",
|
||||
"from cognee import add\n",
|
||||
"\n",
|
||||
"data_path = path.abspath(\".data\")\n",
|
||||
"\n",
|
||||
"results = await add(data_path, \"izmene\")\n",
|
||||
"for result in results:\n",
|
||||
" print(result)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "47edce91",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import duckdb\n",
|
||||
"from cognee.root_dir import get_absolute_path\n",
|
||||
"\n",
|
||||
"dataset_name = \"pdf_files\"\n",
|
||||
"\n",
|
||||
"db_path = get_absolute_path(\"./data/cognee\")\n",
|
||||
"db_location = db_path + \"/cognee.duckdb\"\n",
|
||||
"print(db_location)\n",
|
||||
"\n",
|
||||
"db = duckdb.connect(db_location)\n",
|
||||
"\n",
|
||||
"tables = db.sql(\"SELECT DISTINCT schema_name FROM duckdb_tables();\").df()\n",
|
||||
"print(list(filter(lambda table_name: table_name.endswith('staging') is False, tables.to_dict()[\"schema_name\"].values())))\n",
|
||||
"\n",
|
||||
"# izmene = db.sql(f\"SELECT * FROM izmene.file_metadata;\")\n",
|
||||
"\n",
|
||||
"# print(izmene)\n",
|
||||
"\n",
|
||||
"# pravilnik = db.sql(f\"SELECT * FROM pravilnik.file_metadata;\")\n",
|
||||
"\n",
|
||||
"# print(pravilnik)\n",
|
||||
"\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "607bf624",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from os import path, listdir\n",
|
||||
"from cognee import cognify, list_datasets\n",
|
||||
"from cognee.utils import render_graph\n",
|
||||
"\n",
|
||||
"print(list_datasets())\n",
|
||||
"\n",
|
||||
"graph = await cognify(\"izmene\")\n",
|
||||
"\n",
|
||||
"graph_url = await render_graph(graph, graph_type = \"networkx\")\n",
|
||||
"print(graph_url)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "6edb9cac",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from cognee.infrastructure.databases.graph.get_graph_client import get_graph_client\n",
|
||||
"from cognee.shared.data_models import GraphDBType\n",
|
||||
"from cognee import search, SearchType\n",
|
||||
"\n",
|
||||
"graph_client = get_graph_client(GraphDBType.NETWORKX)\n",
|
||||
"await graph_client.load_graph_from_file()\n",
|
||||
"\n",
|
||||
"graph = graph_client.graph\n",
|
||||
"\n",
|
||||
"query_params = {\n",
|
||||
" SearchType.SIMILARITY: {'query': 'nacin vrsenja kontrole tehnicke dokumentacije'}\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"results = await search(graph, query_params)\n",
|
||||
"print(results)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.13"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
|
|
@ -18,8 +18,6 @@ async def search_similarity(query:str ,graph):
|
|||
from cognee.infrastructure.databases.vector.get_vector_database import get_vector_database
|
||||
vector_client = get_vector_database()
|
||||
|
||||
print(query)
|
||||
|
||||
result = await vector_client.search(id, query,10)
|
||||
|
||||
if result:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue