Skip to main content

SOFIA: Simple Orchestrated Flow Intelligence Agent

Project description

sofia

Simple Orchestrated Flow Intelligence Agent

PyPI - Version codecov Test Release

SOFIA is an open-source, configurable multi-step agent framework for building advanced LLM-powered assistants. Define your agent's persona, tools, and step-by-step flows in Python or YAML—perfect for conversational, workflow, and automation use cases.

Features

  • Step-based agent flows: Define agent behavior as a sequence of steps, each with its own tools and transitions.
  • Persona-driven: Easily set the agent's persona for consistent, branded responses.
  • Tool integration: Register Python functions as tools for the agent to call.
  • YAML or Python config: Configure agents via code or declarative YAML.
  • OpenAI and custom LLM support
  • Session management: Save and resume conversations.
  • Extensible: Build your own tools, steps, and integrations.
  • Interactive CLI: Bootstrap new agents with sofia init (install with [cli] extra).

Installation

From PyPI

pip install sofia-agent

With CLI support

pip install sofia-agent[cli]

From Source

git clone https://github.com/chandralegend/sofia.git
cd sofia
poetry install

Usage

CLI: Bootstrap a New Agent

sofia init

This will interactively guide you to create a config YAML and starter Python file for your agent.

Python API Example

from sofia_agent import *
from sofia_agent.llms import OpenAIChatLLM

def get_time():
    from datetime import datetime
    return f"Current time: {datetime.now()}"

steps = [
    Step(
        step_id="start",
        description="Greet and offer to tell the time.",
        available_tools=["get_time"],
        routes=[Route(target="end", condition="User is done")],
    ),
    Step(
        step_id="end",
        description="Say goodbye.",
    ),
]

llm = OpenAIChatLLM()
agent = Sofia(
    name="clockbot",
    llm=llm,
    steps=steps,
    start_step_id="start",
    tools=[get_time],
    persona="You are a friendly clock assistant.",
)
sess = agent.create_session()
# ... interact with sess.next(user_input)

YAML Config Example

See examples/config.barista.yaml for a full-featured barista agent.

Configuration

  • Persona: Set in YAML or Python for consistent agent style.
  • Steps: Each step defines available tools, description, and routes to other steps.
  • Tools: Python functions registered with the agent.

Example: Barista Agent

A full example is provided in examples/barista/barista.py and examples/config.barista.yaml.

To run the Barista agent:

cd examples/barista
export OPENAI_API_KEY=your-api-key-here
python barista.py
# or
python barista_with_config.py

Example: Financial Planning Assistant

A production-ready example of a Financial Planning Assistant is available in examples/financial-advisor/. This example demonstrates:

  • Budget planning and expense tracking
  • Savings goal management
  • Financial health assessment
  • Uses the sofia-base Docker image
  • Production-ready configuration

To run the Financial Planning Assistant:

docker run -e OPENAI_API_KEY=your-api-key-here -p 8000:8000 financial-advisor

Docker Base Image

SOFIA provides a base Docker image that you can use to quickly containerize your agents. The base image is available on Docker Hub as chandralegend/sofia-base.

To use the base image in your own agent:

  1. Create a Dockerfile:
FROM chandralegend/sofia-base:latest

# Copy your config file
COPY config.agent.yaml /app/config.agent.yaml

# Copy your tools
COPY tools.py /app/tools/
  1. Build and run your container:
docker build -t my-sofia-agent .
docker run -e OPENAI_API_KEY=your-api-key-here -p 8000:8000 my-sofia-agent

The base image supports configuration via environment variables:

  • CONFIG_URL: URL to download the agent configuration from
  • CONFIG_PATH: Path to a mounted config file
  • OPENAI_API_KEY: Your OpenAI API key
  • REDIS_URL: Optional Redis URL for session management

Contributing

Contributions are welcome! Please open issues or pull requests on GitHub.

License

MIT License. See LICENSE.

Acknowledgements

  • Inspired by the open-source LLM community.
  • Built with ❤️ by contributors.

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

sofia_agent-0.1.8.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

sofia_agent-0.1.8-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file sofia_agent-0.1.8.tar.gz.

File metadata

  • Download URL: sofia_agent-0.1.8.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sofia_agent-0.1.8.tar.gz
Algorithm Hash digest
SHA256 fba6d256aef9d8399492839181274fe11c30f45c13824e2c593aa9e590eae624
MD5 233ce8d9f9a3a7ea0f74d66556a7a621
BLAKE2b-256 d66b5487a357bdc093c261ccc1a31ed5b8be6cc7c4b9e1dbcc4379599ed60c9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for sofia_agent-0.1.8.tar.gz:

Publisher: publish.yml on sofia-hq/sofia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sofia_agent-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: sofia_agent-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for sofia_agent-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4f6294d1084d3f5881d9971073ce121aae2549c8c21c3a18697d36c64f8d730b
MD5 429688b31d624b6cf64d08f370132298
BLAKE2b-256 f02d8c35d16ecd4822ca9e05a44d033f88799087cf69870c7df35865c8366d63

See more details on using hashes here.

Provenance

The following attestation bundles were made for sofia_agent-0.1.8-py3-none-any.whl:

Publisher: publish.yml on sofia-hq/sofia

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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