Skip to content

Commit

Permalink
Merge pull request #216 from sirji-ai/use-action-names-in-systempromot
Browse files Browse the repository at this point in the history
used action names from enum in systemPrompt
  • Loading branch information
kedarchandrayan authored Jul 30, 2024
2 parents 1ea6490 + ee1f96d commit b8a3c01
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion agents/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sirji-messages==0.0.32
sirji-messages==0.0.33
sirji-tools==0.0.16
openai==1.35.7
anthropic==0.29.0
Expand Down
2 changes: 1 addition & 1 deletion agents/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sirji-agents',
version='0.0.48',
version='0.0.49',
author='Sirji',
description='Orchestrator, Generic Agent, and Research Agent components of the Sirji AI agentic framework.',
license='MIT',
Expand Down
8 changes: 4 additions & 4 deletions agents/sirji_agents/llm/generic/system_prompts/anthropic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import textwrap

from sirji_messages import ActionEnum, AgentEnum, allowed_response_templates, permissions_dict, ActionEnum
from sirji_messages import ActionEnum, AgentEnum, allowed_response_templates, permissions_dict

class AnthropicSystemPrompt:
def __init__(self, config, agent_output_folder_index):
Expand Down Expand Up @@ -69,7 +69,7 @@ def system_prompt(self):
***
FROM: {{Your Agent ID}}
TO: {sub_agent['id']}
ACTION: INVOKE_AGENT
ACTION: {ActionEnum.INVOKE_AGENT.name}
STEP: "provide the step number here for the ongoing step if any."
SUMMARY: {{Display a concise summary to the user, describing the action using the present continuous tense.}}
BODY:
Expand All @@ -83,7 +83,7 @@ def system_prompt(self):
***
FROM: {{Your Agent ID}}
TO: {sub_agent['id']}
ACTION: INVOKE_AGENT_EXISTING_SESSION
ACTION: {ActionEnum.INVOKE_AGENT_EXISTING_SESSION.name}
STEP: "provide the step number here for the ongoing step if any."
SUMMARY: {{Display a concise summary to the user, describing the action using the present continuous tense.}}
BODY:
Expand All @@ -99,7 +99,7 @@ def system_prompt(self):
action_list.add(ActionEnum[action])
allowed_response_templates_str += '\n' + allowed_response_templates(AgentEnum.ANY, AgentEnum.EXECUTOR, action_list) + '\n'

allowed_response_templates_str += "For updating in project folder use either FIND_AND_REPLACE, INSERT_ABOVE or INSERT_BELOW 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 += 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'

current_agent_output_index = f"Current contents of Agent Output Index:\n{json.dumps(self.agent_output_folder_index, indent=4)}"
Expand Down
14 changes: 7 additions & 7 deletions agents/sirji_agents/llm/generic/system_prompts/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import textwrap

from sirji_messages import ActionEnum, AgentEnum, allowed_response_templates, permissions_dict, ActionEnum
from sirji_messages import ActionEnum, AgentEnum, allowed_response_templates, permissions_dict

class DefaultSystemPrompt:
def __init__(self, config, agent_output_folder_index):
Expand All @@ -21,7 +21,7 @@ def system_prompt(self):
- 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.""")
# Todo: Use action names from ActionEnum

understanding_the_folders = textwrap.dedent("""
Project Folder:
- The Project Folder is your primary directory for accessing all user-specific project files, including code files, documentation, and other relevant resources.
Expand All @@ -48,7 +48,7 @@ def system_prompt(self):
- Upon being invoked, identify which of your skills match the requirements of the task.
- 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 STORE_IN_AGENT_OUTPUT and READ_AGENT_OUTPUT_FILES to write and read files to and from the agent output folder.
- 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.
""")

Expand All @@ -69,7 +69,7 @@ def system_prompt(self):
***
FROM: {{Your Agent ID}}
TO: {sub_agent['id']}
ACTION: INVOKE_AGENT
ACTION: {ActionEnum.INVOKE_AGENT.name}
STEP: "provide the step number here for the ongoing step if any."
SUMMARY: {{Display a concise summary to the user, describing the action using the present continuous tense.}}
BODY:
Expand All @@ -83,7 +83,7 @@ def system_prompt(self):
***
FROM: {{Your Agent ID}}
TO: {sub_agent['id']}
ACTION: INVOKE_AGENT_EXISTING_SESSION
ACTION: {ActionEnum.INVOKE_AGENT_EXISTING_SESSION.name}
STEP: "provide the step number here for the ongoing step if any."
SUMMARY: {{Display a concise summary to the user, describing the action using the present continuous tense.}}
BODY:
Expand All @@ -99,7 +99,7 @@ def system_prompt(self):
action_list.add(ActionEnum[action])
allowed_response_templates_str += '\n' + allowed_response_templates(AgentEnum.ANY, AgentEnum.EXECUTOR, action_list) + '\n'

allowed_response_templates_str += "For updating in project folder use either FIND_AND_REPLACE, INSERT_ABOVE or INSERT_BELOW 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 += textwrap.dedent(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'

current_agent_output_index = f"Current contents of Agent Output Index:\n{json.dumps(self.agent_output_folder_index, indent=4)}"
Expand All @@ -118,7 +118,7 @@ def __format_skills(self):

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

output_text += "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 LOG_STEPS action.\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 += "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
3 changes: 1 addition & 2 deletions agents/sirji_agents/llm/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import json

# TODO - log file should be dynamically created based on agent ID
from sirji_tools.logger import o_logger as logger

from sirji_messages import message_parse, ActionEnum, AgentEnum, allowed_response_templates, permissions_dict, MessageIncorrectFormatError, MessageMultipleActionError, MessageUnRecognizedActionError, MessageMissingPropertyError, MessageLengthConstraintError
Expand Down Expand Up @@ -132,7 +131,7 @@ def system_prompt(self):

pseudo_code = textwrap.dedent(f"""
Pseudo code which you must follow:
1. Invoke agent RECIPE_SELECTOR to get the recipe selected from the available recipes by SIRJI_USER and then store it in Agent Output Folder.
1. Invoke agent {ActionEnum.RECIPE_SELECTOR.name} to get the recipe selected from the available recipes by SIRJI_USER and then store it in Agent Output Folder.
2. Read the selected recipe from the Agent Output Folder.
3. Loop over the prescribed tasks in the selected recipe and invoke the agent specified in the recipe alongside the current task, explaining the task in the BODY of the invocation.
""")
Expand Down
2 changes: 1 addition & 1 deletion messages/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='sirji-messages',
version='0.0.32',
version='0.0.33',
author='Sirji',
description='Sirji messaging protocol implementation to create, validate and parse messages.',
license='MIT',
Expand Down
2 changes: 1 addition & 1 deletion sirji/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "sirji",
"displayName": "Sirji",
"description": "Sirji is an AI Software Development Agent.",
"version": "0.0.31-beta.2",
"version": "0.0.31-beta.3",
"publisher": "TrueSparrow",
"icon": "out/assets/sirji.png",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
urllib3==2.2.1
pyyaml==6.0.1
sirji-messages==0.0.32
sirji-agents == 0.0.48
sirji-messages==0.0.33
sirji-agents == 0.0.49
4 changes: 2 additions & 2 deletions sirji/vscode-extension/src/py_scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
urllib3==1.25.11
pyyaml==6.0.1
sirji-messages==0.0.32
sirji-agents == 0.0.48
sirji-messages==0.0.33
sirji-agents == 0.0.49

0 comments on commit b8a3c01

Please sign in to comment.