Core Agent Classes#
Base Types#
Base agent types.
BaseAgent #
Bases: BaseChatEngine
, BaseQueryEngine
Base Agent.
Source code in llama-index-core/llama_index/core/base/agent/types.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 |
|
BaseAgentWorker #
Bases: PromptMixin
, DispatcherSpanMixin
Base agent worker.
Source code in llama-index-core/llama_index/core/base/agent/types.py
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 |
|
initialize_step
abstractmethod
#
Initialize step from task.
Source code in llama-index-core/llama_index/core/base/agent/types.py
208 209 210 |
|
run_step
abstractmethod
#
run_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/base/agent/types.py
212 213 214 |
|
arun_step
abstractmethod
async
#
arun_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/base/agent/types.py
216 217 218 219 220 221 |
|
stream_step
abstractmethod
#
stream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/base/agent/types.py
223 224 225 226 227 |
|
astream_step
abstractmethod
async
#
astream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/base/agent/types.py
229 230 231 232 233 234 |
|
finalize_task
abstractmethod
#
finalize_task(task: Task, **kwargs: Any) -> None
Finalize task, after all the steps are completed.
Source code in llama-index-core/llama_index/core/base/agent/types.py
236 237 238 |
|
set_callback_manager #
set_callback_manager(callback_manager: CallbackManager) -> None
Set callback manager.
Source code in llama-index-core/llama_index/core/base/agent/types.py
240 241 |
|
as_agent #
as_agent(**kwargs: Any) -> AgentRunner
Return as an agent runner.
Source code in llama-index-core/llama_index/core/base/agent/types.py
244 245 246 247 248 |
|
Task #
Bases: BaseModel
Agent Task.
Represents a "run" of an agent given a user input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
Task ID |
'6b89a67b-0847-4537-8d85-49f98b9ec05b'
|
input
|
str
|
User input |
required |
memory
|
BaseMemory
|
Conversational Memory. Maintains state before execution of this task. |
required |
callback_manager
|
CallbackManager
|
Callback manager for the task. |
<llama_index.core.callbacks.base.CallbackManager object at 0x7f3b5c19eb40>
|
extra_state
|
Dict[str, Any]
|
Additional user-specified state for a given task. Can be modified throughout the execution of a task. |
{}
|
Source code in llama-index-core/llama_index/core/base/agent/types.py
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 |
|
TaskStep #
Bases: BaseModel
Agent task step.
Represents a single input step within the execution run ("Task") of an agent given a user input.
The output is returned as a TaskStepOutput
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
task_id
|
str
|
Task ID |
required |
step_id
|
str
|
Step ID |
required |
input
|
str | None
|
User input |
None
|
step_state
|
Dict[str, Any]
|
Additional state for a given step. |
{}
|
next_steps
|
Dict[str, TaskStep]
|
Next steps to be executed. |
{}
|
prev_steps
|
Dict[str, TaskStep]
|
Previous steps that were dependencies for this step. |
{}
|
is_ready
|
bool
|
Is this step ready to be executed? |
True
|
Source code in llama-index-core/llama_index/core/base/agent/types.py
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 |
|
get_next_step #
get_next_step(step_id: str, input: Optional[str] = None, step_state: Optional[Dict[str, Any]] = None) -> TaskStep
Convenience function to get next step.
Preserve task_id, memory, step_state.
Source code in llama-index-core/llama_index/core/base/agent/types.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
link_step #
link_step(next_step: TaskStep) -> None
Link to next step.
Add link from this step to next, and from next step to current.
Source code in llama-index-core/llama_index/core/base/agent/types.py
130 131 132 133 134 135 136 137 138 139 140 |
|
TaskStepOutput #
Bases: BaseModel
Agent task step output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output
|
Any
|
Task step output |
required |
task_step
|
TaskStep
|
Task step input |
required |
next_steps
|
List[TaskStep]
|
Next steps to be executed. |
required |
is_last
|
bool
|
Is this the last step? |
False
|
Source code in llama-index-core/llama_index/core/base/agent/types.py
143 144 145 146 147 148 149 150 151 152 153 |
|
Runners#
AgentRunner #
Bases: BaseAgentRunner
Agent runner.
Top-level agent orchestrator that can create tasks, run each step in a task, or run a task e2e. Stores state and keeps track of tasks.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
agent_worker
|
BaseAgentWorker
|
step executor |
required |
chat_history
|
Optional[List[ChatMessage]]
|
chat history. Defaults to None. |
None
|
state
|
Optional[AgentState]
|
agent state. Defaults to None. |
None
|
memory
|
Optional[BaseMemory]
|
memory. Defaults to None. |
None
|
llm
|
Optional[LLM]
|
LLM. Defaults to None. |
None
|
callback_manager
|
Optional[CallbackManager]
|
callback manager. Defaults to None. |
None
|
init_task_state_kwargs
|
Optional[dict]
|
init task state kwargs. Defaults to None. |
None
|
Source code in llama-index-core/llama_index/core/agent/runner/base.py
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 727 728 729 730 731 732 733 734 735 736 |
|
create_task #
create_task(input: str, **kwargs: Any) -> Task
Create task.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
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 |
|
delete_task #
delete_task(task_id: str) -> None
Delete task.
NOTE: this will not delete any previous executions from memory.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
340 341 342 343 344 345 346 347 348 349 |
|
list_tasks #
list_tasks(**kwargs: Any) -> List[Task]
List tasks.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
351 352 353 |
|
get_task #
get_task(task_id: str, **kwargs: Any) -> Task
Get task.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
355 356 357 |
|
get_upcoming_steps #
get_upcoming_steps(task_id: str, **kwargs: Any) -> List[TaskStep]
Get upcoming steps.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
359 360 361 |
|
get_completed_steps #
get_completed_steps(task_id: str, **kwargs: Any) -> List[TaskStepOutput]
Get completed steps.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
363 364 365 |
|
get_task_output #
get_task_output(task_id: str, **kwargs: Any) -> TaskStepOutput
Get task output.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
367 368 369 370 371 372 |
|
get_completed_tasks #
get_completed_tasks(**kwargs: Any) -> List[Task]
Get completed tasks.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
374 375 376 377 378 379 380 381 382 383 |
|
run_step #
run_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
469 470 471 472 473 474 475 476 477 478 479 480 481 |
|
arun_step
async
#
arun_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/agent/runner/base.py
483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
stream_step #
stream_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/agent/runner/base.py
497 498 499 500 501 502 503 504 505 506 507 508 509 |
|
astream_step
async
#
astream_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/agent/runner/base.py
511 512 513 514 515 516 517 518 519 520 521 522 523 |
|
finalize_response #
finalize_response(task_id: str, step_output: Optional[TaskStepOutput] = None) -> AGENT_CHAT_RESPONSE_TYPE
Finalize response.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
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 |
|
undo_step #
undo_step(task_id: str) -> None
Undo previous step.
Source code in llama-index-core/llama_index/core/agent/runner/base.py
734 735 736 |
|
ParallelAgentRunner #
Bases: BaseAgentRunner
Parallel agent runner.
Executes steps in queue in parallel. Requires async support.
Source code in llama-index-core/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 492 493 494 495 496 |
|
create_task #
create_task(input: str, **kwargs: Any) -> Task
Create task.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
delete_task #
delete_task(task_id: str) -> None
Delete task.
NOTE: this will not delete any previous executions from memory.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
129 130 131 132 133 134 135 136 137 138 |
|
get_completed_tasks #
get_completed_tasks(**kwargs: Any) -> List[Task]
Get completed tasks.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
140 141 142 143 144 145 146 147 148 |
|
get_task_output #
get_task_output(task_id: str, **kwargs: Any) -> TaskStepOutput
Get task output.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
150 151 152 153 154 155 |
|
list_tasks #
list_tasks(**kwargs: Any) -> List[Task]
List tasks.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
157 158 159 160 |
|
get_task #
get_task(task_id: str, **kwargs: Any) -> Task
Get task.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
162 163 164 |
|
get_upcoming_steps #
get_upcoming_steps(task_id: str, **kwargs: Any) -> List[TaskStep]
Get upcoming steps.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
166 167 168 |
|
get_completed_steps #
get_completed_steps(task_id: str, **kwargs: Any) -> List[TaskStepOutput]
Get completed steps.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
170 171 172 |
|
run_steps_in_queue #
run_steps_in_queue(task_id: str, mode: ChatResponseMode = WAIT, **kwargs: Any) -> List[TaskStepOutput]
Execute steps in queue.
Run all steps in queue, clearing it out.
Assume that all steps can be run in parallel.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
arun_steps_in_queue
async
#
arun_steps_in_queue(task_id: str, mode: ChatResponseMode = WAIT, **kwargs: Any) -> List[TaskStepOutput]
Execute all steps in queue.
All steps in queue are assumed to be ready.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
run_step #
run_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
278 279 280 281 282 283 284 285 286 |
|
arun_step
async
#
arun_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
288 289 290 291 292 293 294 295 296 297 298 |
|
stream_step #
stream_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
300 301 302 303 304 305 306 307 308 |
|
astream_step
async
#
astream_step(task_id: str, input: Optional[str] = None, step: Optional[TaskStep] = None, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
310 311 312 313 314 315 316 317 318 319 320 |
|
finalize_response #
finalize_response(task_id: str, step_output: Optional[TaskStepOutput] = None) -> AGENT_CHAT_RESPONSE_TYPE
Finalize response.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
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 |
|
undo_step #
undo_step(task_id: str) -> None
Undo previous step.
Source code in llama-index-core/llama_index/core/agent/runner/parallel.py
494 495 496 |
|
Workers#
CustomSimpleAgentWorker #
Bases: BaseModel
, BaseAgentWorker
Custom simple agent worker.
This is "simple" in the sense that some of the scaffolding is setup already.
Assumptions:
- assumes that the agent has tools, llm, callback manager, and tool retriever
- has a from_tools
convenience function
- assumes that the agent is sequential, and doesn't take in any additional
intermediate inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tools
|
Sequence[BaseTool]
|
Tools to use for reasoning |
required |
llm
|
LLM
|
LLM to use |
required |
callback_manager
|
CallbackManager
|
Callback manager |
required |
tool_retriever
|
Optional[ObjectRetriever[BaseTool]]
|
Tool retriever |
required |
verbose
|
bool
|
Whether to print out reasoning steps |
required |
Source code in llama-index-core/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 259 260 261 |
|
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
Convenience constructor method from set of BaseTools (Optional).
Source code in llama-index-core/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 #
Initialize step from task.
Source code in llama-index-core/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]
Get tools.
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
155 156 157 |
|
run_step #
run_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
207 208 209 210 211 212 213 214 215 216 |
|
arun_step
async
#
arun_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
218 219 220 221 222 223 224 225 226 227 228 |
|
stream_step #
stream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
230 231 232 233 |
|
astream_step
async
#
astream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
235 236 237 238 239 240 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
Finalize task, after all the steps are completed.
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
250 251 252 253 254 255 256 |
|
set_callback_manager #
set_callback_manager(callback_manager: CallbackManager) -> None
Set callback manager.
Source code in llama-index-core/llama_index/core/agent/custom/simple.py
258 259 260 261 |
|
MultimodalReActAgentWorker #
Bases: BaseAgentWorker
Multimodal ReAct Agent worker.
NOTE: This is a BETA feature.
Source code in llama-index-core/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 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 |
|
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
Convenience constructor method from set of BaseTools (Optional).
NOTE: kwargs should have been exhausted by this point. In other words the various upstream components such as BaseSynthesizer (response synthesizer) or BaseRetriever should have picked up off their respective kwargs in their constructions.
Returns:
Type | Description |
---|---|
MultimodalReActAgentWorker
|
ReActAgent |
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
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 |
|
initialize_step #
Initialize step from task.
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
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 |
|
get_tools #
get_tools(input: str) -> List[AsyncBaseTool]
Get tools.
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
235 236 237 |
|
run_step #
run_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
494 495 496 497 |
|
arun_step
async
#
arun_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
499 500 501 502 503 504 |
|
stream_step #
stream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
506 507 508 509 510 |
|
astream_step
async
#
astream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
512 513 514 515 516 517 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
Finalize task, after all the steps are completed.
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
519 520 521 522 523 524 525 526 |
|
set_callback_manager #
set_callback_manager(callback_manager: CallbackManager) -> None
Set callback manager.
Source code in llama-index-core/llama_index/core/agent/react_multimodal/step.py
528 529 530 531 |
|
QueryPipelineAgentWorker #
Bases: BaseModel
, BaseAgentWorker
Query Pipeline agent worker.
NOTE: This is now deprecated. Use FnAgentWorker
instead to build a stateful agent.
Barebones agent worker that takes in a query pipeline.
Default Workflow: The default workflow assumes that you compose
a query pipeline with StatefulFnComponent
objects. This allows you to store, update
and retrieve state throughout the executions of the query pipeline by the agent.
The task and step state of the agent are stored in this state
variable via a special key.
Of course you can choose to store other variables in this state as well.
Deprecated Workflow: The deprecated workflow assumes that the first component in the
query pipeline is an AgentInputComponent
and last is AgentFnComponent
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pipeline
|
QueryPipeline
|
Query pipeline |
required |
callback_manager
|
CallbackManager
|
|
required |
task_key
|
str
|
Key to store task in state |
'task'
|
step_state_key
|
str
|
Key to store step in state |
'step_state'
|
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
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 |
|
agent_input_component
property
#
agent_input_component: AgentInputComponent
Get agent input component.
NOTE: This is deprecated and will be removed in the future.
agent_components
property
#
agent_components: Sequence[BaseAgentComponent]
Get agent output component.
preprocess #
Preprocessing flow.
This runs preprocessing to propagate the task and step as variables to relevant components in the query pipeline.
Contains deprecated flow of updating agent components. But also contains main flow of updating StatefulFnComponent components.
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
initialize_step #
Initialize step from task.
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
run_step #
run_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step.
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
|
arun_step
async
#
arun_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async).
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
stream_step #
stream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (stream).
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
233 234 235 236 |
|
astream_step
async
#
astream_step(step: TaskStep, task: Task, **kwargs: Any) -> TaskStepOutput
Run step (async stream).
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
238 239 240 241 242 243 |
|
finalize_task #
finalize_task(task: Task, **kwargs: Any) -> None
Finalize task, after all the steps are completed.
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
245 246 247 248 249 250 |
|
set_callback_manager #
set_callback_manager(callback_manager: CallbackManager) -> None
Set callback manager.
Source code in llama-index-core/llama_index/core/agent/custom/pipeline_worker.py
252 253 254 255 256 |
|