Skip to main content

Orchestration Agent, Research Agent, and Generic Agent components of the Sirji AI agentic framework.

Project description

Sirji Logo

Sirji is an Open Source AI Software Development Agent.

Built with ❤️ by True Sparrow

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

GitHub Repo stars GitHub forks GitHub watchers

Sirji Agents

sirji-agents is a PyPI package that implements following components of the Sirji AI agentic framework:

  • Orchestration Agent
  • Research Agent
  • Generic Agent

By default, it utilizes:

  • OpenAI Chat Completions API
  • OpenAI Assistants API

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-agents

Run the following command to install playwright:

playwright install

Usage

Environment Variables

Ensure that following environment variables are set:

export SIRJI_WORKSPACE="Absolute folder path for Sirji to use as it's workspace."
export SIRJI_RUN_PATH='Folder path containing run related logs, etc.'
export SIRJI_OPENAI_API_KEY='OpenAI API key for Chat Completions API and Assistants API'
export SIRJI_MODEL_PROVIDER='Model Provider to be used for LLM inference. Defaults to "openai".'
export SIRJI_MODEL='Model to be used for LLM inference. Defaults to "gpt-4-turbo".'
export SIRJI_MODEL_PROVIDER_API_KEY='API key to be use for LLM inference.'
export SIRJI_INSTALLATION_DIR='Absolute path of the Sirji installation directory.'

Orchestration Agent

# Following is a sample recipe
recipe = {
  "prescribed_tasks": [
    "Write epics and user stories.",
    "Write architecture components.",
    "Implement the epic & user stories using the architecture components."
  ],
  "tips": [
    "Ensure finalized epics & user stories and architecture components are consistent. Address any discrepancies with the user."
  ]
}

# Following is a sample array of installed agents
installed_agents = [
  {
    "id": "PRODUCT_MANAGER",
    "name": "Product Manager Agent",
    "skills": [
      "Generation of epics and user stories for the problem statement."
    ]
  },
  {
    "id": "ARCHITECT",
    "name": "Architect Agent",
    "skills": [
      "Generation of architecture components."
    ]
  },
  {
    "id": "CODER",
    "name": "Coding Agent",
    "skills": [
      "Developing end-to-end working code for the epic & user stories, making use of the finalized architecture components."
    ]
  }
]

from sirji_agents import Orchestrator

agent = Orchestrator(recipe, installed_agents)

# History is the array of LLM conversation till now
history = []

# Input message string
message_str = ""
response_message, history, prompt_tokens, completion_tokens = agent.message(message_str, history)

Generic Agent

config = {
  "id": "CODER",
  "name": "Coding Agent",
  "llm": {
    "provider": "openai",
    "model": "gpt-4"
  },
  "skills": [
    {
      "skill": "Developing end-to-end working code for the epic & user stories, making use of the finalized architecture components.",
      "sub_tasks": [
        "Read problem statement, epics & user stories and architecture components from shared_resources.",
        "Write concrete code and not just conceptualize or outline or simulate it.",
        "Follow secure software development practices while generating code.",
        "Ensure that you don't create any file/folder outside of workspace root folder, i.e. './'",
        "Install programming language-specific packages or libraries in local folders, utilizing tools such as venv for installing Python dependencies and package.json for managing Node.js dependencies.",
        "Verify whether a system-level command is already installed to avoid triggering the installation of packages that are already in place.",
        "Always execute the code and evaluate the response output. If the response has errors, solve them before moving ahead."
      ]
    }
  ]
}

shared_resources_index = {
  "shared_resources/SIRJI/problem.txt": {
    "description": "Problem statement from the user.",
    "created_by": "SIRJI"
  },
  "shared_resources/PRODUCT_MANAGER/finalized_epics_user_stories.txt": {
    "description": "Finalized Epics and User Stories for the Tic-Tac-Toe game with AI opponent.",
    "created_by": "PRODUCT_MANAGER"
  },
  "shared_resources/ARCHITECT/finalized_architecture_components.txt": {
    "description": "Finalized architecture components for the Tic-Tac-Toe game with AI opponent.",
    "created_by": "ARCHITECT"
  }
}

from sirji_agents import GenericAgent

agent = GenericAgent(config, shared_resources_index)

history = []
message_str = "***\nFROM: ORCHESTRATOR\nTO: CODER\nACTION: INVOKE_AGENT\nSUMMARY: Implement the epic & user stories using the architecture components.\nBODY:\nPImplement the epic & user stories using the architecture components.\n***"

response_message, history, prompt_tokens, completion_tokens = agent.message(message_str, history)

Research Agent

Initialization

from sirji_agents import ResearchAgent

# Initialize Researcher without assistant ID
researcher = ResearchAgent('openai_assistant', 'openai_assistant')

# init_payload fetched from researcher object should be persisted
init_payload = researcher.init_payload

# Initialize Researcher with assistant ID
researcher = ResearchAgent('openai_assistant', 'openai_assistant', init_payload)

Some example message handling usages are given below.

Train using URL

from sirji_messages import MessageFactory, ActionEnum

message_class = MessageFactory[ActionEnum.TRAIN_USING_URL.name]
message_str = message_class().generate({"url": "https://finance.yahoo.com/quote/API/"})

researcher.message(message_str)

Infer

from sirji_messages import MessageFactory, ActionEnum

message_class = MessageFactory[ActionEnum.INFER.name]
message_str = message_class().generate({"details": "How to use yahoo finance api?"})

response, total_tokens = researcher.message(message_str)

For Contributors

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

Running Tests and Coverage Analysis

TODO

License

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sirji_agents-0.0.23.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

sirji_agents-0.0.23-py3-none-any.whl (20.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page