jin
commited on
Commit
·
99f5836
1
Parent(s):
55feb16
Update insert_custom_kg.py
Browse files- examples/insert_custom_kg.py +16 -16
examples/insert_custom_kg.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import os
|
2 |
-
from lightrag import LightRAG
|
3 |
from lightrag.llm import gpt_4o_mini_complete
|
4 |
#########
|
5 |
# 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 = {
|
|
24 |
"entity_name": "CompanyA",
|
25 |
"entity_type": "Organization",
|
26 |
"description": "A major technology company",
|
27 |
-
"source_id": "Source1"
|
28 |
},
|
29 |
{
|
30 |
"entity_name": "ProductX",
|
31 |
"entity_type": "Product",
|
32 |
"description": "A popular product developed by CompanyA",
|
33 |
-
"source_id": "Source1"
|
34 |
},
|
35 |
{
|
36 |
"entity_name": "PersonA",
|
37 |
"entity_type": "Person",
|
38 |
"description": "A renowned researcher in AI",
|
39 |
-
"source_id": "Source2"
|
40 |
},
|
41 |
{
|
42 |
"entity_name": "UniversityB",
|
43 |
"entity_type": "Organization",
|
44 |
"description": "A leading university specializing in technology and sciences",
|
45 |
-
"source_id": "Source2"
|
46 |
},
|
47 |
{
|
48 |
"entity_name": "CityC",
|
49 |
"entity_type": "Location",
|
50 |
"description": "A large metropolitan city known for its culture and economy",
|
51 |
-
"source_id": "Source3"
|
52 |
},
|
53 |
{
|
54 |
"entity_name": "EventY",
|
55 |
"entity_type": "Event",
|
56 |
"description": "An annual technology conference held in CityC",
|
57 |
-
"source_id": "Source3"
|
58 |
},
|
59 |
{
|
60 |
"entity_name": "CompanyD",
|
61 |
"entity_type": "Organization",
|
62 |
"description": "A financial services company specializing in insurance",
|
63 |
-
"source_id": "Source4"
|
64 |
},
|
65 |
{
|
66 |
"entity_name": "ServiceZ",
|
67 |
"entity_type": "Service",
|
68 |
"description": "An insurance product offered by CompanyD",
|
69 |
-
"source_id": "Source4"
|
70 |
-
}
|
71 |
],
|
72 |
"relationships": [
|
73 |
{
|
@@ -76,7 +76,7 @@ custom_kg = {
|
|
76 |
"description": "CompanyA develops ProductX",
|
77 |
"keywords": "develop, produce",
|
78 |
"weight": 1.0,
|
79 |
-
"source_id": "Source1"
|
80 |
},
|
81 |
{
|
82 |
"src_id": "PersonA",
|
@@ -84,7 +84,7 @@ custom_kg = {
|
|
84 |
"description": "PersonA works at UniversityB",
|
85 |
"keywords": "employment, affiliation",
|
86 |
"weight": 0.9,
|
87 |
-
"source_id": "Source2"
|
88 |
},
|
89 |
{
|
90 |
"src_id": "CityC",
|
@@ -92,7 +92,7 @@ custom_kg = {
|
|
92 |
"description": "EventY is hosted in CityC",
|
93 |
"keywords": "host, location",
|
94 |
"weight": 0.8,
|
95 |
-
"source_id": "Source3"
|
96 |
},
|
97 |
{
|
98 |
"src_id": "CompanyD",
|
@@ -100,9 +100,9 @@ custom_kg = {
|
|
100 |
"description": "CompanyD provides ServiceZ",
|
101 |
"keywords": "provide, offer",
|
102 |
"weight": 1.0,
|
103 |
-
"source_id": "Source4"
|
104 |
-
}
|
105 |
-
]
|
106 |
}
|
107 |
|
108 |
rag.insert_custom_kg(custom_kg)
|
|
|
1 |
import os
|
2 |
+
from lightrag import LightRAG
|
3 |
from lightrag.llm import gpt_4o_mini_complete
|
4 |
#########
|
5 |
# Uncomment the below two lines if running in a jupyter notebook to handle the async nature of rag.insert()
|
|
|
24 |
"entity_name": "CompanyA",
|
25 |
"entity_type": "Organization",
|
26 |
"description": "A major technology company",
|
27 |
+
"source_id": "Source1",
|
28 |
},
|
29 |
{
|
30 |
"entity_name": "ProductX",
|
31 |
"entity_type": "Product",
|
32 |
"description": "A popular product developed by CompanyA",
|
33 |
+
"source_id": "Source1",
|
34 |
},
|
35 |
{
|
36 |
"entity_name": "PersonA",
|
37 |
"entity_type": "Person",
|
38 |
"description": "A renowned researcher in AI",
|
39 |
+
"source_id": "Source2",
|
40 |
},
|
41 |
{
|
42 |
"entity_name": "UniversityB",
|
43 |
"entity_type": "Organization",
|
44 |
"description": "A leading university specializing in technology and sciences",
|
45 |
+
"source_id": "Source2",
|
46 |
},
|
47 |
{
|
48 |
"entity_name": "CityC",
|
49 |
"entity_type": "Location",
|
50 |
"description": "A large metropolitan city known for its culture and economy",
|
51 |
+
"source_id": "Source3",
|
52 |
},
|
53 |
{
|
54 |
"entity_name": "EventY",
|
55 |
"entity_type": "Event",
|
56 |
"description": "An annual technology conference held in CityC",
|
57 |
+
"source_id": "Source3",
|
58 |
},
|
59 |
{
|
60 |
"entity_name": "CompanyD",
|
61 |
"entity_type": "Organization",
|
62 |
"description": "A financial services company specializing in insurance",
|
63 |
+
"source_id": "Source4",
|
64 |
},
|
65 |
{
|
66 |
"entity_name": "ServiceZ",
|
67 |
"entity_type": "Service",
|
68 |
"description": "An insurance product offered by CompanyD",
|
69 |
+
"source_id": "Source4",
|
70 |
+
},
|
71 |
],
|
72 |
"relationships": [
|
73 |
{
|
|
|
76 |
"description": "CompanyA develops ProductX",
|
77 |
"keywords": "develop, produce",
|
78 |
"weight": 1.0,
|
79 |
+
"source_id": "Source1",
|
80 |
},
|
81 |
{
|
82 |
"src_id": "PersonA",
|
|
|
84 |
"description": "PersonA works at UniversityB",
|
85 |
"keywords": "employment, affiliation",
|
86 |
"weight": 0.9,
|
87 |
+
"source_id": "Source2",
|
88 |
},
|
89 |
{
|
90 |
"src_id": "CityC",
|
|
|
92 |
"description": "EventY is hosted in CityC",
|
93 |
"keywords": "host, location",
|
94 |
"weight": 0.8,
|
95 |
+
"source_id": "Source3",
|
96 |
},
|
97 |
{
|
98 |
"src_id": "CompanyD",
|
|
|
100 |
"description": "CompanyD provides ServiceZ",
|
101 |
"keywords": "provide, offer",
|
102 |
"weight": 1.0,
|
103 |
+
"source_id": "Source4",
|
104 |
+
},
|
105 |
+
],
|
106 |
}
|
107 |
|
108 |
rag.insert_custom_kg(custom_kg)
|