Core Agent Classes#
Base Types#
基本代理类型。
BaseAgent #
Bases: BaseChatEngine
, BaseQueryEngine
基础代理。
Source code in llama_index/core/base/agent/types.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 |
|
BaseAgentWorker #
Bases: PromptMixin
基础代理工作者。
Source code in llama_index/core/base/agent/types.py
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 |
|
initialize_step
abstractmethod
#
从任务中初始化步骤。
Source code in llama_index/core/base/agent/types.py
201 202 203 |
|
run_step
abstractmethod
#
run_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/base/agent/types.py
205 206 207 |
|
arun_step
abstractmethod
async
#
arun_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/base/agent/types.py
209 210 211 212 213 214 |
|
stream_step
abstractmethod
#
stream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/base/agent/types.py
216 217 218 219 220 |
|
astream_step
abstractmethod
async
#
astream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/base/agent/types.py
222 223 224 225 226 227 |
|
finalize_task
abstractmethod
#
finalize_task(task: Task, **kwargs: Any) -> None
完成任务,在所有步骤都完成之后。
Source code in llama_index/core/base/agent/types.py
229 230 231 |
|
set_callback_manager #
set_callback_manager(
callback_manager: CallbackManager,
) -> None
设置回调管理器。
Source code in llama_index/core/base/agent/types.py
233 234 |
|
as_agent #
as_agent(**kwargs: Any) -> AgentRunner
作为代理运行返回。
Source code in llama_index/core/base/agent/types.py
237 238 239 240 241 |
|
Task #
Bases: BaseModel
代理任务。
表示根据用户输入给定的代理运行。
Source code in llama_index/core/base/agent/types.py
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 |
|
TaskStep #
Bases: BaseModel
代理任务步骤。
代表了代理执行运行中的单个输入步骤("任务")给定用户输入。
输出以 TaskStepOutput
的形式返回。
Source code in llama_index/core/base/agent/types.py
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 |
|
get_next_step #
get_next_step(
step_id: str,
input: Optional[str] = None,
step_state: Optional[Dict[str, Any]] = None,
) -> TaskStep
获取下一步的便利函数。
保留任务ID、内存和步骤状态。
Source code in llama_index/core/base/agent/types.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
|
link_step #
link_step(next_step: TaskStep) -> None
链接到下一步。
从当前步骤添加到下一步的链接,以及从下一步到当前步骤的链接。
Source code in llama_index/core/base/agent/types.py
120 121 122 123 124 125 126 127 128 129 |
|
TaskStepOutput #
Bases: BaseModel
代理任务步骤输出。
Source code in llama_index/core/base/agent/types.py
132 133 134 135 136 137 138 139 140 141 142 |
|
Runners#
AgentRunner #
Bases: BaseAgentRunner
代理运行器。
顶层代理协调器,可以创建任务,运行任务中的每个步骤,或者运行端到端的任务。存储状态并跟踪任务。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_worker |
BaseAgentWorker
|
步骤执行器 |
required |
chat_history |
Optional[List[ChatMessage]]
|
聊天历史。默认为None。 |
None
|
state |
Optional[AgentState]
|
代理状态。默认为None。 |
None
|
memory |
Optional[BaseMemory]
|
内存。默认为None。 |
None
|
llm |
Optional[LLM]
|
LLM。默认为None。 |
None
|
callback_manager |
Optional[CallbackManager]
|
回调管理器。默认为None。 |
None
|
init_task_state_kwargs |
Optional[dict]
|
初始化任务状态参数。默认为None。 |
None
|
Source code in llama_index/core/agent/runner/base.py
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 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 |
|
create_task #
create_task(input: str, **kwargs: Any) -> Task
创建任务。
Source code in llama_index/core/agent/runner/base.py
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 |
|
delete_task #
delete_task(task_id: str) -> None
删除任务。
注意:这不会从内存中删除任何先前的执行。
Source code in llama_index/core/agent/runner/base.py
336 337 338 339 340 341 342 343 344 |
|
list_tasks #
list_tasks(**kwargs: Any) -> List[Task]
列出任务。
Source code in llama_index/core/agent/runner/base.py
346 347 348 |
|
get_task #
get_task(task_id: str, **kwargs: Any) -> Task
获取任务。
Source code in llama_index/core/agent/runner/base.py
350 351 352 |
|
get_upcoming_steps #
get_upcoming_steps(
task_id: str, **kwargs: Any
) -> List[TaskStep]
获取接下来的步骤。
Source code in llama_index/core/agent/runner/base.py
354 355 356 |
|
get_completed_steps #
get_completed_steps(
task_id: str, **kwargs: Any
) -> List[TaskStepOutput]
获取已完成的步骤。
Source code in llama_index/core/agent/runner/base.py
358 359 360 |
|
get_task_output #
get_task_output(
task_id: str, **kwargs: Any
) -> TaskStepOutput
获取任务输出。
Source code in llama_index/core/agent/runner/base.py
362 363 364 365 366 367 |
|
get_completed_tasks #
get_completed_tasks(**kwargs: Any) -> List[Task]
获取已完成的任务。
Source code in llama_index/core/agent/runner/base.py
369 370 371 372 373 374 375 376 377 378 |
|
run_step #
run_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/agent/runner/base.py
463 464 465 466 467 468 469 470 471 472 473 474 475 |
|
arun_step
async
#
arun_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/agent/runner/base.py
477 478 479 480 481 482 483 484 485 486 487 488 489 |
|
stream_step #
stream_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/agent/runner/base.py
491 492 493 494 495 496 497 498 499 500 501 502 503 |
|
astream_step
async
#
astream_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/agent/runner/base.py
505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
finalize_response #
finalize_response(
task_id: str,
step_output: Optional[TaskStepOutput] = None,
) -> AGENT_CHAT_RESPONSE_TYPE
完成响应。
Source code in llama_index/core/agent/runner/base.py
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 |
|
undo_step #
undo_step(task_id: str) -> None
撤销上一步操作。
Source code in llama_index/core/agent/runner/base.py
724 725 726 |
|
ParallelAgentRunner #
Bases: BaseAgentRunner
并行代理运行程序。
在队列中并行执行步骤。需要异步支持。
Source code in llama_index/core/agent/runner/parallel.py
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 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 |
|
create_task #
create_task(input: str, **kwargs: Any) -> Task
创建任务。
Source code in llama_index/core/agent/runner/parallel.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
delete_task #
delete_task(task_id: str) -> None
删除任务。
注意:这不会从内存中删除任何先前的执行。
Source code in llama_index/core/agent/runner/parallel.py
127 128 129 130 131 132 133 134 135 |
|
get_completed_tasks #
get_completed_tasks(**kwargs: Any) -> List[Task]
获取已完成的任务。
Source code in llama_index/core/agent/runner/parallel.py
137 138 139 140 141 142 143 144 145 |
|
get_task_output #
get_task_output(task_id: str) -> TaskStepOutput
获取任务输出。
Source code in llama_index/core/agent/runner/parallel.py
147 148 149 150 151 152 |
|
list_tasks #
list_tasks(**kwargs: Any) -> List[Task]
列出任务。
Source code in llama_index/core/agent/runner/parallel.py
154 155 156 157 |
|
get_task #
get_task(task_id: str, **kwargs: Any) -> Task
获取任务。
Source code in llama_index/core/agent/runner/parallel.py
159 160 161 |
|
get_upcoming_steps #
get_upcoming_steps(
task_id: str, **kwargs: Any
) -> List[TaskStep]
获取接下来的步骤。
Source code in llama_index/core/agent/runner/parallel.py
163 164 165 |
|
get_completed_steps #
get_completed_steps(
task_id: str, **kwargs: Any
) -> List[TaskStepOutput]
获取已完成的步骤。
Source code in llama_index/core/agent/runner/parallel.py
167 168 169 |
|
run_steps_in_queue #
run_steps_in_queue(
task_id: str,
mode: ChatResponseMode = ChatResponseMode.WAIT,
**kwargs: Any
) -> List[TaskStepOutput]
执行队列中的步骤。
运行队列中的所有步骤,并清空队列。
假设所有步骤可以并行运行。
Source code in llama_index/core/agent/runner/parallel.py
171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
arun_steps_in_queue
async
#
arun_steps_in_queue(
task_id: str,
mode: ChatResponseMode = ChatResponseMode.WAIT,
**kwargs: Any
) -> List[TaskStepOutput]
执行队列中的所有步骤。
假设队列中的所有步骤都已准备就绪。
Source code in llama_index/core/agent/runner/parallel.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
run_step #
run_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/agent/runner/parallel.py
273 274 275 276 277 278 279 280 281 |
|
arun_step
async
#
arun_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/agent/runner/parallel.py
283 284 285 286 287 288 289 290 291 292 293 |
|
stream_step #
stream_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/agent/runner/parallel.py
295 296 297 298 299 300 301 302 303 |
|
astream_step
async
#
astream_step(
task_id: str,
input: Optional[str] = None,
step: Optional[TaskStep] = None,
**kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/agent/runner/parallel.py
305 306 307 308 309 310 311 312 313 314 315 |
|
finalize_response #
finalize_response(
task_id: str,
step_output: Optional[TaskStepOutput] = None,
) -> AGENT_CHAT_RESPONSE_TYPE
完成响应。
Source code in llama_index/core/agent/runner/parallel.py
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 |
|
undo_step #
undo_step(task_id: str) -> None
撤销上一步操作。
Source code in llama_index/core/agent/runner/parallel.py
489 490 491 |
|
Workers#
CustomSimpleAgentWorker #
Bases: BaseModel
, BaseAgentWorker
自定义简单的代理工作程序。
这里的“简单”是指一些脚手架已经设置好了。
假设:
- 假设代理有工具、llm、回调管理器和工具检索器
- 有一个from_tools
便利函数
- 假设代理是顺序的,并且不接受任何额外的中间输入。
Args: 工具(Sequence[BaseTool]):用于推理的工具 llm(LLM):要使用的LLM callback_manager(CallbackManager):回调管理器 tool_retriever(Optional[ObjectRetriever[BaseTool]]):工具检索器 verbose(bool):是否打印推理步骤
Source code in llama_index/core/agent/custom/simple.py
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 |
|
from_tools
classmethod
#
from_tools(
tools: Optional[Sequence[BaseTool]] = None,
tool_retriever: Optional[
ObjectRetriever[BaseTool]
] = None,
llm: Optional[LLM] = None,
callback_manager: Optional[CallbackManager] = None,
verbose: bool = False,
**kwargs: Any
) -> CustomSimpleAgentWorker
方便的构造方法,用于一组BaseTools(可选)。
Source code in llama_index/core/agent/custom/simple.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
initialize_step #
从任务中初始化步骤。
Source code in llama_index/core/agent/custom/simple.py
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 |
|
get_tools #
get_tools(input: str) -> List[AsyncBaseTool]
获取工具。
Source code in llama_index/core/agent/custom/simple.py
155 156 157 |
|
run_step #
run_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/agent/custom/simple.py
205 206 207 208 209 210 211 212 213 214 |
|
arun_step
async
#
arun_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/agent/custom/simple.py
216 217 218 219 220 221 222 223 224 225 226 |
|
stream_step #
stream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/agent/custom/simple.py
228 229 230 231 |
|
astream_step
async
#
astream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/agent/custom/simple.py
233 234 235 236 237 238 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
完成任务,在所有步骤都完成之后。
Source code in llama_index/core/agent/custom/simple.py
247 248 249 250 251 252 253 |
|
set_callback_manager #
set_callback_manager(
callback_manager: CallbackManager,
) -> None
设置回调管理器。
Source code in llama_index/core/agent/custom/simple.py
255 256 257 258 |
|
MultimodalReActAgentWorker #
Bases: BaseAgentWorker
多模态ReAct代理工作程序。
注意:这是一个测试版功能。
Source code in llama_index/core/agent/react_multimodal/step.py
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 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 |
|
from_tools
classmethod
#
from_tools(
tools: Optional[Sequence[BaseTool]] = None,
tool_retriever: Optional[
ObjectRetriever[BaseTool]
] = None,
multi_modal_llm: Optional[MultiModalLLM] = None,
max_iterations: int = 10,
react_chat_formatter: Optional[
ReActChatFormatter
] = None,
output_parser: Optional[ReActOutputParser] = None,
callback_manager: Optional[CallbackManager] = None,
verbose: bool = False,
**kwargs: Any
) -> MultimodalReActAgentWorker
方便的构造方法,从BaseTools的集合中(可选)。
注意:kwargs在这一点上应该已经用尽。换句话说,各种上游组件,如BaseSynthesizer(响应合成器)或BaseRetriever应该在它们的构造中从各自的kwargs中取出。
返回: ReActAgent
Source code in llama_index/core/agent/react_multimodal/step.py
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 |
|
initialize_step #
从任务中初始化步骤。
Source code in llama_index/core/agent/react_multimodal/step.py
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 |
|
get_tools #
get_tools(input: str) -> List[AsyncBaseTool]
获取工具。
Source code in llama_index/core/agent/react_multimodal/step.py
223 224 225 |
|
run_step #
run_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/agent/react_multimodal/step.py
477 478 479 480 |
|
arun_step
async
#
arun_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/agent/react_multimodal/step.py
482 483 484 485 486 487 |
|
stream_step #
stream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/agent/react_multimodal/step.py
489 490 491 492 493 |
|
astream_step
async
#
astream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/agent/react_multimodal/step.py
495 496 497 498 499 500 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
完成任务,在所有步骤都完成之后。
Source code in llama_index/core/agent/react_multimodal/step.py
502 503 504 505 506 507 508 509 |
|
set_callback_manager #
set_callback_manager(
callback_manager: CallbackManager,
) -> None
设置回调管理器。
Source code in llama_index/core/agent/react_multimodal/step.py
511 512 513 514 |
|
QueryPipelineAgentWorker #
Bases: BaseModel
, BaseAgentWorker
查询管道代理工作程序。
最基本的代理工作程序,接收查询管道作为输入。
假设查询管道中的第一个组件是 AgentInputComponent
,最后一个是 AgentFnComponent
。
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline |
QueryPipeline
|
查询管道 |
required |
Source code in llama_index/core/agent/custom/pipeline_worker.py
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 |
|
initialize_step #
从任务中初始化步骤。
Source code in llama_index/core/agent/custom/pipeline_worker.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
run_step #
run_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤。
Source code in llama_index/core/agent/custom/pipeline_worker.py
144 145 146 147 148 149 150 151 152 153 154 155 |
|
arun_step
async
#
arun_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步)。
Source code in llama_index/core/agent/custom/pipeline_worker.py
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
stream_step #
stream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(流式)。
Source code in llama_index/core/agent/custom/pipeline_worker.py
173 174 175 176 |
|
astream_step
async
#
astream_step(
step: TaskStep, task: Task, **kwargs: Any
) -> TaskStepOutput
运行步骤(异步流)。
Source code in llama_index/core/agent/custom/pipeline_worker.py
178 179 180 181 182 183 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
完成任务,在所有步骤都完成之后。
Source code in llama_index/core/agent/custom/pipeline_worker.py
185 186 187 188 189 190 |
|
set_callback_manager #
set_callback_manager(
callback_manager: CallbackManager,
) -> None
设置回调管理器。
Source code in llama_index/core/agent/custom/pipeline_worker.py
192 193 194 195 196 |
|