索引
标记节点 #
基类:EventBaseModel
图中的实体。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
label
|
str
|
节点的标签。 |
'node'
|
embedding
|
List[float] | None
|
节点的嵌入向量。 |
None
|
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
实体节点 #
基类:EventLabelledNode
图中的实体。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
label
|
str
|
节点的标签。 |
'entity'
|
name
|
str
|
实体的名称。 |
required |
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
分块节点 #
基类:EventLabelledNode
图中的文本块。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
label
|
str
|
节点的标签。 |
'text_chunk'
|
text
|
str
|
文本块的内容。 |
required |
id_
|
str | None
|
节点的标识符。默认为文本的哈希值。 |
None
|
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
关系 #
基类:EventBaseModel
图中连接两个实体的关系。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
label
|
str
|
|
required |
source_id
|
str
|
|
required |
target_id
|
str
|
|
required |
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
标记属性图 #
基类:EventBaseModel
内存中的标记属性图,包含实体和关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
get_all_nodes #
get_all_nodes() -> List[LabelledNode]
获取所有实体。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
140 141 142 | |
get_all_relations #
get_all_relations() -> List[关系]
获取所有关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
144 145 146 | |
get_triplets #
get_triplets() -> List[Triplet]
获取所有三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
148 149 150 151 152 153 154 155 156 157 158 159 | |
add_triplet #
add_triplet(triplet: Triplet) -> None
添加一个三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
161 162 163 164 165 166 167 168 169 170 | |
add_node #
add_node(node: LabelledNode) -> None
添加一个节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
172 173 174 | |
add_relation #
add_relation(relation: 关系) -> None
添加一个关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
176 177 178 179 180 181 182 183 184 185 | |
delete_triplet #
delete_triplet(triplet: Triplet) -> None
删除一个三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
delete_node #
delete_node(node: LabelledNode) -> None
删除一个节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
203 204 205 206 | |
delete_relation #
delete_relation(relation: 关系) -> None
删除一个关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
208 209 210 211 212 | |
图存储 #
基类:EventProtocol
抽象图存储协议。
该协议定义了图存储的接口,该接口负责存储和检索知识图谱数据。
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
客户端 |
Any
|
Any: 用于连接到图存储的客户端。 |
获取 |
List[List[str]]
|
可调用[[字符串], 列表[列表[字符串]]]: 获取指定主题的三元组。 |
get_rel_map |
Dict[str, List[List[str]]]
|
Callable[[Optional[List[str]], int], Dict[str, List[List[str]]]]: 获取主题在最大深度下的关系映射。 |
upsert_triplet |
None
|
Callable[[str, str, str], None]: 插入或更新三元组。 |
删除 |
None
|
Callable[[str, str, str], None]: 删除一个三元组。 |
持久化 |
None
|
可调用对象[[字符串, 可选[fsspec.抽象文件系统]], 无]: 将图存储持久化到文件。 |
get_schema |
str
|
可调用[[布尔值], 字符串]: 获取图存储的架构。 |
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | |
get #
get(subj: str) -> List[List[str]]
获取三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
243 244 245 | |
get_rel_map #
get_rel_map(subjs: Optional[List[str]] = None, depth: int = 2, limit: int = 30) -> Dict[str, List[List[str]]]
获取深度感知关系图。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
247 248 249 250 251 | |
upsert_triplet #
upsert_triplet(subj: str, rel: str, obj: str) -> None
添加三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
253 254 255 | |
删除 #
delete(subj: str, rel: str, obj: str) -> None
删除三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
257 258 259 | |
persist #
persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> None
将图存储持久化保存到文件中。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
261 262 263 264 265 | |
get_schema #
get_schema(refresh: bool = False) -> str
获取图存储的模式。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
267 268 269 | |
query #
query(query: str, param_map: Optional[Dict[str, Any]] = {}) -> Any
使用语句和参数查询图存储。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
271 272 273 | |
属性图存储 #
基类:EventABC
抽象标记图存储协议。
该协议定义了图存储的接口,该接口负责存储和检索知识图谱数据。
属性:
| 名称 | 类型 | 描述 |
|---|---|---|
客户端 |
Any
|
Any: 用于连接到图存储的客户端。 |
获取 |
List[LabelledNode]
|
可调用[[字符串], 列表[列表[字符串]]]: 获取指定主题的三元组。 |
get_rel_map |
List[Triplet]
|
可调用[[可选[列表[字符串]], 整型], 字典[字符串, 列表[列表[字符串]]]]: 获取主题在最大深度下的关系映射。 |
upsert_triplet |
List[Triplet]
|
Callable[[str, str, str], None]: 插入或更新三元组。 |
删除 |
None
|
Callable[[str, str, str], None]: 删除一个三元组。 |
持久化 |
None
|
Callable[[str, Optional[fsspec.AbstractFileSystem]], None]: 将图存储持久化到文件。 |
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |
获取
abstractmethod
#
get(properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[LabelledNode]
获取具有匹配值的节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
303 304 305 306 307 308 309 310 | |
get_triplets
abstractmethod
#
get_triplets(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[Triplet]
获取具有匹配值的三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
312 313 314 315 316 317 318 319 320 321 | |
get_rel_map
abstractmethod
#
get_rel_map(graph_nodes: List[LabelledNode], depth: int = 2, limit: int = 30, ignore_rels: Optional[List[str]] = None) -> List[Triplet]
获取深度感知关系图。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
323 324 325 326 327 328 329 330 331 332 | |
get_llama_nodes #
get_llama_nodes(node_ids: List[str]) -> List[BaseNode]
获取 llama-index 节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
334 335 336 337 338 339 340 341 342 343 344 345 | |
upsert_nodes
abstractmethod
#
upsert_nodes(nodes: Sequence[LabelledNode]) -> None
更新或插入节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
347 348 349 350 | |
upsert_relations
abstractmethod
#
upsert_relations(relations: List[关系]) -> None
更新或插入关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
352 353 354 355 | |
upsert_llama_nodes #
upsert_llama_nodes(llama_nodes: List[BaseNode]) -> None
添加 llama-index 节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
357 358 359 360 361 362 363 364 365 366 367 368 369 370 | |
删除
abstractmethod
#
delete(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> None
删除匹配数据。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
372 373 374 375 376 377 378 379 380 381 | |
delete_llama_nodes #
delete_llama_nodes(node_ids: Optional[List[str]] = None, ref_doc_ids: Optional[List[str]] = None) -> None
删除 llama-index 节点。
旨在删除图存储中与给定的llama-index节点ID或参考文档ID相关联的任何节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 | |
structured_query
abstractmethod
#
structured_query(query: str, param_map: Optional[Dict[str, Any]] = None) -> Any
使用语句和参数查询图存储。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
412 413 414 415 416 417 | |
vector_query
abstractmethod
#
vector_query(query: VectorStoreQuery, **kwargs: Any) -> Tuple[List[LabelledNode], List[float]]
使用向量存储查询来查询图存储。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
419 420 421 422 423 424 | |
persist #
persist(persist_path: str, fs: Optional[AbstractFileSystem] = None) -> None
将图存储持久化保存到文件中。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
426 427 428 429 430 | |
get_schema #
get_schema(refresh: bool = False) -> Any
获取图存储的模式。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
432 433 434 | |
get_schema_str #
get_schema_str(refresh: bool = False) -> str
以字符串形式获取图存储的模式。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
436 437 438 | |
智能体
async
#
aget(properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[LabelledNode]
异步获取具有匹配值的节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
442 443 444 445 446 447 448 | |
aget_triplets
async
#
aget_triplets(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> List[Triplet]
异步获取具有匹配值的三元组。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
450 451 452 453 454 455 456 457 458 | |
aget_rel_map
async
#
aget_rel_map(graph_nodes: List[LabelledNode], depth: int = 2, limit: int = 30, ignore_rels: Optional[List[str]] = None) -> List[Triplet]
异步获取深度感知关系图。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
460 461 462 463 464 465 466 467 468 | |
aget_llama_nodes
async
#
aget_llama_nodes(node_ids: List[str]) -> List[BaseNode]
异步获取节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
470 471 472 473 474 475 476 477 478 479 480 481 | |
aupsert_nodes
async
#
aupsert_nodes(nodes: List[LabelledNode]) -> None
异步添加节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
483 484 485 | |
aupsert_relations
async
#
aupsert_relations(relations: List[关系]) -> None
异步添加关系。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
487 488 489 | |
删除
async
#
adelete(entity_names: Optional[List[str]] = None, relation_names: Optional[List[str]] = None, properties: Optional[dict] = None, ids: Optional[List[str]] = None) -> None
异步删除匹配数据。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
491 492 493 494 495 496 497 498 499 | |
adelete_llama_nodes
async
#
adelete_llama_nodes(node_ids: Optional[List[str]] = None, ref_doc_ids: Optional[List[str]] = None) -> None
异步删除 llama-index 节点。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
501 502 503 504 505 506 507 | |
astructured_query
async
#
astructured_query(query: str, param_map: Optional[Dict[str, Any]] = {}) -> Any
使用语句和参数异步查询图存储。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
509 510 511 512 513 | |
avector_query
async
#
avector_query(query: VectorStoreQuery, **kwargs: Any) -> Tuple[List[LabelledNode], List[float]]
使用向量存储查询异步查询图存储。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
515 516 517 518 519 | |
aget_schema
async
#
aget_schema(refresh: bool = False) -> str
异步获取图存储的模式。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
521 522 523 | |
aget_schema_str
async
#
aget_schema_str(refresh: bool = False) -> str
异步获取图存储的模式作为字符串。
workflows/handler.py 中的源代码llama_index/core/graph_stores/types.py
525 526 527 | |
选项: 成员:- GraphStore - PropertyGraphStore - DEFAULT_PERSIST_DIR - DEFAULT_PERSIST_FNAME