You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Infrastructure/BotSharp.Core/data/agents/c2a2faf6-b8b5-47fe-807b-f4714cf25dd4/templates/rule-trigger-code-generate_instruction.liquid
+7-5Lines changed: 7 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,13 @@ Based on user's request, help generate a refined python code of function definit
3
3
User's request is {{user_request}}
4
4
5
5
Couple of notes to address:
6
-
1. You need to generate a function named check_trigger_criterion(args), where input is a json object. The example of this json object is {{states_example}}.
7
-
2. The input to this function comes from the arguments. You must use "ArgumentParser" to take "states" as an argument, and then use "parse_known_args" to get the raw args.
6
+
1. You need to generate a function named check_trigger_criterion(args), where input is a json object. The example of this json object is {{args_example}}.
7
+
2. The input to this function comes from the arguments. You must use "ArgumentParser" to take an argument named "states", and then use "parse_known_args" to get the raw args.
8
8
3. After getting the raw args, you need to use 'clean_args = bytes(raw_args, "utf-8").decode("unicode_escape")' to clean the raw argument, and then use 'args = json.loads(clean_args)' to get the json args.
9
-
4. Based on the user's request and input args, the output of this function must be True or False.
9
+
4. Based on the user's request and input args, generate the function logic and ONLY return a boolean value.
10
10
5. You must only call check_trigger_criterion with the parsed json args in "if __name__ == '__main__'" block, and print only the function output. If any error occurs, print "Error".
11
-
6. Refine the code so it will return for certain errors if detected, for example, when input is not a valid json, return "Error: Input is not a valid JSON string."; If "states" not in data: return "Error: Missing 'states' key in JSON."; or when certain states are missing from input, so I can better track of this.
11
+
6. Refine the code so it will return for certain errors if detected, for example, when input is not a valid json, return "Error: Input is not a valid JSON string."; or when certain attributes are missing from json args, so I can better track of this.
12
+
7. You can use try-except blocks to catch any errors, and return "Error" if any error occurs. Do not use sys.exit(0) to exit the program.
13
+
8. Use as fewer comments and try-except blocks as possible.
12
14
13
-
Output the code directly in order to directly save it to a py file. Avoid using comments for format issues, use code snip block for the output.
15
+
Output the executable code directly in order to directly save it to a py file.
0 commit comments