Skip to main content

Sirji Logo

Sirji is an agentic AI framework for software development.

Built with ❤️ by True Sparrow

GitHub License GitHub commit activity GitHub Issues or Pull Requests PyPI sirji-messages

GitHub Repo stars GitHub forks GitHub watchers

Sirji Messages

sirji-messages is a PyPI package that implements the Sirji messaging protocol with the following highlights:

  • Message Factory: A factory that provides a Message class for a given action.
  • Message Parser: Parse structured message strings into Python dictionaries for easy access to the message components.
  • Allowed Response Templates: Provides the part of the system prompt describing allowed Response Templates for a given agent pair.
  • Custom Exceptions: A set of custom exceptions thrown by the message parser.
  • Enums for Agents and Actions: Provides easy auto-completion while writing code.

Installation

Setup Virtual Environment

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 Package

Install the package from PyPi:

pip install sirji-messages

Usage

Message Factory

A factory that provides a Message class for a given action.

from sirji_messages import MessageFactory, ActionEnum

# Message class instantiation from an action enum
message_class = MessageFactory[ActionEnum.RESPONSE.name]
print(f"Sample RESPONSE message:\n{message_class().sample()}")

# Generate message using passed template variables
message_str = message_class().generate({
            "from_agent_id": "EXECUTOR",
            "to_agent_id": "CODER",
            "summary": "Empty",
            "body": "Done."})

print(f"Generated RESPONSE message:\n{message_str}")

Message Parsing

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: EXECUTOR
TO: CODER
ACTION: RESPONSE
SUMMARY: Welcome to sirji-messages
BODY: Welcome to sirji-messages. Here's how you can start.
***"""

# Parsing the message
message = message_parse(message_str)
print(message)

Allowed Response Templates

Provides the part of the system prompt describing allowed Response Templates for a given agent pair.

from sirji_messages import allowed_response_templates, AgentEnum

# Generate allowed response templates
response_templates_str = allowed_response_templates(AgentEnum.ANY, AgentEnum.EXECUTOR)
print(response_templates_str)

Handling Custom Exceptions

Efficiently manage parsing and validation errors with custom exceptions for improved error handling and debugging.

from sirji_messages import  MessageIncorrectFormatError, MessageMultipleActionError, MessageUnRecognizedActionError, MessageMissingPropertyError, MessageLengthConstraintError, message_parse

try:
    # Attempt parsing an incorrectly formatted message
    message_parse("INCORRECT_FORMAT")
except MessageParsingError as e:
    print(f"Parsing Error: {e}")
except MessageIncorrectFormatError as e:
    print(f"Incorrect Format Error: {e}")

Enums for Agents and Actions

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.INVOKE_AGENT
agent = AgentEnum.ORCHESTRATOR

# Accessing enum properties
print(f"Action: {action.name}, Agent: {agent.full_name}")

# Access to enums using [] is also possible
action = ActionEnum['INVOKE_AGENT']
agent = AgentEnum['ORCHESTRATOR']

For Contributors

  1. Fork and clone the repository.
  2. Create and activate the virtual environment as described above.
  3. Install the package in editable mode by running the following command from repository root:
pip install -e .

Running Tests and Coverage Analysis

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

License

Distributed under the MIT License. See LICENSE for more information.

Metadata

Release files for sirji-messages 0.0.34

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sirji-messages 0.0.34
File Size Uploaded Provenance Actions
sirji_messages-0.0.34.tar.gz 21.6 kB Without provenance Details for sirji_messages-0.0.34.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sirji-messages 0.0.34
File Interpreter ABI Platform Actions
sirji_messages-0.0.34-py3-none-any.whl Python 3 none any Details for sirji_messages-0.0.34-py3-none-any.whl

Total release size: 72.0 kB

Release files / sirji_messages-0.0.34.tar.gz

Download URL sirji_messages-0.0.34.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ff39d85541c61928673544fe0a4b5d2fa2e2dce532ec5556d6a12d9482949cc8
BLAKE2b-256 checksum
How to use checksums
6f62a2dfd74c80e87f30f5c50e11d5424b6b6799fa8b8bb3e249fae7b921ef55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Release files / sirji_messages-0.0.34-py3-none-any.whl

Download URL sirji_messages-0.0.34-py3-none-any.whl
Size 50.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56d2cb9c65795b13e23ecdedc11ccf1d56f4a1ab5dcdad87ae2fb28a888974ec
BLAKE2b-256 checksum
How to use checksums
30bb9702c361c0448cd93b110de5ff03a84296982096f9eee33fdb7c2d8d6c2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.4

Security for sirji-messages 0.0.34

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.34 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page