steamship.agents.schema package#
Submodules#
steamship.agents.schema.action module#
- class steamship.agents.schema.action.Action(*, tool: Tool, input: List[Block], output: Optional[List[Block]] = [])[source]#
Bases:
BaseModel
Actions represent a binding of a Tool to the inputs supplied to the tool.
Upon completion, the Action also contains the output of the Tool given the inputs.
- class steamship.agents.schema.action.AgentTool(*, name: str = 'Agent', agent_description: str = '', human_description: str = 'Placeholder tool object for FinishAction')[source]#
Bases:
Tool
- run(tool_input: List[Block], context: AgentContext) Union[List[Block], Task[Any]] [source]#
Run the tool given the provided input and context.
At the moment, only synchronous Tools (those that return List[Block]) are supported.
Support for asynchronous Tools (those that return Task[Any]) will be added shortly.
- class steamship.agents.schema.action.FinishAction(*, tool: Tool = AgentTool(name='Agent', agent_description='', human_description='Placeholder tool object for FinishAction'), input: List[Block] = [], output: Optional[List[Block]] = [])[source]#
Bases:
Action
Represents a final selected action in an Agent Execution.
steamship.agents.schema.agent module#
- class steamship.agents.schema.agent.Agent(*, tools: List[Tool])[source]#
Bases:
BaseModel
,ABC
Agent is responsible for choosing the next action to take for an AgentService.
It uses the provided context, and a set of Tools, to decide on an action that will be executed by the AgentService.
- abstract next_action(context: AgentContext) Action [source]#
- class steamship.agents.schema.agent.LLMAgent(*, tools: List[Tool], llm: LLM, output_parser: OutputParser)[source]#
Bases:
Agent
LLMAgents choose next actions for an AgentService based on interactions with an LLM.
- abstract next_action(context: AgentContext) Action [source]#
- output_parser: OutputParser#
Utility responsible for converting LLM output into Actions
steamship.agents.schema.context module#
- class steamship.agents.schema.context.AgentContext[source]#
Bases:
object
AgentContext contains all relevant information about a particular execution of an Agent. It is used by the AgentService to manage execution history as well as store/retrieve information and metadata that will be used in the process of an agent execution.
- chat_history: ChatHistory#
Record of user-package messages. It records user submitted queries/prompts and the final agent-driven answer sent in response to those queries/prompts. It does NOT record any chat history related to agent execution and action selection.
- completed_steps: List[Action] = []#
Record of agent-selected Actions and their outputs. This provides an ordered look at the execution sequence for this context.
- emit_funcs: List[Callable[[List[Block], Dict[str, Any]], None]] = []#
Called when an agent execution has completed. These provide a way for the AgentService to return the result of an agent execution to the package that requested the agent execution.
steamship.agents.schema.llm module#
steamship.agents.schema.output_parser module#
- class steamship.agents.schema.output_parser.OutputParser[source]#
Bases:
BaseModel
,ABC
Used to convert text into Actions.
Primarily used by LLM-based agents that generate textual descriptions of selected actions and their inputs. OutputParsers can be used to convert those descriptions into Action objects for the AgentService to run.
Example
- input: “Action: GenerateImage
ActionInput: row-house”
output: Action(“dalle”, “row-house”)
- abstract parse(text: str, context: AgentContext) Action [source]#
Convert text into an Action object.
steamship.agents.schema.tool module#
- class steamship.agents.schema.tool.AgentContext[source]#
Bases:
BaseModel
Placeholder to avoid circular dependency.
- class steamship.agents.schema.tool.Tool(*, name: str, agent_description: str, human_description: str)[source]#
Bases:
BaseModel
Tools provide functionality that may be used by AgentServices, as directed by Agents, to achieve a goal.
Tools may be used to wrap Steamship packages and plugins, as well as third-party backend services, and even locally-contained bits of Python code.
- agent_description: str#
Description for use in an agent in order to enable Action selection. It should include a short summary of what the Tool does, what the inputs to the Tool should be, and what the outputs of the tool are.
- name: str#
The short name for the tool. This will be used by Agents to refer to this tool during action selection.
- post_process(async_task: Task, context: AgentContext) List[Block] [source]#
Transforms Task output into a List[Block].
- abstract run(tool_input: List[Block], context: AgentContext) Union[List[Block], Task[Any]] [source]#
Run the tool given the provided input and context.
At the moment, only synchronous Tools (those that return List[Block]) are supported.
Support for asynchronous Tools (those that return Task[Any]) will be added shortly.
Module contents#
- class steamship.agents.schema.Action(*, tool: Tool, input: List[Block], output: Optional[List[Block]] = [])[source]#
Bases:
BaseModel
Actions represent a binding of a Tool to the inputs supplied to the tool.
Upon completion, the Action also contains the output of the Tool given the inputs.
- class steamship.agents.schema.Agent(*, tools: List[Tool])[source]#
Bases:
BaseModel
,ABC
Agent is responsible for choosing the next action to take for an AgentService.
It uses the provided context, and a set of Tools, to decide on an action that will be executed by the AgentService.
- abstract next_action(context: AgentContext) Action [source]#
- class steamship.agents.schema.AgentContext[source]#
Bases:
object
AgentContext contains all relevant information about a particular execution of an Agent. It is used by the AgentService to manage execution history as well as store/retrieve information and metadata that will be used in the process of an agent execution.
- chat_history: ChatHistory#
Record of user-package messages. It records user submitted queries/prompts and the final agent-driven answer sent in response to those queries/prompts. It does NOT record any chat history related to agent execution and action selection.
- completed_steps: List[Action] = []#
Record of agent-selected Actions and their outputs. This provides an ordered look at the execution sequence for this context.
- emit_funcs: List[Callable[[List[Block], Dict[str, Any]], None]] = []#
Called when an agent execution has completed. These provide a way for the AgentService to return the result of an agent execution to the package that requested the agent execution.
- class steamship.agents.schema.FinishAction(*, tool: Tool = AgentTool(name='Agent', agent_description='', human_description='Placeholder tool object for FinishAction'), input: List[Block] = [], output: Optional[List[Block]] = [])[source]#
Bases:
Action
Represents a final selected action in an Agent Execution.
- class steamship.agents.schema.LLM[source]#
Bases:
BaseModel
,ABC
LLM wraps large language model-based backends.
They may be used with LLMAgents in Action selection, or for direct prompt completion.
- class steamship.agents.schema.LLMAgent(*, tools: List[Tool], llm: LLM, output_parser: OutputParser)[source]#
Bases:
Agent
LLMAgents choose next actions for an AgentService based on interactions with an LLM.
- abstract next_action(context: AgentContext) Action [source]#
- output_parser: OutputParser#
Utility responsible for converting LLM output into Actions
- class steamship.agents.schema.OutputParser[source]#
Bases:
BaseModel
,ABC
Used to convert text into Actions.
Primarily used by LLM-based agents that generate textual descriptions of selected actions and their inputs. OutputParsers can be used to convert those descriptions into Action objects for the AgentService to run.
Example
- input: “Action: GenerateImage
ActionInput: row-house”
output: Action(“dalle”, “row-house”)
- abstract parse(text: str, context: AgentContext) Action [source]#
Convert text into an Action object.
- class steamship.agents.schema.Tool(*, name: str, agent_description: str, human_description: str)[source]#
Bases:
BaseModel
Tools provide functionality that may be used by AgentServices, as directed by Agents, to achieve a goal.
Tools may be used to wrap Steamship packages and plugins, as well as third-party backend services, and even locally-contained bits of Python code.
- agent_description: str#
Description for use in an agent in order to enable Action selection. It should include a short summary of what the Tool does, what the inputs to the Tool should be, and what the outputs of the tool are.
- name: str#
The short name for the tool. This will be used by Agents to refer to this tool during action selection.
- post_process(async_task: Task, context: AgentContext) List[Block] [source]#
Transforms Task output into a List[Block].
- abstract run(tool_input: List[Block], context: AgentContext) Union[List[Block], Task[Any]] [source]#
Run the tool given the provided input and context.
At the moment, only synchronous Tools (those that return List[Block]) are supported.
Support for asynchronous Tools (those that return Task[Any]) will be added shortly.