steamship.agents.tools.classification package#

Submodules#

steamship.agents.tools.classification.multiple_choice_tool module#

class steamship.agents.tools.classification.multiple_choice_tool.MultipleChoiceOption(*, name: str, description: str | None = None, question: MultipleChoiceQuestion | None = None)[source]#

Bases: BaseModel

description: str | None#
name: str#
question: MultipleChoiceQuestion | None#
to_prompt_string(number: int)[source]#

Return the prompt representation of this option.

class steamship.agents.tools.classification.multiple_choice_tool.MultipleChoiceQuestion(*, question: str = 'What category does the following text best relate to?', options: List[MultipleChoiceOption])[source]#

Bases: BaseModel

option_from_answer(answer: str)[source]#

Return the option (1-indexed) from the prompt response.

options: List[MultipleChoiceOption]#
question: str#
to_options_string()[source]#

Return the list of options for this question, 1-indexed.

class steamship.agents.tools.classification.multiple_choice_tool.MultipleChoiceTool(*, name: str = 'MultipleChoiceTool', agent_description: str = 'Used to transform a user message into a structured answer from a multiple choice question.', human_description: str = 'Turns a user input into a multiple choice selection.', is_final: bool = False, cacheable: bool = True, question: MultipleChoiceQuestion = MultipleChoiceQuestion(question='What category does the following text best relate to?', options=[MultipleChoiceOption(name='Countries', description=None, question=MultipleChoiceQuestion(question='What category does the following text best relate to?', options=[MultipleChoiceOption(name='USA', description=None, question=None), MultipleChoiceOption(name='Canada', description=None, question=None), MultipleChoiceOption(name='Mexico', description=None, question=None), MultipleChoiceOption(name='Taiwan', description=None, question=None)])), MultipleChoiceOption(name='Food', description=None, question=MultipleChoiceQuestion(question='What category does the following text best relate to?', options=[MultipleChoiceOption(name='Breakfast', description=None, question=None), MultipleChoiceOption(name='Lunch', description=None, question=None), MultipleChoiceOption(name='Dinner', description=None, question=None)])), MultipleChoiceOption(name='Other', description=None, question=None)]), rewrite_prompt: str = 'Multiple Choice Exam.\n\n{question}\n\nText:\n{input}\n\nPossible Answers:\n{options}\n\nYour answer. Respond with ONLY the number of the correct option:')[source]#

Bases: Tool

Example tool to illustrate how one can parse a user response into a fixed multiple-choice answer.

Supports traversing a hierarchical tree of multiple-choice answers.

question: MultipleChoiceQuestion#
rewrite_prompt: str#
run(tool_input: List[Block], context: AgentContext) 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.

steamship.agents.tools.classification.sentiment_analysis_tool module#

class steamship.agents.tools.classification.sentiment_analysis_tool.SentimentAnalysisTool(labels: List[str] | None = None, rewrite_prompt: str | None = None, *, name: str = 'SentimentAnalysisTool', agent_description: str = 'Used to record the sentiment of a user message. The input is a string, and the output is a string with the sentiment.', human_description: str = 'Returns the sentiment of a user message.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate how one might classify a user message with a sentiment.

TODO: This feels like it wants to emit data to a side channel. Or perhaps it TAGS the user input block?

labels: List[str]#
rewrite_prompt: str#

steamship.agents.tools.classification.zero_shot_classifier_tool module#

class steamship.agents.tools.classification.zero_shot_classifier_tool.ZeroShotClassifierTool(labels: List[str] | None = None, rewrite_prompt: str | None = None, *, name: str = 'ZeroShotClassifierTool', agent_description: str = 'Used to classify a user message. The input is a string, and the output is a string with the classification label.', human_description: str = 'Classifies a user message.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate how one might classify a user message.

For example: the agent may wish to know if the use message was a question, complaint, or suggestion.

TODO: This feels like it wants to emit data to a side channel. Or perhaps it TAGS the user input block?

labels: List[str]#
rewrite_prompt: str#

Module contents#

class steamship.agents.tools.classification.SentimentAnalysisTool(labels: List[str] | None = None, rewrite_prompt: str | None = None, *, name: str = 'SentimentAnalysisTool', agent_description: str = 'Used to record the sentiment of a user message. The input is a string, and the output is a string with the sentiment.', human_description: str = 'Returns the sentiment of a user message.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate how one might classify a user message with a sentiment.

TODO: This feels like it wants to emit data to a side channel. Or perhaps it TAGS the user input block?

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.

cacheable: bool#

Whether runs of this Tool should be cached based on inputs (if caching is enabled in the AgentContext for a run). Setting this to False will make prevent any Actions that involve this tool from being cached, meaning that every Action using this Tool will result in a call to run. By default, Tools are considered cacheable.

human_description: str#

Human-friendly description. Used for logging, tool indices, etc.

is_final: bool#

Whether actions performed by this tool should have their is_final bit marked.

Setting this to True means that the output of this tool will halt the reasoning loop. Its output will be returned directly to the user.

labels: List[str]#
name: str#

The short name for the tool. This will be used by Agents to refer to this tool during action selection.

rewrite_prompt: str#
class steamship.agents.tools.classification.ZeroShotClassifierTool(labels: List[str] | None = None, rewrite_prompt: str | None = None, *, name: str = 'ZeroShotClassifierTool', agent_description: str = 'Used to classify a user message. The input is a string, and the output is a string with the classification label.', human_description: str = 'Classifies a user message.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate how one might classify a user message.

For example: the agent may wish to know if the use message was a question, complaint, or suggestion.

TODO: This feels like it wants to emit data to a side channel. Or perhaps it TAGS the user input block?

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.

cacheable: bool#

Whether runs of this Tool should be cached based on inputs (if caching is enabled in the AgentContext for a run). Setting this to False will make prevent any Actions that involve this tool from being cached, meaning that every Action using this Tool will result in a call to run. By default, Tools are considered cacheable.

human_description: str#

Human-friendly description. Used for logging, tool indices, etc.

is_final: bool#

Whether actions performed by this tool should have their is_final bit marked.

Setting this to True means that the output of this tool will halt the reasoning loop. Its output will be returned directly to the user.

labels: List[str]#
name: str#

The short name for the tool. This will be used by Agents to refer to this tool during action selection.

rewrite_prompt: str#