cognee/cognee.ipynb
2024-03-13 16:27:07 +01:00

94 lines
No EOL
2.5 KiB
Text

{
"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"
]
}
],
"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
}