Sirji is an Open Source AI Software Development Agent.
Built with ❤️ by True Sparrow
sirji-messages
is a PyPI package that implements the Sirji message protocol with following highlights:
- Message Factory
- Permissions Matrix (for defining message actions allowed between two agents)
- System prompt generation
We recommend setting up a virtual environment to isolate Python dependencies, ensuring project-specific packages without conflicting with system-wide installations.
python3 -m venv venv
source venv/bin/activate
Install the package from PyPi:
pip install sirji-messages
Parse structured message strings into Python dictionaries for easy access to the message components.
from sirji_messages import message_parse
# Example message string to parse
message_str = """```
FROM: CODER
TO: USER
ACTION: INFORM
DETAILS: Welcome to sirji-messages. Here's how you can start.
```"""
# Parsing the message
message = message_parse(message_str)
print(message)
Determine if a specified action is allowed between two agents based on predefined permission rules.
from sirji_messages import permissions_dict, validate_permission, AgentEnum
# Example check if a CODER can QUESTION a USER
is_allowed = validate_permission("CODER", "USER", "QUESTION")
print(f"Is allowed: {is_allowed}")
# Get a direct look at permissions dictionary for CODER sending to USER
print(permissions_dict[(AgentEnum.CODER, AgentEnum.USER)])
Efficiently manage parsing and validation errors with custom exceptions for improved error handling and debugging.
from sirji_messages import MessageParsingError, MessageValidationError, message_parse
try:
# Attempt parsing an incorrectly formatted message
message_parse("INCORRECT_FORMAT")
except MessageParsingError as e:
print(f"Parsing Error: {e}")
except MessageValidationError as e:
print(f"Validation Error: {e}")
Use enums (ActionEnum
, AgentEnum
) to reference actions and agent types programmatically, enhancing code clarity and reducing errors.
from sirji_messages import ActionEnum, AgentEnum
# Example usage of enums for action and agent reference
action = ActionEnum.ACKNOWLEDGE
agent = AgentEnum.CODER
# Accessing enum properties
print(f"Action: {action.name}, Agent: {agent.full_name}")
# Access to enums using [] is also possible
action = ActionEnum['ACKNOWLEDGE']
agent = AgentEnum['CODER']
Utilize factories (MessageFactory
, AgentSystemPromptFactory
) to instantiate message and prompt classes dynamically based on enums. It simplifies creating custom messages or retrieving specific system prompts without hardcoding class names.
from sirji_messages import MessageFactory, ActionEnum, AgentSystemPromptFactory, AgentEnum
# Message class instantiation from an action enum
message_class = MessageFactory[ActionEnum.INFORM.name]
print(f"Sample INFORM message:\n{message_class().sample()}")
# Generate message using passed template variables
generated_messages = message_class().generate({"details": "Some sample information."})
print(f"Generated INFORM message:\n{generated_messages}")
# System prompt class instantiation from an agent enum
prompt_class = AgentSystemPromptFactory[AgentEnum.CODER.name]
print(f"CODER system prompt: {prompt_class().system_prompt()}")
- Fork and clone the repository.
- Create and activate the virtual environment as described above.
- Install the package in editable mode by running the following command from repository root:
pip install -e .
Follow the above mentioned steps for "contributors", before running the test cases.
# Install testing dependencies
pip install pytest coverage
# Execute tests
pytest
# Measure coverage, excluding test files
coverage run --omit="tests/*" -m pytest
coverage report
Distributed under the MIT License. See LICENSE
for more information.