-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prompt engineering refinements and related processing
- Loading branch information
1 parent
24f6fcc
commit 7668daa
Showing
9 changed files
with
87 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
from langchain.prompts import SystemMessagePromptTemplate | ||
FORMAT_SECTION = """ | ||
Please respond in the following format: | ||
TEMPLATE = """As the AI Tool Selector your responsibility is to identify functions (tools) that could be useful for an autonomous AI agent to accomplish a given task. | ||
Firstly, provide a comma-separated list of function names. Exclude parentheses and arguments from this list. Secondly, after the special delimiter '###', provide explanations for why each function was chosen and how it contributes to accomplishing the task. | ||
Analyze the task and available functions, and determine which functions could be useful. Consider functions that can achieve the goal directly or indirectly, in combination with other tools. | ||
For example, your response may look like this: | ||
Only recommend programming functions if the task explicitly requires programming. | ||
function1, function2, function3 ### function1 can accomplish step A of the task because..., function2 and function3 can be used together to...""" | ||
|
||
INITIAL_SELECTION_TEMPLATE = """As the AI Tool Selector, your responsibility is to analyze a given task and the available functions. Your goal is to identify and recommend functions (tools) that could be used, either directly or indirectly, to accomplish the task by an autonomous AI agent. | ||
By providing more flexibility in the selection and emphasizing the consideration of alternative functions, we can ensure a wider range of function recommendations that align with the given task. | ||
Task: | ||
Take into account that programming functions should only be recommended if the task explicitly requires programming. | ||
# Task | ||
Your original task, given by the human, is: | ||
{task} | ||
Available functions: | ||
# Functions | ||
You may only recommend functions from the following list: | ||
{functions}. | ||
Please respond with a comma-separated list of function names, excluding parentheses and arguments. Do not include any other explanatory text. | ||
By providing more flexibility in the selection and emphasizing the consideration of alternative functions, we can ensure a wider range of function recommendations that align with the given task. | ||
""" | ||
When making your recommendations, consider how the functions can work together to achieve the task's goal, how certain functions may be more effective than others, and prioritize those functions that are most likely to contribute to a successful task completion.""" | ||
|
||
GET_MORE_TOOLS_TEMPLATE = """As the AI Tool Selector your responsibility is to identify functions (tools) that could be useful for an autonomous AI agent to accomplish a given task. | ||
Analyze the functions request and determine which functions could be useful. Consider functions that can achieve the goal directly or indirectly, in combination with other tools. | ||
GET_MORE_TOOLS_TEMPLATE = """As the AI Tool Selector, your responsibility is to identify functions (tools) that could be useful for an autonomous AI agent to accomplish a given task. By providing more flexibility in the selection and emphasizing the consideration of alternative functions, we can ensure a wider range of function recommendations that align with the given task. | ||
Only recommend programming functions if the task explicitly requires programming. | ||
Functions request: | ||
In this scenario, the Autonomous AI has made a request for additional tools to complete a task. Your role is to analyze the functions request and determine which functions could be useful, either directly or indirectly, in combination with other tools. | ||
Request for more tools: | ||
The Autonomous AI has made this request for more tools: {functions_request} | ||
Task: | ||
Your original task, given by the human, is: | ||
Original Task: | ||
The task originally assigned by the human is: | ||
{task} | ||
Available functions: | ||
You may only recommend functions from the following list: | ||
{functions}. | ||
Please respond with a comma-separated list of function names, excluding parentheses and arguments. Do not include any other explanatory text. | ||
By providing more flexibility in the selection and emphasizing the consideration of alternative functions, we can ensure a wider range of function recommendations that align with the given task. | ||
""" | ||
{functions}.""" | ||
|
||
|
||
def initial_selection_template() -> SystemMessagePromptTemplate: | ||
return SystemMessagePromptTemplate.from_template(TEMPLATE) | ||
def initial_selection_template() -> str: | ||
return INITIAL_SELECTION_TEMPLATE + FORMAT_SECTION | ||
|
||
|
||
def get_more_tools_template() -> SystemMessagePromptTemplate: | ||
return SystemMessagePromptTemplate.from_template(GET_MORE_TOOLS_TEMPLATE) | ||
def get_more_tools_template() -> str: | ||
return GET_MORE_TOOLS_TEMPLATE + FORMAT_SECTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters