Skip to content

Commit

Permalink
fix: Add install of llama-index to notebook
Browse files Browse the repository at this point in the history
Removed additional references to llama-index from core cognee lib.
Added llama-index-core install from notebook

Fix COG-337
  • Loading branch information
dexters1 committed Nov 15, 2024
1 parent 4c7a4e2 commit c4700b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from llama_index.core import Document
from typing import Union, BinaryIO
from typing import Union, BinaryIO, Any
from cognee.modules.ingestion import save_data_to_file
from .transform_data import get_data_from_llama_index

def save_data_item_with_metadata_to_storage(data_item: Union[BinaryIO, Document, str], dataset_name: str) -> str:
def save_data_item_with_metadata_to_storage(data_item: Union[BinaryIO, str, Any], dataset_name: str) -> str:
# Dynamic import is used because the llama_index module is optional.
# For the same reason Any is accepted as a data item
from llama_index.core import Document
from .transform_data import get_data_from_llama_index

# Check if data is of type Document or any of it's subclasses
if isinstance(data_item, Document):
file_path = get_data_from_llama_index(data_item, dataset_name)
Expand Down
13 changes: 11 additions & 2 deletions notebooks/cognee_llama_index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
"## Cognee GraphRAG with LlamaIndex Documents"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index-core"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -43,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -62,7 +71,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit c4700b1

Please sign in to comment.