steamship.agents.tools.text_generation package#

Submodules#

steamship.agents.tools.text_generation.custom_llm_prompt module#

steamship.agents.tools.text_generation.image_prompt_generator_tool module#

class steamship.agents.tools.text_generation.image_prompt_generator_tool.ImagePromptGeneratorTool(*, name: str = 'ImagePromptGenerator', agent_description: str = 'Use this tool to improve a prompt for stable diffusion and other image and video generators. This tool will refine your prompt to include key words and phrases that make stable diffusion and other art generation algorithms perform better. The input is a prompt text string and the output is a prompt text string', human_description: str = 'Improves a prompt for use with image generation.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease rewrite the following passage to create an excellent prompt for use with DALL-E or Stable Diffusion. Add\nkeywords that improve the drama and style to create dramatic, photographic effects.\n\nPassage:\n{input}\n\nImage Generation Prompt:')[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting an input query to become a better prompt.

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.

human_description: str#

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

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#

steamship.agents.tools.text_generation.json_object_generator module#

class steamship.agents.tools.text_generation.json_object_generator.JsonObjectGeneratorTool(*args, name: str = 'JsonObjectTool', agent_description: str = '(set at initialization time)', human_description: str = 'Generates a new JSON object.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'INSTRUCTIONS:\nGenerate a JSON object describing {table_description}.\nAlways return a non-empty value for every field in the object.\n\nFIELDS DESIRED:\n{fields_desired}\n\nEXAMPLE OBJECTS:\n{example_objects}\n\nNEW OBJECT:\n{new_object_prefix}\n', plural_object_description: str = 'employees of a company', object_keys: List[str] = ['Name', 'Age', 'Gender'], example_rows: List[List[str]] = [['Bob', 30, 'Male'], ['Susan', 32, 'Female'], ['Zhenzhong', 40, 'Male'], ['Luis', 32, 'Male'], ['Roberta', 35, 'Female'], ['Sofia', 30, 'Female']], new_row_prefix_fields: List[str] = [], shuffle_example_rows: bool = True, validate_output_as_json: bool = True)[source]#

Bases: Tool

Example tool to illustrate generating a new JSON object provided a set of examples.

This is useful as an example of how to generate a new structured object:

  • A Person (e.g. name, gender, age)

  • A Proposed Podcast Episode (e.g. title, description, tags)

The tool takes no input at runtime: it’s a true generator parameterized only at initializtion time.

The tool’s parameterization is somewhat CSV-like in construction.

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.

example_rows: List[List[str]]#

List of example object values, aligned to the object_keys parameter.

human_description: str#

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

kv_clause(key: str, value: str) str[source]#

Return an escaped, JSON style key-value clause “key”: “value”

name: str#

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

new_row_prefix_fields: List[str]#

Any fields that should be hard-coded for the new row. These must be grouped as the first set of fields.

object_json(schema: List[str], values: List[str])[source]#

Render a CSV-style header row and value list into a JSON object.

object_keys: List[str]#

The keys the JSON should have.

plural_object_description: str#

Plural description of the object. E.g. ‘employees of a company’ or ‘people’ or ‘podcast episodes’

rewrite_prompt: str#

The prompt used to generate a new JSON object.

run(tool_input: List[Block], context: AgentContext) List[Block] | Task[Any][source]#

Ignore tool input and generate a JSON object described by the tool’s configuration.

Inputs#

input: List[Block]

A list of blocks that will be ignored.

memory: AgentContext

The active AgentContext.

Output#

output: List[Blocks]

A single block containing a new row of the table described by the tool’s configuration.

shuffle_example_rows: bool#

Whether randomly shuffle example rows to induce a bit of variety even with low LLM temperature.

validate_output_as_json: bool#

Whether to validate that the output is actually JSON.

steamship.agents.tools.text_generation.personality_tool module#

class steamship.agents.tools.text_generation.personality_tool.PersonalityTool(personality: str | None = None, rewrite_prompt: str | None = None, *, name: str = 'PersonalityTool', agent_description: str = 'Used to provide a response with a particular personality. Takes a message as input, and provides a message as output.', human_description: str = 'Rewrites a response with the given personality.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

human_description: str#

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

name: str#

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

personality: str#
rewrite_prompt: str#

steamship.agents.tools.text_generation.summarize_text_with_prompt_tool module#

class steamship.agents.tools.text_generation.summarize_text_with_prompt_tool.SummarizeTextWithPromptTool(*, name: str = 'SummarizeTextWithPromptTool', agent_description: str = 'Use this tool to summarize text. The input is the text needing summarization. The output is a summary of the text.', human_description: str = 'Summarizes text using an LLM prompt.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease summarize the following document so that the key points are represented in a way that stand alone for reading.\n\nDOCUMENT\n========\n\n{input}\n\nONE PARAGRAPH SUMMARY\n=====================')[source]#

Bases: TextRewritingTool

Example tool to illustrate summarizing an input document using prompt engineering.

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.

human_description: str#

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

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#

steamship.agents.tools.text_generation.text_rewrite_tool module#

class steamship.agents.tools.text_generation.text_rewrite_tool.TextRewritingTool(*, name: str = 'TextRewritingTool', agent_description: str = 'Used to rewrite a piece of text given a prompt. Takes text as input, and provides text as output.', human_description: str = 'Rewrites a piece of text using the provided prompt.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease rewrite the following passage to be incredibly polite, to a fault.\nPassage:\n{input}\nRewritten Passage:')[source]#

Bases: Tool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

human_description: str#

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

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#
run(tool_input: List[Block], context: AgentContext) List[Block] | Task[Any][source]#

Rewrites each provided text block using the stored prompt. Non-text blocks are passed through without modification.

Inputs#

input: List[Block]

A list of blocks to be rewritten if they contain text. Each block will be considered a separate input.

memory: AgentContext

The active AgentContext.

Output#

output: List[Blocks]

A list of blocks whose content has been rewritten. Synchronously produced (for now).

steamship.agents.tools.text_generation.text_translation_tool module#

class steamship.agents.tools.text_generation.text_translation_tool.TextTranslationTool(language: str | None = None, rewrite_prompt: str | None = None, *, name: str = 'TextTranslationTool', agent_description: str = '(set dynamically)', human_description: str = 'Translates a text into a new language.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

human_description: str#

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

language: 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#

Module contents#

class steamship.agents.tools.text_generation.ImagePromptGeneratorTool(*, name: str = 'ImagePromptGenerator', agent_description: str = 'Use this tool to improve a prompt for stable diffusion and other image and video generators. This tool will refine your prompt to include key words and phrases that make stable diffusion and other art generation algorithms perform better. The input is a prompt text string and the output is a prompt text string', human_description: str = 'Improves a prompt for use with image generation.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease rewrite the following passage to create an excellent prompt for use with DALL-E or Stable Diffusion. Add\nkeywords that improve the drama and style to create dramatic, photographic effects.\n\nPassage:\n{input}\n\nImage Generation Prompt:')[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting an input query to become a better prompt.

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.

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.text_generation.JsonObjectGeneratorTool(*args, name: str = 'JsonObjectTool', agent_description: str = '(set at initialization time)', human_description: str = 'Generates a new JSON object.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'INSTRUCTIONS:\nGenerate a JSON object describing {table_description}.\nAlways return a non-empty value for every field in the object.\n\nFIELDS DESIRED:\n{fields_desired}\n\nEXAMPLE OBJECTS:\n{example_objects}\n\nNEW OBJECT:\n{new_object_prefix}\n', plural_object_description: str = 'employees of a company', object_keys: List[str] = ['Name', 'Age', 'Gender'], example_rows: List[List[str]] = [['Bob', 30, 'Male'], ['Susan', 32, 'Female'], ['Zhenzhong', 40, 'Male'], ['Luis', 32, 'Male'], ['Roberta', 35, 'Female'], ['Sofia', 30, 'Female']], new_row_prefix_fields: List[str] = [], shuffle_example_rows: bool = True, validate_output_as_json: bool = True)[source]#

Bases: Tool

Example tool to illustrate generating a new JSON object provided a set of examples.

This is useful as an example of how to generate a new structured object:

  • A Person (e.g. name, gender, age)

  • A Proposed Podcast Episode (e.g. title, description, tags)

The tool takes no input at runtime: it’s a true generator parameterized only at initializtion time.

The tool’s parameterization is somewhat CSV-like in construction.

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.

example_rows: List[List[str]]#

List of example object values, aligned to the object_keys parameter.

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.

kv_clause(key: str, value: str) str[source]#

Return an escaped, JSON style key-value clause “key”: “value”

name: str#

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

new_row_prefix_fields: List[str]#

Any fields that should be hard-coded for the new row. These must be grouped as the first set of fields.

object_json(schema: List[str], values: List[str])[source]#

Render a CSV-style header row and value list into a JSON object.

object_keys: List[str]#

The keys the JSON should have.

plural_object_description: str#

Plural description of the object. E.g. ‘employees of a company’ or ‘people’ or ‘podcast episodes’

rewrite_prompt: str#

The prompt used to generate a new JSON object.

run(tool_input: List[Block], context: AgentContext) List[Block] | Task[Any][source]#

Ignore tool input and generate a JSON object described by the tool’s configuration.

Inputs#

input: List[Block]

A list of blocks that will be ignored.

memory: AgentContext

The active AgentContext.

Output#

output: List[Blocks]

A single block containing a new row of the table described by the tool’s configuration.

shuffle_example_rows: bool#

Whether randomly shuffle example rows to induce a bit of variety even with low LLM temperature.

validate_output_as_json: bool#

Whether to validate that the output is actually JSON.

class steamship.agents.tools.text_generation.PersonalityTool(personality: str | None = None, rewrite_prompt: str | None = None, *, name: str = 'PersonalityTool', agent_description: str = 'Used to provide a response with a particular personality. Takes a message as input, and provides a message as output.', human_description: str = 'Rewrites a response with the given personality.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

name: str#

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

personality: str#
rewrite_prompt: str#
class steamship.agents.tools.text_generation.SummarizeTextWithPromptTool(*, name: str = 'SummarizeTextWithPromptTool', agent_description: str = 'Use this tool to summarize text. The input is the text needing summarization. The output is a summary of the text.', human_description: str = 'Summarizes text using an LLM prompt.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease summarize the following document so that the key points are represented in a way that stand alone for reading.\n\nDOCUMENT\n========\n\n{input}\n\nONE PARAGRAPH SUMMARY\n=====================')[source]#

Bases: TextRewritingTool

Example tool to illustrate summarizing an input document using prompt engineering.

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.

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.text_generation.TextRewritingTool(*, name: str = 'TextRewritingTool', agent_description: str = 'Used to rewrite a piece of text given a prompt. Takes text as input, and provides text as output.', human_description: str = 'Rewrites a piece of text using the provided prompt.', is_final: bool = False, cacheable: bool = True, rewrite_prompt: str = 'Instructions:\nPlease rewrite the following passage to be incredibly polite, to a fault.\nPassage:\n{input}\nRewritten Passage:')[source]#

Bases: Tool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

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#
run(tool_input: List[Block], context: AgentContext) List[Block] | Task[Any][source]#

Rewrites each provided text block using the stored prompt. Non-text blocks are passed through without modification.

Inputs#

input: List[Block]

A list of blocks to be rewritten if they contain text. Each block will be considered a separate input.

memory: AgentContext

The active AgentContext.

Output#

output: List[Blocks]

A list of blocks whose content has been rewritten. Synchronously produced (for now).

class steamship.agents.tools.text_generation.TextTranslationTool(language: str | None = None, rewrite_prompt: str | None = None, *, name: str = 'TextTranslationTool', agent_description: str = '(set dynamically)', human_description: str = 'Translates a text into a new language.', is_final: bool = False, cacheable: bool = True)[source]#

Bases: TextRewritingTool

Example tool to illustrate rewriting a statement according to a particular personality.

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.

language: 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#