forked from zlzGithub-0801/GuardAgent-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompts_guard.py
More file actions
63 lines (54 loc) · 2.53 KB
/
prompts_guard.py
File metadata and controls
63 lines (54 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
CodeHeader = """import tools
CheckAccess = tools.check_access
CheckRule = tools.check_rule
"""
Example_Decomposition = """
Agent specification: {agent_specification}
User request: {user_request}
{decomposition_examples}
Agent input: {agent_input}
Agent output: {agent_output}
Task decomposition:
"""
SYSTEM_PROMPT_DECOMPOSITION = """You are the planner of a helpful AI assistant designed to provide guardrail to protect AI agents.
You will be provided with the following information.
1) Agent specification: A description of the agent to be protected, including the input and output to the agent and how the agent works.
2) User request: A description of the desired agent behavior by the user.
3) Agent input: An inference-time input to the agent to be protected.
4) Agent output: An inference-time output by the agent to be protected.
You need to first read the "user request" carefully and then generate a few subtasks for checking whether the "agent input" and the "agent output" satisfy the user request.
You will be provided several related examples.
Follow the examples to complete the "task decomposition" for the given "agent input" and "agent output".
"""
GuardAgent_Message_Prompt = """Write a guardrail code in python following the examples provided in below.
Here are some examples:
{examples}
(END OF EXAMPLES)
Agent input:
{agent_input}
Agent output:
{agent_output}
Task decomposition:
{subtasks}
Here are the functions you can use:
(1) CheckAccess(DATABASE_ALLOWED, DATABASE_NEEDED)
(2) CheckRule(list_of_rules: dict, user_info: dict)
The functions are stored in the toolbox and will be imported. Please do not define them again.
These functions have been imported. Donot need to define them or import them again.
Guardrail code: """
DEFAULT_USER_PROXY_AGENT_DESCRIPTIONS = {
"ALWAYS": "An attentive HUMAN user who can answer questions about the task, and can perform tasks such as running Python code or inputting command line commands at a Linux terminal and reporting back the execution results.",
"TERMINATE": "A user that can run Python code or input command line commands at a Linux terminal and report back the execution results.",
"NEVER": "A user that can run Python code or input command line commands at a Linux terminal and report back the execution results.",
}
CodeDebugger = """Given a question:
{subtasks}
The user have written code with the following functions:
(1) CheckAccess
(2) CheckRule
The code is as follows:
{code}
The execution result is:
{error_info}
Please check the code and point out the most possible reason to the error.
"""