Skip to main content

Mainframe-Orchestra is a lightweight, open-source agentic framework for building LLM based pipelines and self-orchestrating multi-agent teams

Project description

PRs Welcome PyPI version License Twitter

Orchestra

Cognitive Architectures for Multi-Agent Teams.

Overview

Mainframe-Orchestra is a lightweight, open-source agentic framework for building LLM-based pipelines and multi-agent teams. It implements a unique approach to agent orchestration that goes beyond simple routing, enabling complex workflows.

Key Features

  • Modularity: Modular architecture for easy building, extension, and integration
  • Agent Orchestration: Agents can act as both executors and conductors, enabling dynamic task decomposition and coordination among agents
  • Phased Task Execution: Reduces cognitive load on LLMs through structured thinking patterns
  • Tool Integration: Simple docstring-based tool definitions without complex JSON schemas
  • Streaming Support: Real-time output streaming with both sync and async support
  • Built-in Fallbacks: Graceful handling of LLM failures with configurable fallback chains

Installation

Install Orchestra using pip:

pip install mainframe-orchestra

Quick Start

Here's a simple example to get you started:

from mainframe_orchestra import Agent, Task, OpenaiModels, WebTools, set_verbosity

set_verbosity(1)

research_agent = Agent(
    role="research assistant",
    goal="answer user queries",
    llm=OpenaiModels.gpt_4o,
    tools={WebTools.exa_search}
)

def research_task(topic):
    return Task.create(
        agent=research_agent,
        instruction=f"Use your exa search tool to research {topic} and explain it in a way that is easy to understand.",
    )

result = research_task("quantum computing")
print(result)

Core Components

Tasks: Discrete units of work

Agents: Personas that perform tasks and can be assigned tools

Tools: Wrappers around external services or specific functionalities

Language Model Interfaces: Consistent interface for various LLM providers

Supported Language Models and Providers

Orchestra supports a wide range of language models from a number of providers:

OpenAI

GPT-4o, GPT-4o Mini, & Custom defined models

Anthropic

Claude 3 Haiku, Claude 3 Sonnet, Claude 3 Opus, Claude 3.5 Sonnet, & Custom defined models

Openrouter

GPT-4 Turbo, Claude 3 Opus, Mixtral 8x7B, Llama 3.1 405B, & Custom defined models

Ollama

Mistral, Mixtral, Llama 3.1, Qwen, Gemma, & Custom defined models

Groq

Mixtral 8x7B, Llama 3, Llama 3.1, Gemma, & Custom defined models

TogetherAI

Custom models

Gemini

Gemini 1.5 Flash, Gemini 1.5 Flash 8B, Gemini 1.5 Pro, & Custom defined models

Each provider is accessible through a dedicated class (e.g., OpenaiModels, AnthropicModels, etc.) with methods corresponding to specific models. This structure allows for painless switching between models and providers, enabling users to leverage the most suitable LLM for their tasks.

Tools

Mainframe-Orchestra comes with a set of built-in tools that provide a wide range of functionalities, skills, actions, and knowledge for your agents to use in their task completion.

  • WebTools: For web scraping, searches, and data retrieval with Serper, Exa, WeatherAPI, etc.
  • FileTools: Handling various file operations like reading CSV, JSON, XML, YAML files and directory tree generation.
  • GitHubTools: Interacting with GitHub repositories, including listing contributors and fetching repository contents.
  • CalculatorTools: Performing date and time calculations.
  • EmbeddingsTools: Generating embeddings for text.
  • WikipediaTools: Searching and retrieving information from Wikipedia.
  • AmadeusTools: Searching for flight information.
  • LangchainTools: A wrapper for integrating Langchain tools to allow agents to use tools in the Langchain catalog.
  • LinearTools: Linear API-based tools for creating, updating, and retrieving tasks.
  • PineconeTools: Pinecone API-based tools for vector database operations like creating indexes and querying vectors.
  • MatplotlibTools: Creating various types of plots including line plots, scatter plots, bar plots, histograms, and heatmaps.
  • YahooFinanceTools: Financial data analysis including stock information, technical analysis, and fundamental analysis.
  • FredTools: Economic data analysis tools using the FRED (Federal Reserve Economic Data) API.
  • TextToSpeechTools: Text-to-speech conversion using ElevenLabs and OpenAI APIs.
  • WhisperTools: Audio transcription and translation using OpenAI's Whisper API.
  • Custom Tools: You can also create your own custom tools to add any functionality you need.

Multi-Agent Teams

Mainframe-Orchestra allows you to create multi-agent teams that can use tools to complete a series of tasks. Here's an example of a finance agent that uses multiple agents to analyze a stock:

from mainframe_orchestra import Task, Agent, Conduct, OpenaiModels, WebTools, YahooFinanceTools

