Update insert_custom_kg.py

This commit is contained in:
jin
2024-11-27 15:20:10 +08:00
parent 9f3c0581ac
commit 0edb958357

View File

@@ -1,5 +1,5 @@
import os import os
from lightrag import LightRAG, QueryParam from lightrag import LightRAG
from lightrag.llm import gpt_4o_mini_complete from lightrag.llm import gpt_4o_mini_complete
######### #########
# Uncomment the below two lines if running in a jupyter notebook to handle the async nature of rag.insert() # Uncomment the below two lines if running in a jupyter notebook to handle the async nature of rag.insert()
@@ -24,50 +24,50 @@ custom_kg = {
"entity_name": "CompanyA", "entity_name": "CompanyA",
"entity_type": "Organization", "entity_type": "Organization",
"description": "A major technology company", "description": "A major technology company",
"source_id": "Source1" "source_id": "Source1",
}, },
{ {
"entity_name": "ProductX", "entity_name": "ProductX",
"entity_type": "Product", "entity_type": "Product",
"description": "A popular product developed by CompanyA", "description": "A popular product developed by CompanyA",
"source_id": "Source1" "source_id": "Source1",
}, },
{ {
"entity_name": "PersonA", "entity_name": "PersonA",
"entity_type": "Person", "entity_type": "Person",
"description": "A renowned researcher in AI", "description": "A renowned researcher in AI",
"source_id": "Source2" "source_id": "Source2",
}, },
{ {
"entity_name": "UniversityB", "entity_name": "UniversityB",
"entity_type": "Organization", "entity_type": "Organization",
"description": "A leading university specializing in technology and sciences", "description": "A leading university specializing in technology and sciences",
"source_id": "Source2" "source_id": "Source2",
}, },
{ {
"entity_name": "CityC", "entity_name": "CityC",
"entity_type": "Location", "entity_type": "Location",
"description": "A large metropolitan city known for its culture and economy", "description": "A large metropolitan city known for its culture and economy",
"source_id": "Source3" "source_id": "Source3",
}, },
{ {
"entity_name": "EventY", "entity_name": "EventY",
"entity_type": "Event", "entity_type": "Event",
"description": "An annual technology conference held in CityC", "description": "An annual technology conference held in CityC",
"source_id": "Source3" "source_id": "Source3",
}, },
{ {
"entity_name": "CompanyD", "entity_name": "CompanyD",
"entity_type": "Organization", "entity_type": "Organization",
"description": "A financial services company specializing in insurance", "description": "A financial services company specializing in insurance",
"source_id": "Source4" "source_id": "Source4",
}, },
{ {
"entity_name": "ServiceZ", "entity_name": "ServiceZ",
"entity_type": "Service", "entity_type": "Service",
"description": "An insurance product offered by CompanyD", "description": "An insurance product offered by CompanyD",
"source_id": "Source4" "source_id": "Source4",
} },
], ],
"relationships": [ "relationships": [
{ {
@@ -76,7 +76,7 @@ custom_kg = {
"description": "CompanyA develops ProductX", "description": "CompanyA develops ProductX",
"keywords": "develop, produce", "keywords": "develop, produce",
"weight": 1.0, "weight": 1.0,
"source_id": "Source1" "source_id": "Source1",
}, },
{ {
"src_id": "PersonA", "src_id": "PersonA",
@@ -84,7 +84,7 @@ custom_kg = {
"description": "PersonA works at UniversityB", "description": "PersonA works at UniversityB",
"keywords": "employment, affiliation", "keywords": "employment, affiliation",
"weight": 0.9, "weight": 0.9,
"source_id": "Source2" "source_id": "Source2",
}, },
{ {
"src_id": "CityC", "src_id": "CityC",
@@ -92,7 +92,7 @@ custom_kg = {
"description": "EventY is hosted in CityC", "description": "EventY is hosted in CityC",
"keywords": "host, location", "keywords": "host, location",
"weight": 0.8, "weight": 0.8,
"source_id": "Source3" "source_id": "Source3",
}, },
{ {
"src_id": "CompanyD", "src_id": "CompanyD",
@@ -100,9 +100,9 @@ custom_kg = {
"description": "CompanyD provides ServiceZ", "description": "CompanyD provides ServiceZ",
"keywords": "provide, offer", "keywords": "provide, offer",
"weight": 1.0, "weight": 1.0,
"source_id": "Source4" "source_id": "Source4",
} },
] ],
} }
rag.insert_custom_kg(custom_kg) rag.insert_custom_kg(custom_kg)