Update insert_custom_kg.py

This commit is contained in:
jin
2024-11-27 15:20:10 +08:00
parent a88908009c
commit 69867da89f

View File

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