vision_agent.agent
vision_agent.agent.agent.Agent
Bases: ABC
log_progress
abstractmethod
Log the progress of the agent. This is a hook that is intended for reporting the progress of the agent.
vision_agent.agent.vision_agent_v2.VisionAgentV2
VisionAgentV2(
agent=None,
coder=None,
hil=False,
verbose=False,
code_sandbox_runtime=None,
update_callback=lambda x: None,
)
Bases: Agent
VisionAgentV2 is a conversational agent that allows you to more easily use a coder agent such as VisionAgentCoderV2 to write vision code for you.
Initialize the VisionAgentV2.
PARAMETER | DESCRIPTION |
---|---|
agent |
The language model to use for the agent. If None, a default AnthropicLMM will be used.
TYPE:
|
coder |
The coder agent to use for generating vision code. If None, a default VisionAgentCoderV2 will be used.
TYPE:
|
hil |
Whether to use human-in-the-loop mode.
TYPE:
|
verbose |
Whether to print out debug information.
TYPE:
|
code_sandbox_runtime |
The code sandbox runtime to use, can be one of: None or "local". If None, it will read from the environment variable CODE_SANDBOX_RUNTIME.
TYPE:
|
update_callback |
The callback function that will send back intermediate conversation messages.
TYPE:
|
Source code in vision_agent/agent/vision_agent_v2.py
coder
instance-attribute
coder = (
coder
if coder is not None
else VisionAgentCoderV2(
verbose=verbose,
update_callback=update_callback,
hil=hil,
)
)
chat
Conversational interface to the agent. This is the main method to use to interact with the agent. It takes in a list of messages and returns the agent's response as a list of messages.
PARAMETER | DESCRIPTION |
---|---|
chat |
The input to the agent. This should be a list of AgentMessage objects.
TYPE:
|
code_interpreter |
The code interpreter to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
List[AgentMessage]
|
List[AgentMessage]: The agent's response as a list of AgentMessage objects. |
Source code in vision_agent/agent/vision_agent_v2.py
vision_agent.agent.vision_agent_coder_v2.VisionAgentCoderV2
VisionAgentCoderV2(
planner=None,
coder=None,
tester=None,
debugger=None,
tool_recommender=None,
hil=False,
verbose=False,
code_sandbox_runtime=None,
update_callback=lambda _: None,
)
Bases: AgentCoder
VisionAgentCoderV2 is an agent that will write vision code for you.
Initialize the VisionAgentCoderV2.
PARAMETER | DESCRIPTION |
---|---|
planner |
The planner agent to use for generating vision plans. If None, a default VisionAgentPlannerV2 will be used.
TYPE:
|
coder |
The language model to use for the coder agent. If None, a default AnthropicLMM will be used.
TYPE:
|
tester |
The language model to use for the tester agent. If None, a default AnthropicLMM will be used.
TYPE:
|
debugger |
The language model to use for the debugger agent.
TYPE:
|
tool_recommender |
The tool recommender to use.
TYPE:
|
hil |
Whether to use human-in-the-loop mode.
TYPE:
|
verbose |
Whether to print out debug information.
TYPE:
|
code_sandbox_runtime |
The code sandbox runtime to use, can be one of: None or "local". If None, it will read from the environment variable CODE_SANDBOX_RUNTIME.
TYPE:
|
update_callback |
The callback function that will send back intermediate conversation messages.
TYPE:
|
Source code in vision_agent/agent/vision_agent_coder_v2.py
planner
instance-attribute
planner = (
planner
if planner is not None
else VisionAgentPlannerV2(
verbose=verbose,
update_callback=update_callback,
hil=hil,
)
)
generate_code
Generate vision code from a conversation.
PARAMETER | DESCRIPTION |
---|---|
chat |
The input to the agent. This should be a list of AgentMessage objects.
TYPE:
|
code_interpreter |
The code interpreter to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CodeContext
|
The generated code as a CodeContext object which includes the code, test code, whether or not it was exceuted successfully, and the execution result.
TYPE:
|
Source code in vision_agent/agent/vision_agent_coder_v2.py
generate_code_from_plan
Generate vision code from a conversation and a previously made plan. This will skip the planning step and go straight to generating code.
PARAMETER | DESCRIPTION |
---|---|
chat |
The input to the agent. This should be a list of AgentMessage objects.
TYPE:
|
plan_context |
The plan context that was previously generated. If plan_context.code is not provided, then the code will be generated from the chat messages.
TYPE:
|
code_interpreter |
The code interpreter to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
CodeContext
|
The generated code as a CodeContext object which includes the code, test code, whether or not it was exceuted successfully, and the execution result.
TYPE:
|
Source code in vision_agent/agent/vision_agent_coder_v2.py
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 |
|
vision_agent.agent.vision_agent_planner_v2.VisionAgentPlannerV2
VisionAgentPlannerV2(
planner=None,
summarizer=None,
critic=None,
max_steps=10,
use_multi_trial_planning=False,
critique_steps=11,
hil=False,
verbose=False,
code_sandbox_runtime=None,
update_callback=lambda _: None,
)
Bases: AgentPlanner
VisionAgentPlannerV2 is a class that generates a plan to solve a vision task.
Initialize the VisionAgentPlannerV2.
PARAMETER | DESCRIPTION |
---|---|
planner |
The language model to use for planning. If None, a default AnthropicLMM will be used.
TYPE:
|
critic |
The language model to use for critiquing the plan. If None, a default AnthropicLMM will be used.
TYPE:
|
max_steps |
The maximum number of steps to plan.
TYPE:
|
use_multi_trial_planning |
Whether to use multi-trial planning.
TYPE:
|
critique_steps |
The number of steps between critiques. If critic steps is larger than max_steps no critiques will be made.
TYPE:
|
hil |
Whether to use human-in-the-loop mode.
TYPE:
|
verbose |
Whether to print out debug information.
TYPE:
|
code_sandbox_runtime |
The code sandbox runtime to use, can be one of: None or "local". If None, it will read from the environment variable CODE_SANDBOX_RUNTIME.
TYPE:
|
update_callback |
The callback function that will send back intermediate conversation messages.
TYPE:
|
Source code in vision_agent/agent/vision_agent_planner_v2.py
summarizer
instance-attribute
summarizer = (
summarizer
if summarizer is not None
else create_summarizer()
)
generate_plan
Generate a plan to solve a vision task.
PARAMETER | DESCRIPTION |
---|---|
chat |
The conversation messages to generate a plan for.
TYPE:
|
max_steps |
The maximum number of steps to plan.
TYPE:
|
code_interpreter |
The code interpreter to use.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
PlanContext
|
The generated plan including the instructions and code snippets needed to solve the task.
TYPE:
|
Source code in vision_agent/agent/vision_agent_planner_v2.py
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 |
|