转换
BaseRetriever #
Bases: PromptMixin, DispatcherSpanMixin
基础检索器。
workflows/handler.py 中的源代码llama_index/core/base/base_retriever.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 274 | |
retrieve #
retrieve(str_or_query_bundle: QueryType) -> List[NodeWithScore]
根据查询检索节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
str_or_query_bundle
|
QueryType
|
可以是一个查询字符串或一个QueryBundle对象。 |
required |
workflows/handler.py 中的源代码llama_index/core/base/base_retriever.py
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 213 214 215 216 217 218 219 220 221 | |
BaseImageRetriever #
Bases: PromptMixin, DispatcherSpanMixin
基础图像检索器抽象。
workflows/handler.py 中的源代码llama_index/core/image_retriever.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
text_to_image_retrieve #
text_to_image_retrieve(str_or_query_bundle: QueryType) -> List[NodeWithScore]
根据查询或单个图像输入检索图像节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
str_or_query_bundle
|
QueryType
|
一个查询文本 |
required |
workflows/handler.py 中的源代码llama_index/core/image_retriever.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
image_to_image_retrieve #
image_to_image_retrieve(str_or_query_bundle: QueryType) -> List[NodeWithScore]
根据单个图像输入检索图像节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
str_or_query_bundle
|
QueryType
|
一个图像路径 |
required |
workflows/handler.py 中的源代码llama_index/core/image_retriever.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
空索引检索器 #
基类:EventBaseRetriever
EmptyIndex 查询。
将原始LLM调用传递给底层的LLM模型。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
input_prompt
|
Optional[BasePromptTemplate]
|
A Simple Input Prompt
(see :ref: |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/empty/retrievers.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
关键词表简单检索器 #
基类:EventBaseKeywordTableRetriever
关键词表索引简单检索器。
Extracts keywords using simple regex-based keyword extractor.
Set when retriever_mode="simple".
有关参数请参见 BaseGPTKeywordTableQuery。
workflows/handler.py 中的源代码llama_index/core/indices/keyword_table/retrievers.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
知识图谱表格检索器 #
基类:EventBaseRetriever
知识图谱表格检索器。
参数在子类之间共享。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_keyword_extract_template
|
Optional[QueryKGExtractPrompt]
|
一个查询
知识图谱提取
提示(参见: |
None
|
refine_template
|
Optional[BasePromptTemplate]
|
A Refinement Prompt
(see :ref: |
required |
text_qa_template
|
Optional[BasePromptTemplate]
|
A Question Answering Prompt
(see :ref: |
required |
max_keywords_per_query
|
int
|
从查询中提取的关键词最大数量。 |
10
|
num_chunks_per_query
|
int
|
要查询的最大文本块数量。 |
10
|
include_text
|
bool
|
在查询过程中使用每个相关三元组的文档文本源。 |
True
|
retriever_mode
|
KGRetrieverMode
|
指定是使用关键词、嵌入向量还是两者结合来查找相关的三元组。应为 "keyword"、"embedding" 或 "hybrid" 中的一种。 |
KEYWORD
|
similarity_top_k
|
int
|
使用的顶部嵌入数量 (如果使用了嵌入)。 |
2
|
graph_store_query_depth
|
int
|
图存储查询的深度。 |
2
|
use_global_node_triplets
|
bool
|
是否从关键词匹配的文本块中获取更多关键词(实体)。这有助于引入更多全局知识。 虽然成本更高,因此默认关闭。 |
False
|
max_knowledge_sequence
|
int
|
响应中包含的知识序列最大数量。默认情况下为30。 |
REL_TEXT_LIMIT
|
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/retrievers.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 274 275 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 | |
知识图谱检索增强生成检索器 #
基类:EventBaseRetriever
知识图谱RAG检索器。
执行面向知识图谱的子图检索增强生成的检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
storage_context
|
Optional[StorageContext]
|
要使用的存储上下文。 |
None
|
entity_extract_fn
|
Optional[Callable]
|
一个用于提取实体的函数。 |
None
|
entity_extract_template Optional[BasePromptTemplate])
|
一个查询关键实体提取提示(参见: |
required | |
entity_extract_policy
|
Optional[str]
|
要使用的实体提取策略。 默认值:"union" 可能的值:"union", "intersection" |
'union'
|
synonym_expand_fn
|
Optional[Callable]
|
一个用于扩展同义词的函数。 |
None
|
synonym_expand_template
|
Optional[QueryKeywordExpandPrompt]
|
一个查询关键实体扩展提示(参见: |
None
|
synonym_expand_policy
|
Optional[str]
|
要使用的同义词扩展策略。 默认值:"union" 可能的值:"union", "intersection" |
'union'
|
max_entities
|
int
|
要提取的实体最大数量。 默认值:5 |
5
|
max_synonyms
|
int
|
每个实体扩展的最大同义词数量。 默认值:5 |
5
|
retriever_mode
|
Optional[str]
|
使用的检索器模式。 默认值:"keyword" 可选值:"keyword", "embedding", "keyword_embedding" |
'keyword'
|
with_nl2graphquery
|
bool
|
是否在上下文中结合自然语言转图查询。 默认值:False |
False
|
graph_traversal_depth
|
int
|
图遍历的深度。 默认值:2 |
2
|
max_knowledge_sequence
|
int
|
响应中包含的知识序列最大数量。默认情况下为30。 |
REL_TEXT_LIMIT
|
verbose
|
bool
|
是否打印调试信息。 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/knowledge_graph/retrievers.py
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 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 | |
摘要索引嵌入检索器 #
基类:EventBaseRetriever
基于嵌入的摘要索引检索器。
以惰性方式为所有遍历的节点生成嵌入向量。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
SummaryIndex
|
要检索的索引。 |
required |
similarity_top_k
|
Optional[int]
|
返回的顶部节点数量。 |
1
|
workflows/handler.py 中的源代码llama_index/core/indices/list/retrievers.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 | |
摘要索引LLM检索器 #
基类:EventBaseRetriever
用于SummaryIndex的LLM检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
SummaryIndex
|
要检索的索引。 |
required |
choice_select_prompt
|
Optional[PromptTemplate]
|
一个选择提示
(参见 :ref: |
None
|
choice_batch_size
|
int
|
每次查询的节点数量。 |
10
|
format_node_batch_fn
|
Optional[Callable]
|
一个用于格式化 节点批处理的函数。 |
None
|
parse_choice_select_answer_fn
|
Optional[Callable]
|
一个解析选择答案的函数。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/list/retrievers.py
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 213 214 215 216 217 218 219 220 221 222 | |
摘要索引检索器 #
基类:EventBaseRetriever
用于SummaryIndex的简单检索器,返回所有节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
SummaryIndex
|
要检索的索引。 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/list/retrievers.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
基础PG检索器 #
基类:EventBaseRetriever
属性图检索器的基类。
默认情况下,将从图存储中检索节点,并在需要时为节点添加源文本。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
include_text
|
bool
|
是否在检索到的节点中包含源文本。默认为 True。 |
True
|
include_text_preamble
|
Optional[str]
|
在源文本之前包含的前言。默认为 DEFAULT_PREAMBLE。 |
DEFAULT_PREAMBLE
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 | |
add_source_text #
add_source_text(nodes: List[NodeWithScore]) -> List[NodeWithScore]
将检索到的节点/三元组与其源文本结合。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/base.py
123 124 125 126 127 128 129 130 | |
async_add_source_text
async
#
async_add_source_text(nodes: List[NodeWithScore]) -> List[NodeWithScore]
将检索到的节点/三元组与其源文本结合。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/base.py
132 133 134 135 136 137 138 139 140 141 | |
retrieve_from_graph
abstractmethod
#
retrieve_from_graph(query_bundle: QueryBundle) -> List[NodeWithScore]
从标记属性图中检索节点。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/base.py
155 156 157 158 | |
aretrieve_from_graph
abstractmethod
async
#
aretrieve_from_graph(query_bundle: QueryBundle) -> List[NodeWithScore]
从标记属性图中检索节点。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/base.py
160 161 162 163 164 165 | |
自定义PG检索器 #
基类:EventBasePGRetriever
一个旨在易于子类化以实现自定义检索逻辑的检索器。
用户只需实现:
- init 来初始化检索器并分配必要的属性。
- custom_retrieve 来实现自定义检索逻辑。
- aretrieve_custom(可选)来实现异步检索逻辑。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
include_text
|
bool
|
是否在检索到的节点中包含文本。仅适用于由LlamaIndex插入的知识图谱节点。 |
False
|
**kwargs
|
Any
|
传递给 init() 的额外关键字参数。 |
{}
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/custom.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
init
abstractmethod
#
init(**kwargs: Any) -> None
初始化检索器。
可以访问传递给检索器的所有关键字参数,包括:
- self.graph_store:用于检索数据的图存储。
- `self.include_text``:是否在检索到的节点中包含文本。
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/custom.py
52 53 54 55 56 57 58 59 60 61 | |
custom_retrieve
abstractmethod
#
custom_retrieve(query_str: str) -> CUSTOM_RETRIEVE_TYPE
根据查询字符串从图存储中检索数据。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_str
|
str
|
用于检索数据的查询字符串。 |
required |
返回:
| 类型 | 描述 |
|---|---|
CUSTOM_RETRIEVE_TYPE
|
检索到的数据。返回类型可以是以下之一: |
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/custom.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
acustom_retrieve
async
#
acustom_retrieve(query_str: str) -> CUSTOM_RETRIEVE_TYPE
根据查询字符串异步从图存储中检索数据。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_str
|
str
|
用于检索数据的查询字符串。 |
required |
返回:
| 类型 | 描述 |
|---|---|
CUSTOM_RETRIEVE_TYPE
|
检索到的数据。返回类型可以是以下之一: |
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
CUSTOM_RETRIEVE_TYPE
|
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/custom.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
Cypher模板检索器 #
基类:EventBasePGRetriever
一个使用LLM为Cypher查询填充参数的Cypher检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
output_cls
|
Type[BaseModel]
|
用于LLM的输出类。 应包含Cypher查询所需的参数。 |
required |
cypher_query
|
str
|
要使用的Cypher查询,包含模板参数。 |
required |
llm
|
Optional[大语言模型]
|
要使用的语言模型。默认为 Settings.llm。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/cypher_template.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
LLM同义词检索器 #
基类:EventBasePGRetriever
一种使用语言模型通过同义词扩展查询的检索器。 这些同义词随后被用于从属性图中检索节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
include_text
|
bool
|
是否在检索到的节点中包含源文本。默认为 True。 |
True
|
synonym_prompt
|
Union[BasePromptTemplate, str]
|
用于同义词扩展查询的模板。 默认为 DEFAULT_SYNONYM_EXPAND_TEMPLATE。 |
DEFAULT_SYNONYM_EXPAND_TEMPLATE
|
max_keywords
|
int
|
生成同义词的最大数量。默认为10。 |
10
|
path_depth
|
int
|
为每个节点检索的路径深度。默认为1(即三元组)。 |
1
|
output_parsing_fn
|
Optional[callable]
|
一个可调用函数,用于解析语言模型的输出。默认为 None。 |
None
|
llm
|
Optional[大语言模型]
|
要使用的语言模型。默认为 Settings.llm。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/llm_synonym.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
PG检索器 #
基类:EventBaseRetriever
一种使用多个子检索器从属性图中检索节点的检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
sub_retrievers
|
List[BasePGRetriever]
|
要使用的子检索器。 |
required |
num_workers
|
int
|
用于异步检索的工作线程数量。默认为4。 |
4
|
use_async
|
bool
|
是否使用异步检索。默认为 True。 |
True
|
show_progress
|
bool
|
是否显示进度条。默认为 False。 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/retriever.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
文本转Cypher检索器 #
基类:EventBasePGRetriever
一个使用语言模型生成Cypher查询的文本转Cypher检索器。
注意:执行任意Cypher查询存在风险。请确保采取必要措施(只读角色、沙盒环境等)以确保在生产环境中的安全使用。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
llm
|
Optional[大语言模型]
|
要使用的语言模型。默认为 Settings.llm。 |
None
|
text_to_cypher_template
|
Optional[Union[PromptTemplate, str]]
|
用于文本转Cypher查询的模板。默认为None。 |
None
|
response_template
|
Optional[str]
|
用于响应的模板。默认为 None。 |
None
|
cypher_validator
|
Optional[callable]
|
一个可调用函数,用于验证生成的Cypher查询。默认为None。 |
None
|
allowed_query_fields
|
Optional[List[str]]
|
查询输出中允许的字段。默认为 ["text", "label", "type"]。 |
required |
include_raw_response_as_metadata
|
Optional[bool]
|
如果为 True,这会将查询和原始响应数据添加到元数据属性中。默认为 False。 |
False
|
summarize_response
|
Optional[bool]
|
如果为 True,将通过提供的 LLM 运行响应以生成更易读的响应;如果为 False,则使用提供或默认的 response_template。默认为 False。 |
False
|
summarization_template
|
Optional[str]
|
用于总结响应的模板。默认为 None。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/text_to_cypher.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 215 216 217 218 219 220 221 222 223 | |
向量上下文检索器 #
基类:EventBasePGRetriever
一个使用向量存储根据查询检索节点的检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
graph_store
|
PropertyGraphStore
|
用于检索数据的图存储。 |
required |
include_text
|
bool
|
是否在检索到的节点中包含源文本。默认为 True。 |
True
|
embed_model
|
Optional[BaseEmbedding]
|
要使用的嵌入模型。默认为 Settings.embed_model。 |
None
|
vector_store
|
Optional[BasePydanticVectorStore]
|
要使用的向量存储。默认为 None。 如果图存储不支持向量查询,则应提供此参数。 |
None
|
similarity_top_k
|
int
|
要检索的顶部相似知识图谱节点数量。默认为4。 |
4
|
path_depth
|
int
|
为每个节点检索的路径深度。默认为1(即三元组)。 |
1
|
similarity_score
|
float
|
检索节点所需的最小相似度分数。默认为 None。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/property_graph/sub_retrievers/vector.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 | |
自然语言SQL检索器 #
Bases: BaseRetriever, PromptMixin
文本到SQL检索器。
通过文本检索。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
sql_database
|
SQLDatabase
|
SQL数据库。 |
required |
text_to_sql_prompt
|
BasePromptTemplate
|
文本转SQL的提示模板。 默认为DEFAULT_TEXT_TO_SQL_PROMPT。 |
None
|
context_query_kwargs
|
dict
|
从表名到上下文查询的映射。 默认为 None。 |
None
|
tables
|
Union[List[str], List[Table]]
|
表名或表对象的列表。 |
None
|
table_retriever
|
ObjectRetriever[SQLTableSchema]
|
用于SQLTableSchema对象的对象检索器。默认为None。 |
None
|
rows_retriever
|
Dict[str, VectorIndexRetriever]
|
表名与其行向量索引检索器之间的映射。默认为 None。 |
required |
context_str_prefix
|
str
|
上下文字符串的前缀。默认为 None。 |
None
|
return_raw
|
bool
|
是否返回SQL结果的纯文本转储,还是解析为节点。 |
True
|
handle_sql_errors
|
bool
|
是否处理SQL错误。默认为True。 |
True
|
sql_only (bool)
|
是否仅获取SQL而不获取SQL查询结果。 默认为False。 |
required | |
llm
|
Optional[大语言模型]
|
使用的语言模型。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
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 213 214 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 274 275 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 | |
retrieve_with_metadata #
retrieve_with_metadata(str_or_query_bundle: QueryType) -> Tuple[List[NodeWithScore], Dict]
使用元数据检索。
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
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 | |
aretrieve_with_metadata
async
#
aretrieve_with_metadata(str_or_query_bundle: QueryType) -> Tuple[List[NodeWithScore], Dict]
异步检索与元数据。
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
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 | |
SQL解析器模式 #
Bases: str, Enum
SQL解析器模式。
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
118 119 120 121 122 | |
SQL检索器 #
基类:EventBaseRetriever
SQL检索器。
通过原始SQL语句进行检索。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
sql_database
|
SQLDatabase
|
SQL数据库。 |
required |
return_raw
|
bool
|
是否返回原始结果或格式化结果。 默认为 True。 |
True
|
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
retrieve_with_metadata #
retrieve_with_metadata(str_or_query_bundle: QueryType) -> Tuple[List[NodeWithScore], Dict]
使用元数据检索。
workflows/handler.py 中的源代码llama_index/core/indices/struct_store/sql_retriever.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | |
树形全叶检索器 #
基类:EventBaseRetriever
GPT全叶检索器。
该类从叶子节点构建特定于查询的树以返回响应。 使用此查询模式意味着树索引在初始化时无需构建, 因为我们会为每个查询重新构建树。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
text_qa_template
|
Optional[BasePromptTemplate]
|
问答提示
(请参阅 :ref: |
required |
workflows/handler.py 中的源代码llama_index/core/indices/tree/all_leaf_retriever.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
树形选择叶子嵌入检索器 #
基类:EventTreeSelectLeafRetriever
树形选择叶子嵌入检索器。
该类通过查询与节点文本之间的嵌入相似性来遍历索引图。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_template
|
Optional[BasePromptTemplate]
|
树形选择查询提示
(参见 :ref: |
None
|
query_template_multiple
|
Optional[BasePromptTemplate]
|
树形选择
查询提示(多选)
(参见: |
None
|
text_qa_template
|
Optional[BasePromptTemplate]
|
问答提示
(请参阅 :ref: |
None
|
refine_template
|
Optional[BasePromptTemplate]
|
优化提示
(请参阅 :ref: |
None
|
child_branch_factor
|
int
|
在每一层级上需要考虑的子节点数量。 如果子分支因子为1,则查询对于任意给定的父节点只会选择一个子节点进行遍历。 如果子分支因子为2,则查询会选择两个子节点。 |
1
|
embed_model
|
Optional[BaseEmbedding]
|
用于嵌入相似度的嵌入模型。 |
None
|
workflows/handler.py 中的源代码llama_index/core/indices/tree/select_leaf_embedding_retriever.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 | |
树形选择叶节点检索器 #
基类:EventBaseRetriever
树形选择叶节点检索器。
该类遍历索引图并搜索能够最佳回答查询的叶节点。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
query_template
|
Optional[BasePromptTemplate]
|
树形选择查询提示
(参见 :ref: |
None
|
query_template_multiple
|
Optional[BasePromptTemplate]
|
树形选择
查询提示(多选)
(参见: |
None
|
child_branch_factor
|
int
|
在每个层级上需要考虑的子节点数量。 如果子分支因子为1,则查询将仅为任意给定父节点选择一个子节点进行遍历。 如果子分支因子为2,则查询将选择两个子节点。 |
1
|
workflows/handler.py 中的源代码llama_index/core/indices/tree/select_leaf_retriever.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 274 275 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 | |
树根检索器 #
基类:EventBaseRetriever
树根检索器。
该类直接从根节点获取答案。
与GPTTreeIndexLeafQuery不同,该类假设图已存储答案(因为它是通过query_str构建的),因此不会尝试沿着图解析信息以合成答案。
workflows/handler.py 中的源代码llama_index/core/indices/tree/tree_root_retriever.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
向量索引自动检索器 #
基类:EventBaseAutoRetriever
向量存储自动检索器。
一种用于向量存储索引的检索器,它使用LLM自动设置向量存储查询参数。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
VectorStoreIndex
|
向量存储索引 |
required |
vector_store_info
|
VectorStoreInfo
|
关于向量存储内容和支持的元数据过滤器的附加信息。自然语言描述由大型语言模型用于自动设置向量存储查询参数。 |
required |
prompt_template_str
|
Optional[str]
|
用于大语言模型的自定义提示模板字符串。 如果为None则使用默认模板字符串。 |
None
|
similarity_top_k
|
int
|
返回前k个结果的数量。 |
DEFAULT_SIMILARITY_TOP_K
|
empty_query_top_k
|
Optional[int]
|
返回前k个结果的数量 如果推断的查询字符串为空(仅使用元数据过滤器)。 可设置为None,此时将使用similarity_top_k参数。 默认设置为10。 |
10
|
max_top_k
|
int
|
允许的最大 top_k 值。由 LLM 或 similarity_top_k 设置的 top_k 将被限制为此值。 |
10
|
vector_store_query_mode
|
str
|
向量存储查询模式 有关支持的完整模式列表,请参阅 VectorStoreQueryMode 的参考文档。 |
DEFAULT
|
default_empty_query_vector
|
Optional[List[float]]
|
默认空查询向量。 默认为 None。如果不为 None,则当查询为空时将使用此向量作为查询向量。 |
None
|
callback_manager
|
Optional[CallbackManager]
|
回调管理器 |
None
|
verbose
|
bool
|
详细模式 |
False
|
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/retrievers/auto_retriever/auto_retriever.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 | |
向量索引检索器 #
基类:EventBaseRetriever
向量索引检索器。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
index
|
VectorStoreIndex
|
向量存储索引。 |
required |
similarity_top_k
|
int
|
返回前k个结果的数量。 |
DEFAULT_SIMILARITY_TOP_K
|
vector_store_query_mode
|
str
|
向量存储查询模式 有关支持的完整模式列表,请参阅 VectorStoreQueryMode 的参考文档。 |
DEFAULT
|
filters
|
Optional[MetadataFilters]
|
元数据过滤器,默认为 None |
None
|
alpha
|
float
|
稀疏/密集检索的权重,仅用于混合查询模式。 |
None
|
doc_ids
|
Optional[List[str]]
|
用于限制搜索的文档列表。 |
None
|
vector_store_kwargs
|
dict
|
在查询时传递给向量存储的额外向量存储特定参数。 |
required |
workflows/handler.py 中的源代码llama_index/core/indices/vector_store/retrievers/retriever.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 | |
自动合并检索器 #
基类:EventBaseRetriever
该检索器将尝试将上下文合并到父级上下文中。
检索器首先从向量存储中检索数据块。 然后,它会尝试将这些数据块合并为单一上下文。
workflows/handler.py 中的源代码llama_index/core/retrievers/auto_merging_retriever.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 | |
查询融合检索器 #
基类:EventBaseRetriever
workflows/handler.py 中的源代码llama_index/core/retrievers/fusion_retriever.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 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 274 275 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 | |
递归检索器 #
基类:EventBaseRetriever
递归检索器。
该检索器将递归地探索从节点到其他检索器/查询引擎的链接。
对于任何检索到的节点,如果其中存在索引节点, 则会探索链接的检索器/查询引擎,并对其进行查询。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
root_id
|
str
|
查询图的根标识符。 |
required |
retriever_dict
|
Optional[Dict[str, BaseRetriever]]
|
一个从标识符到检索器的字典。 |
required |
query_engine_dict
|
Optional[Dict[str, BaseQueryEngine]]
|
一个从标识到查询引擎的字典。 |
None
|
workflows/handler.py 中的源代码llama_index/core/retrievers/recursive_retriever.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 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 213 214 215 216 217 218 219 220 221 | |
retrieve_all #
retrieve_all(query_bundle: QueryBundle) -> Tuple[List[NodeWithScore], List[NodeWithScore]]
检索所有节点。
与默认的 retrieve 方法不同,此方法还会获取额外的来源。
workflows/handler.py 中的源代码llama_index/core/retrievers/recursive_retriever.py
212 213 214 215 216 217 218 219 220 221 | |
路由检索器 #
基类:EventBaseRetriever
路由检索器。
从多个候选检索器中选取一个(或多个)来执行查询。
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
selector
|
BaseSelector
|
一个根据每个候选者的元数据和查询从多个选项中选择其一的筛选器。 |
required |
retriever_tools
|
Sequence[RetrieverTool]
|
一系列候选检索器。它们必须被封装为工具,以便向选择器暴露元数据。 |
required |
workflows/handler.py 中的源代码llama_index/core/retrievers/router_retriever.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
转换检索器 #
基类:EventBaseRetriever
转换检索器。
接收一个现有的检索器和一个查询转换器,并在运行检索器之前先执行查询转换。
workflows/handler.py 中的源代码llama_index/core/retrievers/transform_retriever.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
选项: 成员:- TransformRetriever