SOFIA: Simple Orchestrated Flow Intelligence Agent
Project description
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.
- Package-based tools: Reference Python package functions directly using
package_name:functionsyntax. - Auto tool documentation: Tool descriptions and parameter documentation are automatically generated from docstrings.
- 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/sofia-hq/sofia.git
cd sofia
poetry install
Usage: From No-Code to Low-Code to Full Code
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():
"""Get the current time.
Returns:
str: The current time in string format.
"""
from datetime import datetime
return f"Current time: {datetime.now()}"
steps = [
Step(
step_id="start",
description="Greet and offer to tell the time or perform calculations.",
available_tools=["get_time", "math:sqrt"], # Direct reference to the sqrt function from math package
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, "math:sqrt"], # Mix of custom functions and package references (Optional for package functions)
persona="You are a friendly assistant that can tell time and perform calculations.",
)
sess = agent.create_session()
# ... interact with sess.next(user_input)
YAML Config Example
name: utility-bot
persona: You are a helpful utility bot that can perform various calculations and data operations.
steps:
- step_id: start
description: Handle user requests for mathematical operations or data processing.
available_tools:
- math:sqrt
- json:loads
- itertools:combinations
routes:
- target: end
condition: User is done with calculations
- step_id: end
description: Say goodbye to the user.
start_step_id: start
See examples/config.barista.yaml for a more full-featured example.
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 or package references.
Package Tool Integration
SOFIA now allows you to reference Python package functions directly using the package_name:function syntax:
# Reference a function from a standard library
"math:sqrt" # Standard library function
"json:loads" # Another standard library function
"itertools:combinations" # Complex functions work too!
# Reference nested module functions
"package_name:module.submodule.function"
Benefits of package tool integration:
- No-code/low-code development: Use existing Python functions without writing wrapper code
- Automatic documentation: Function docstrings are used to generate tool descriptions and parameter documentation
- Simplified configuration: Easily reference any Python function in your environment
Tool parameter descriptions in configuration files take precedence over automatically extracted docstring descriptions.
NOTE: Make sure the package is installed in your environment and function returns an output that is string representable.
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:
- 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/
- 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 fromCONFIG_PATH: Path to a mounted config fileOPENAI_API_KEY: Your OpenAI API keyREDIS_URL: Optional Redis URL for session management
Contributing
Contributions are welcome! Please open issues or pull requests on GitHub.
From No-Code to Low-Code Evolution
SOFIA is evolving to support a spectrum of implementation approaches:
No-Code
- Configure agents entirely through YAML
- Reference existing Python functions using
package_name:functionsyntax - Auto-documentation from function docstrings
Low-Code
- Minimal Python code for custom tools
- Mix pre-existing package tools with custom tools
- Configure complex behaviors with minimal coding
Full-Code
- Complete control over agent implementation
- Custom tool development
- Advanced integrations and behaviors
This flexibility allows both non-programmers and experienced developers to create sophisticated AI agents that suit their needs.
License
MIT License. See LICENSE.
Acknowledgements
- Inspired by the open-source LLM community.
- Built with ❤️ by contributors.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sofia_agent-0.1.10.tar.gz.
File metadata
- Download URL: sofia_agent-0.1.10.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39c7c1666033c13dfb429ebf37190f826296cedfec41ffdffbfb744691529cc6
|
|
| MD5 |
09e7d2aede4e64576c813a3da2e0c88d
|
|
| BLAKE2b-256 |
fb103ea4d5a80c467668ed5f65488afa18c51bd246bef6fe7ffe920ad7d41ac9
|
Provenance
The following attestation bundles were made for sofia_agent-0.1.10.tar.gz:
Publisher:
publish.yml on sofia-hq/sofia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sofia_agent-0.1.10.tar.gz -
Subject digest:
39c7c1666033c13dfb429ebf37190f826296cedfec41ffdffbfb744691529cc6 - Sigstore transparency entry: 209956231
- Sigstore integration time:
-
Permalink:
sofia-hq/sofia@242159a415343c910b159ab065eb93e1abf4044b -
Branch / Tag:
refs/tags/0.1.10 - Owner: https://github.com/sofia-hq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@242159a415343c910b159ab065eb93e1abf4044b -
Trigger Event:
push
-
Statement type:
File details
Details for the file sofia_agent-0.1.10-py3-none-any.whl.
File metadata
- Download URL: sofia_agent-0.1.10-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e66687d6e3f5f00c4106325535b520e46786c1b92add50d2f0b6597a2eca9f1
|
|
| MD5 |
25bc830254954303ec82469c7b83b5ef
|
|
| BLAKE2b-256 |
667ef5d43ad76f67b0ad6a01d5bc133ecf54d0c06d05e4b72984f11faa247c5b
|
Provenance
The following attestation bundles were made for sofia_agent-0.1.10-py3-none-any.whl:
Publisher:
publish.yml on sofia-hq/sofia
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sofia_agent-0.1.10-py3-none-any.whl -
Subject digest:
7e66687d6e3f5f00c4106325535b520e46786c1b92add50d2f0b6597a2eca9f1 - Sigstore transparency entry: 209956239
- Sigstore integration time:
-
Permalink:
sofia-hq/sofia@242159a415343c910b159ab065eb93e1abf4044b -
Branch / Tag:
refs/tags/0.1.10 - Owner: https://github.com/sofia-hq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@242159a415343c910b159ab065eb93e1abf4044b -
Trigger Event:
push
-
Statement type: