forked from topoteretes/cognee
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultimedia_audio_image_processing_example.py
More file actions
50 lines (40 loc) · 1.64 KB
/
Copy pathmultimedia_audio_image_processing_example.py
File metadata and controls
50 lines (40 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import asyncio
import os
import pathlib
import cognee
from cognee import SearchType
from cognee.shared.logging_utils import ERROR, setup_logging
# Prerequisites:
# 1. Copy `.env.template` and rename it to `.env`.
# 2. Add your OpenAI API key to the `.env` file in the `LLM_API_KEY` field:
# LLM_API_KEY = "your_key_here"
#
# Optional richer image ingestion (both default off, see `.env.template`):
# IMAGE_EXTRACTION_ENABLED — extraction-oriented transcription prompt (entities/values/relations)
# IMAGE_OCR_ENABLED — append local OCR text; needs pip install "cognee[rapidocr]"
async def main():
# Create a clean slate for cognee -- reset data and system state
await cognee.forget(everything=True)
# cognee knowledge graph will be created based on the text
# and description of these files
mp3_file_path = os.path.join(
pathlib.Path(__file__).parent,
"multimedia_audio_image_processing_example_data/text_to_speech.mp3",
)
png_file_path = os.path.join(
pathlib.Path(__file__).parent,
"multimedia_audio_image_processing_example_data/example.png",
)
# Remember the files and create knowledge graph memory
await cognee.remember([mp3_file_path, png_file_path], self_improvement=False)
# Query cognee for summaries of the data in the multimedia files
search_results = await cognee.recall(
query_type=SearchType.SUMMARIES,
query_text="What is in the multimedia files?",
)
# Display search results
for result_text in search_results:
print(result_text)
if __name__ == "__main__":
logger = setup_logging(log_level=ERROR)
asyncio.run(main())