| 1 | from dotenv import load_dotenv |
| 2 | load_dotenv() |
| 3 | from graphrag_sdk.ontology import Ontology |
| 4 | import unittest |
| 5 | from graphrag_sdk.source import Source |
| 6 | from graphrag_sdk.models.gemini import GeminiGenerativeModel |
| 7 | import vertexai |
| 8 | import os |
| 9 | import logging |
| 10 | |
| 11 | logging.basicConfig(level=logging.DEBUG) |
| 12 | |
| 13 | vertexai.init(project=os.getenv("PROJECT_ID"), location=os.getenv("REGION")) |
| 14 | |
| 15 | |
| 16 | class TestAutoDetectOntology(unittest.TestCase): |
| 17 | """ |
| 18 | Test auto-detect ontology |
| 19 | """ |
| 20 | |
| 21 | def test_auto_detect_ontology(self): |
| 22 | |
| 23 | file_path = "tests/data/madoff.txt" |
| 24 | |
| 25 | sources = [Source(file_path)] |
| 26 | |
| 27 | model = GeminiGenerativeModel(model_name="gemini-1.5-flash-001") |
| 28 | |
| 29 | boundaries = """ |
| 30 | Extract entities and relationships from each page |
| 31 | """ |
| 32 | ontology = Ontology.from_sources(sources, boundaries=boundaries, model=model) |
| 33 | |
| 34 | logging.info(f"Ontology: {ontology.to_json()}") |