# Create specialized agents
market_analyst = Agent(
    agent_id="market_analyst",
    role="Market Microstructure Analyst",
    goal="Analyze market microstructure and identify trading opportunities",
    attributes="You have expertise in market microstructure, order flow analysis, and high-frequency data.",
    llm=OpenaiModels.gpt_4o,
    tools={YahooFinanceTools.calculate_returns, YahooFinanceTools.get_historical_data}
)

fundamental_analyst = Agent(
    agent_id="fundamental_analyst",
    role="Fundamental Analyst",
    goal="Analyze company financials and assess intrinsic value",
    attributes="You have expertise in financial statement analysis, valuation models, and industry analysis.",
    llm=OpenaiModels.gpt_4o,
    tools={YahooFinanceTools.get_financials, YahooFinanceTools.get_ticker_info}
)

technical_analyst = Agent(
    agent_id="technical_analyst",
    role="Technical Analyst",
    goal="Analyze price charts and identify trading patterns",
    attributes="You have expertise in technical analysis, chart patterns, and technical indicators.",
    llm=OpenaiModels.gpt_4o,
    tools={YahooFinanceTools.get_historical_data}
)

sentiment_analyst = Agent(
    agent_id="sentiment_analyst",
    role="Sentiment Analyst",
    goal="Analyze market sentiment, analyst recommendations and news trends",
    attributes="You have expertise in market sentiment analysis.",
    llm=OpenaiModels.gpt_4o,
    tools={YahooFinanceTools.get_recommendations, WebTools.serper_search}
)

conductor_agent = Agent(
    agent_id="conductor_agent",
    role="Conductor",
    goal="Conduct the orchestra",
    attributes="You have expertise in orchestrating the orchestra.",
    llm=OpenaiModels.gpt_4o,
    tools=[Conduct.conduct_tool(market_analyst, fundamental_analyst, technical_analyst, sentiment_analyst)]
)

def chat_task(conversation_history, userinput):
    return Task.create(
        agent=conductor_agent,
        messages=conversation_history,
        instruction=userinput
    )

def main():
    conversation_history = []
    while True:
        userinput = input("You: ")
        conversation_history.append({"role": "user", "content": userinput})
        response = chat_task(conversation_history, userinput)
        conversation_history.append({"role": "assistant", "content": response})
        print(f"Market Analyst: {response}")

if __name__ == "__main__":
    main()

Note: this example requires the yahoofinance and yfinance packages to be installed. You can install them with pip install yahoofinance yfinance.

By combining agents, tasks, tools, and language models, you can create a wide range of workflows, from simple pipelines to complex multi-agent teams.

Documentation

For more detailed information, tutorials, and advanced usage, visit our documentation.

Contributing

Mainframe-Orchestra depends on and welcomes community contributions! Please review contribution guidelines and submit a pull request if you'd like to contribute.

License

Mainframe-Orchestra is released under the Apache License 2.0. See the LICENSE file for details.

Acknowledgments

Orchestra is a fork and further development of TaskflowAI.

Support

For issues or questions, please file an issue on our GitHub repository issues page.

⭐️ If you find Mainframe-Orchestra helpful, consider giving it a star!

Happy building!

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

mainframe_orchestra-0.0.14.tar.gz (75.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mainframe_orchestra-0.0.14-py3-none-any.whl (85.9 kB view details)

Uploaded Python 3

File details

Details for the file mainframe_orchestra-0.0.14.tar.gz.

File metadata

  • Download URL: mainframe_orchestra-0.0.14.tar.gz
  • Upload date:
  • Size: 75.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.8 Linux/6.8.0-1017-azure

File hashes

Hashes for mainframe_orchestra-0.0.14.tar.gz
Algorithm Hash digest
SHA256 79e5531b23b621ab399a8cceb0e63499c1c9bb97bb8cbdb93d6069eede1eabeb
MD5 c94beb2a2773287f75c1b5f02be020ff
BLAKE2b-256 5f3d845d59cc61e8a14604f54fb943453dc9fbb4219b18e83bb3dc626d57bf11

See more details on using hashes here.

File details

Details for the file mainframe_orchestra-0.0.14-py3-none-any.whl.

File metadata

  • Download URL: mainframe_orchestra-0.0.14-py3-none-any.whl
  • Upload date:
  • Size: 85.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.0 CPython/3.12.8 Linux/6.8.0-1017-azure

File hashes

Hashes for mainframe_orchestra-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 28b08714fb6db2b8717e1e7ab42004982ea2c77f8d9cce0605957526774c467b
MD5 acf168252da0e014f7b4f0f2cb9ba0cc
BLAKE2b-256 8f5f3dce79510ad8bf9f40c60c70c769b8e1badfde84a47ebe0aa8739d1871dd

See more details on using hashes here.

Supported by

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