sherpa_ai.actions package#
Submodules#
sherpa_ai.actions.answer_arithmetic module#
sherpa_ai.actions.arxiv_search module#
- class sherpa_ai.actions.arxiv_search.ArxivSearch(*, name: str = 'ArxivSearch', args: dict = {'query': 'string'}, usage: str = 'Search paper on the Arxiv website', belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = True, role_description: str, task: str, llm: ~typing.Any = None, description: str = 'Role Description: {role_description}\nTask: {task}\n\nRelevant Paper Title and Summary:\n{paper_title_summary}\n\n\nReview and analyze the provided paper summary with respect to the task. Craft a concise and short, unified summary that distills key information that is most relevant to the task, incorporating reference links within the summary.\nOnly use the information given. Do not add any additional information. The summary should be less than {n} setences\n')[source]#
Bases:
BaseRetrievalAction
- args: dict#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None #
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- name: str#
- perform_refinement: bool#
- role_description: str#
- task: str#
- usage: str#
sherpa_ai.actions.base module#
- class sherpa_ai.actions.base.ActionArgument(*args, name: str, type: str = 'str', description: str = '', source: str = 'agent', key: str | None = None)[source]#
Bases:
BaseModel
Argument used for an action.
- name#
Name of the argument.
- Type:
str
- type#
Type of the argument. (default: “str”)
- Type:
str
- description#
Description of the argument. (default: “”)
- Type:
str
- source#
source of the argument, select from (agent, belief) If source is agent, the argument is provided by the agent (LLM). If source is belief, the value of the argument is retrieved from the dictionary of the belief. (default: “agent”)
- Type:
str
- key#
key of the argument in the belief dictionary if source is belief. (default: name of the argument, if source is belief)
- Type:
str
- description: str#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- source: str#
- type: str#
- class sherpa_ai.actions.base.ActionResource(*, source: str, content: str)[source]#
Bases:
BaseModel
Resource used for an action.
- source#
Source of the resource, such as document id or url.
- Type:
str
- content#
Content of the resource.
- Type:
str
- content: str#
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- source: str#
- class sherpa_ai.actions.base.AsyncBaseAction(*args, name: str, usage: str, belief: Any = None, output_key: str | None = None)[source]#
Bases:
BaseAction
,ABC
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class sherpa_ai.actions.base.BaseAction(*args, name: str, usage: str, belief: Any = None, output_key: str | None = None)[source]#
Bases:
ABC
,BaseModel
Base class for an action.
- name#
Name of the action.
- Type:
str
- args#
Arguments required to run the action.
- Type:
Union[dict, list[ActionArgument]]
- usage#
Usage description of the action.
- Type:
str
- belief#
Belief used for the action. It is required if any argument requires belief. (default: None)
- Type:
Any
- output_key#
Output key of the action. (default: name of the action)
- Type:
Optional[str]
- args: dict | list[ActionArgument]#
- belief: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- usage: str#
- class sherpa_ai.actions.base.BaseRetrievalAction(*args, name: str, usage: str, belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = False)[source]#
Bases:
BaseAction
,ABC
- current_task: str#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- num_documents: int#
- perform_refinement: bool#
- perform_reranking: bool#
- refiner: BaseRefinement#
- reranker: BaseReranking#
- resources: list[ActionResource]#
sherpa_ai.actions.context_search module#
- class sherpa_ai.actions.context_search.ContextSearch(*, name: str = 'Context Search', args: dict = {'query': 'string'}, usage: str = 'Search the conversation history with the user', belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = True, role_description: str, task: str, llm: ~typing.Any = None, description: str = 'Role Description: {role_description}\nTask: {task}\n\nRelevant Documents:\n{documents}\n\n\nReview and analyze the provided documents with respect to the task. Craft a concise and short, unified summary that distills key information that is most relevant to the task, incorporating reference links within the summary.\nOnly use the information given. Do not add any additional information. The summary should be less than {n} setences\n')[source]#
Bases:
BaseRetrievalAction
- args: dict#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None #
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- name: str#
- perform_refinement: bool#
- role_description: str#
- task: str#
- usage: str#
sherpa_ai.actions.deliberation module#
- class sherpa_ai.actions.deliberation.Deliberation(*args, name: str = 'Deliberation', usage: str = 'Directly come up with a solution', belief: Any = None, output_key: str | None = None, role_description: str, llm: Any = None, description: str = 'Role Description: {role_description}\nTask Description: {task}\n\nPlease deliberate on the task and generate a solution that is:\n\nHighly Detailed: Break down components and elements clearly.\nQuality-Oriented: Ensure top-notch performance and longevity.\nPrecision-Focused: Specific measures, materials, or methods to be used.\n\nKeep the result concise and short. No more than one paragraph.\n\n')[source]#
Bases:
BaseAction
- args: dict#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- role_description: str#
- usage: str#
sherpa_ai.actions.google_search module#
- class sherpa_ai.actions.google_search.GoogleSearch(*, name: str = 'Google Search', args: dict = {'query': 'string'}, usage: str = 'Get answers from Google Search', belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = False, role_description: str, task: str, llm: ~typing.Any = None, description: str = 'Role Description: {role_description}\nTask: {task}\n\nRelevant Documents:\n{documents}\n\n\nReview and analyze the provided documents with respect to the task. Craft a concise and short, unified summary that distills key information that is most relevant to the task, incorporating reference links within the summary.\nOnly use the information given. Do not add any additional information. The summary should be less than {n} setences\n', config: ~sherpa_ai.config.task_config.AgentConfig = AgentConfig(verbose=True, gsite=[], do_reflect=False, use_task_agent=False, search_domains=[], invalid_domains=[]))[source]#
Bases:
BaseRetrievalAction
- args: dict#
- config: AgentConfig#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None #
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- name: str#
- role_description: str#
- task: str#
- usage: str#
sherpa_ai.actions.planning module#
- class sherpa_ai.actions.planning.Step(agent_name: str, task: str)[source]#
Bases:
object
- Step for the plan created by the planner
agent_name: the name of the agent that should execute the step task: the task that the agent should execute
- class sherpa_ai.actions.planning.TaskPlanning(*args, name: str = 'TaskPlanning', usage: str = 'Come up with a plan to solve the task', belief: Any = None, output_key: str | None = None, llm: Any = None, num_steps: int = 5, prompt: str = 'You are a **task decomposition assistant** who simplifies complex tasks into sequential steps, assigning roles or agents to each.\nBy analyzing user-defined tasks and agent capabilities, you provides structured plans, enhancing project clarity and efficiency.\nYour adaptability ensures customized solutions for diverse needs.\n\nA good plan is concise, detailed, feasible and efficient.\n\nTask: **{task}**\n\nAgents:\n{agent_pool_description}\n\nPlease break down the task into maximum {num_steps} individual, detailed steps and designate an appropriate agent for each step. The result should be in the following format:\nStep 1:\n Agent: <AgentName>\n Task: <detailed task description>\n...\nStep N:\n Agent: <AgentName>\n Task: <detailed task description>\n\nDo not answer anything else, and do not add any other information in your answer. Only select agents from the the list and only select one agent at a time.\n', revision_prompt: str = 'You are a **task decomposition assistant** who simplifies complex tasks into sequential steps, assigning roles or agents to each.\nBy analyzing user-defined tasks and agent capabilities, you provide structured plans, enhancing project clarity and efficiency.\nYour adaptability ensures customized solutions for diverse needs.\n\nA good plan is concise, detailed, feasible and efficient. It should be broken down into individual steps, with each step assigned to an appropriate agent.\n\nTask: **{task}**\n\nAgents:\n{agent_pool_description}\n\nHere is your previous plan:\n{previous_plan}\n\nHere is the feedback from the last run:\n{feedback}\n\nPlease revise the plan based on the feedback to maximum {num_steps} steps. The result should be in the following format:\nStep 1:\n Agent: <AgentName>\n Task: <detailed task description>\n...\nStep N:\n Agent: <AgentName>\n Task: <detailed task description>\n\nDo not answer anything else, and do not add any other information in your answer. Only select agents from the the list and only select one agent at a time.\n')[source]#
Bases:
BaseAction
- args: dict#
- execute(task: str, agent_pool_description: str, last_plan: str | None = None, feedback: str | None = None) Plan [source]#
Execute the action
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- num_steps: int#
- post_process(action_output: str) Plan [source]#
Post process the action output into a plan with steps
- prompt: str#
- revision_prompt: str#
- usage: str#
sherpa_ai.actions.synthesize module#
- class sherpa_ai.actions.synthesize.SynthesizeOutput(*, name: str = 'SynthesizeOutput', args: dict = {'context': 'string', 'history': 'string', 'task': 'string'}, usage: str = 'Answer the question using conversation history with the user', belief: Any = None, output_key: str | None = None, role_description: str, llm: Any = None, description: str = '{role_description}\n\nContext: {context}\n\nAction - Result History:\n{history}\n\nGiven the context and the action-result history, please complete the task mentioned. Include any links you used from the context and history in the result.\nTask: {task}\nResult:\n', add_citation: bool = False)[source]#
Bases:
BaseAction
- add_citation: bool#
- args: dict#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- role_description: str#
- usage: str#
Module contents#
- class sherpa_ai.actions.ArxivSearch(*, name: str = 'ArxivSearch', args: dict = {'query': 'string'}, usage: str = 'Search paper on the Arxiv website', belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = True, role_description: str, task: str, llm: ~typing.Any = None, description: str = 'Role Description: {role_description}\nTask: {task}\n\nRelevant Paper Title and Summary:\n{paper_title_summary}\n\n\nReview and analyze the provided paper summary with respect to the task. Craft a concise and short, unified summary that distills key information that is most relevant to the task, incorporating reference links within the summary.\nOnly use the information given. Do not add any additional information. The summary should be less than {n} setences\n')[source]#
Bases:
BaseRetrievalAction
- args: dict#
- belief: Any#
- current_task: str#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None #
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- name: str#
- num_documents: int#
- perform_refinement: bool#
- perform_reranking: bool#
- refiner: BaseRefinement#
- reranker: BaseReranking#
- resources: list[ActionResource]#
- role_description: str#
- task: str#
- usage: str#
- class sherpa_ai.actions.Deliberation(*args, name: str = 'Deliberation', usage: str = 'Directly come up with a solution', belief: Any = None, output_key: str | None = None, role_description: str, llm: Any = None, description: str = 'Role Description: {role_description}\nTask Description: {task}\n\nPlease deliberate on the task and generate a solution that is:\n\nHighly Detailed: Break down components and elements clearly.\nQuality-Oriented: Ensure top-notch performance and longevity.\nPrecision-Focused: Specific measures, materials, or methods to be used.\n\nKeep the result concise and short. No more than one paragraph.\n\n')[source]#
Bases:
BaseAction
- args: dict#
- belief: Any#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- role_description: str#
- usage: str#
- class sherpa_ai.actions.EmptyAction(*args, name: str = '', usage: str = 'Make a decision', belief: Any = None, output_key: str | None = None)[source]#
Bases:
BaseAction
- args: dict#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- usage: str#
- class sherpa_ai.actions.GoogleSearch(*, name: str = 'Google Search', args: dict = {'query': 'string'}, usage: str = 'Get answers from Google Search', belief: ~typing.Any = None, output_key: str | None = None, resources: list[~sherpa_ai.actions.base.ActionResource] = <factory>, num_documents: int = 5, reranker: ~sherpa_ai.actions.utils.reranking.BaseReranking = None, refiner: ~sherpa_ai.actions.utils.refinement.BaseRefinement = None, current_task: str = '', perform_reranking: bool = False, perform_refinement: bool = False, role_description: str, task: str, llm: ~typing.Any = None, description: str = 'Role Description: {role_description}\nTask: {task}\n\nRelevant Documents:\n{documents}\n\n\nReview and analyze the provided documents with respect to the task. Craft a concise and short, unified summary that distills key information that is most relevant to the task, incorporating reference links within the summary.\nOnly use the information given. Do not add any additional information. The summary should be less than {n} setences\n', config: ~sherpa_ai.config.task_config.AgentConfig = AgentConfig(verbose=True, gsite=[], do_reflect=False, use_task_agent=False, search_domains=[], invalid_domains=[]))[source]#
Bases:
BaseRetrievalAction
- args: dict#
- belief: Any#
- config: AgentConfig#
- current_task: str#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None #
This function is meant to behave like a BaseModel method to initialise private attributes.
It takes context as an argument since that’s what pydantic-core passes when calling it.
- Parameters:
self – The BaseModel instance.
context – The context.
- name: str#
- num_documents: int#
- perform_refinement: bool#
- perform_reranking: bool#
- refiner: BaseRefinement#
- reranker: BaseReranking#
- resources: list[ActionResource]#
- role_description: str#
- task: str#
- usage: str#
- class sherpa_ai.actions.SynthesizeOutput(*, name: str = 'SynthesizeOutput', args: dict = {'context': 'string', 'history': 'string', 'task': 'string'}, usage: str = 'Answer the question using conversation history with the user', belief: Any = None, output_key: str | None = None, role_description: str, llm: Any = None, description: str = '{role_description}\n\nContext: {context}\n\nAction - Result History:\n{history}\n\nGiven the context and the action-result history, please complete the task mentioned. Include any links you used from the context and history in the result.\nTask: {task}\nResult:\n', add_citation: bool = False)[source]#
Bases:
BaseAction
- add_citation: bool#
- args: dict#
- belief: Any#
- description: str#
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- role_description: str#
- usage: str#
- class sherpa_ai.actions.TaskPlanning(*args, name: str = 'TaskPlanning', usage: str = 'Come up with a plan to solve the task', belief: Any = None, output_key: str | None = None, llm: Any = None, num_steps: int = 5, prompt: str = 'You are a **task decomposition assistant** who simplifies complex tasks into sequential steps, assigning roles or agents to each.\nBy analyzing user-defined tasks and agent capabilities, you provides structured plans, enhancing project clarity and efficiency.\nYour adaptability ensures customized solutions for diverse needs.\n\nA good plan is concise, detailed, feasible and efficient.\n\nTask: **{task}**\n\nAgents:\n{agent_pool_description}\n\nPlease break down the task into maximum {num_steps} individual, detailed steps and designate an appropriate agent for each step. The result should be in the following format:\nStep 1:\n Agent: <AgentName>\n Task: <detailed task description>\n...\nStep N:\n Agent: <AgentName>\n Task: <detailed task description>\n\nDo not answer anything else, and do not add any other information in your answer. Only select agents from the the list and only select one agent at a time.\n', revision_prompt: str = 'You are a **task decomposition assistant** who simplifies complex tasks into sequential steps, assigning roles or agents to each.\nBy analyzing user-defined tasks and agent capabilities, you provide structured plans, enhancing project clarity and efficiency.\nYour adaptability ensures customized solutions for diverse needs.\n\nA good plan is concise, detailed, feasible and efficient. It should be broken down into individual steps, with each step assigned to an appropriate agent.\n\nTask: **{task}**\n\nAgents:\n{agent_pool_description}\n\nHere is your previous plan:\n{previous_plan}\n\nHere is the feedback from the last run:\n{feedback}\n\nPlease revise the plan based on the feedback to maximum {num_steps} steps. The result should be in the following format:\nStep 1:\n Agent: <AgentName>\n Task: <detailed task description>\n...\nStep N:\n Agent: <AgentName>\n Task: <detailed task description>\n\nDo not answer anything else, and do not add any other information in your answer. Only select agents from the the list and only select one agent at a time.\n')[source]#
Bases:
BaseAction
- args: dict#
- belief: Any#
- execute(task: str, agent_pool_description: str, last_plan: str | None = None, feedback: str | None = None) Plan [source]#
Execute the action
- llm: Any#
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str#
- num_steps: int#
- post_process(action_output: str) Plan [source]#
Post process the action output into a plan with steps
- prompt: str#
- revision_prompt: str#
- usage: str#