Skip to content

Commit

Permalink
Updated the error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
V-R-Dighe committed Aug 6, 2024
1 parent 8271dcc commit 0395340
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions agents/sirji_agents/llm/generic/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,19 @@ def __get_response(self, conversation):
raise e
self.logger.info(f"Requesting LLM to resend the message in correct format.\n")
conversation.append({"role": "assistant", "content": response_message, "parsed_content": {}})
conversation.append({"role": "user", "content": "Error obtained in processing your last response. Your response must conform strictly to one of the allowed Response Templates, as it will be processed programmatically and only these templates are recognized. Your response must be enclosed within '***' at the beginning and end, without any additional text above or below these markers. Not conforming above rules will lead to response processing errors."})
conversation.append({"role": "user", "content": "Error obtained in processing your last message. Your last message has been discarded. The message must conform strictly to one of the allowed Response Templates, as it will be processed programmatically and only these templates are recognized. Your message must be enclosed within '***' at the beginning and end, without any additional text above or below these markers. Not conforming above rules will lead to response processing errors."})
if isinstance(e, MessageMissingPropertyError):
conversation.append({"role": "assistant", "content": response_message, "parsed_content": {}})
conversation.append({"role": "user", "content": "Error obtained in processing your last response. your response is missing some required properties. Please refer to the allowed response templates and provide the missing properties."})
conversation.append({"role": "user", "content": "Error obtained in processing your last message. Your last message has been discarded. The message is missing some required properties. Please refer to the allowed response templates and provide the missing properties."})
if isinstance(e, MessageUnRecognizedActionError):
conversation.append({"role": "assistant", "content": response_message, "parsed_content": {}})
conversation.append({"role": "user", "content": "Error obtained in processing your last response. Your response contains an unrecognized action. Please refer to the allowed response templates and provide a valid action."})
conversation.append({"role": "user", "content": "Error obtained in processing your last message. Your last message has been discarded. The message contains an unrecognized action. Please refer to the allowed response templates and provide a valid action."})
if isinstance(e, MessageLengthConstraintError):
conversation.append({"role": "assistant", "content": response_message, "parsed_content": {}})
conversation.append({"role": "user", "content": "Error obtained in processing your last response. Your response does not have all the required properties."})
conversation.append({"role": "user", "content": "Error obtained in processing your last message. Your last message has been discarded. The message does not have all the required properties."})
if isinstance(e, MessageMultipleActionError):
conversation.append({"role": "assistant", "content": response_message, "parsed_content": {}})
conversation.append({"role": "user", "content": "Error obtained in processing your last response. Your response contains more than one ACTION keyword."})
conversation.append({"role": "user", "content": "Error obtained in processing your last message. Your last message has been discarded. The message contains more than one 'ACTION' keyword. Send only one 'ACTION' at a time."})
except Exception as e:
self.logger.info(f"Generic error while parsing message. Error: {e}\n")
raise e
Expand Down
3 changes: 3 additions & 0 deletions agents/sirji_agents/llm/generic/system_prompts/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def system_prompt(self):
action_list.add(ActionEnum[action])
allowed_response_templates_str += '\n' + allowed_response_templates(AgentEnum.ANY, AgentEnum.EXECUTOR, action_list) + '\n'

action_list_researcher = permissions_dict[(AgentEnum.ANY, AgentEnum.RESEARCHER)]
allowed_response_templates_str += '\n' + allowed_response_templates(AgentEnum.ANY, AgentEnum.RESEARCHER, action_list_researcher) + '\n'

allowed_response_templates_str += f"""For updating in project folder use either {ActionEnum.FIND_AND_REPLACE.name}, {ActionEnum.INSERT_ABOVE.name} or {ActionEnum.INSERT_BELOW.name} actions. Ensure you provide the exact matching string in find from file, with the exact number of lines and proper indentation for insert and replace actions.\n"""
allowed_response_templates_str += '\n' + allowed_response_templates(AgentEnum.ANY, AgentEnum.CALLER, permissions_dict[(AgentEnum.ANY, AgentEnum.CALLER)]) + '\n'

Expand Down
5 changes: 3 additions & 2 deletions agents/sirji_agents/llm/generic/system_prompts/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def system_prompt(self):
- Execute the sub-tasks associated with each of these matching skills.
- Do not respond with two actions in the same response. Respond with one action at a time.
- Always use {ActionEnum.STORE_IN_AGENT_OUTPUT.name} and {ActionEnum.READ_AGENT_OUTPUT_FILES.name} to write and read files to and from the agent output folder.
- If any step is not applicable or cannot be followed, use the DO_NOTHING action to skip it.
- If any step is not applicable or cannot be followed, use the DO_NOTHING action to skip it.
- On getting error multiple times, that you have skipped a step you need to consult with the SIRJI_USER.
""")

formatted_skills = self.__format_skills()
Expand Down Expand Up @@ -121,7 +122,7 @@ def __format_skills(self):

output_text += f"Skill: {self.config['skill']}\n"

output_text += f"Make sure to first convert all the points mentioned in Pseudo code in plain english to steps having at max 10 words each and log these steps using {ActionEnum.LOG_STEPS.name} action.\n"
output_text += f"Make sure to first convert all the points mentioned in Pseudo code to plain english steps having at max 10 words each. Ensure to have one and only one plain english step for each pseudo code point. Log these plain english steps using {ActionEnum.LOG_STEPS.name} action.\n"
output_text += "Then, execute the steps in the order they are logged.\n"
output_text += f"Pseudo code which you must follow:\n{self.config['pseudo_code']}"
output_text += "\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def sample(self):
"summary": "{{Display a concise summary to the user, describing the action using the present continuous tense.}}",
"body": textwrap.dedent("""
FILE_PATH:
{{File path}}
{{File path}}
---
FIND:
{{Code to Find}}
Expand Down
2 changes: 1 addition & 1 deletion messages/sirji_messages/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _validate_message(message):
message = message.strip()
if not (message.startswith("***") and message.endswith("***")):
raise MessageIncorrectFormatError("Message must start and end with ***")
if message.count("ACTION") > 1:
if message.count("ACTION:") > 1:
raise MessageMultipleActionError("Message contains more than one ACTION keyword")
message = message[3:-3].strip()
lines = message.split("\n")
Expand Down
2 changes: 1 addition & 1 deletion sirji/vscode-extension/src/utils/executor/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class Executor {
console.log('LOG_STEPS', oThis.parsedMessage.BODY, oThis.agentStack);
return await oThis.stepManager.createStepsFile(oThis.agentStack, oThis.parsedMessage.BODY);
default:
return `Invalid message ACTION: ${action} sent to executor. Your response must conform strictly to one of the allowed Response Templates, as it will be processed programmatically and only these templates are recognized. Your response must be enclosed within '***' at the beginning and end, without any additional text above or below these markers. Not conforming above rules will lead to response processing errors.`;
return `Invalid message "ACTION": ${action} sent to executor. Your response must conform strictly to one of the allowed Response Templates, as it will be processed programmatically and only these templates are recognized. Your response must be enclosed within '***' at the beginning and end, without any additional text above or below these markers. Not conforming above rules will lead to response processing errors.`;
}
}

Expand Down

0 comments on commit 0395340

Please sign in to comment.