Skip to content

Agentic application

Danger

The features and api described in this section are under heavy development and therefore subject to change. Be prepared for it to break.

However if you don't care about an unstable API, using the features in this mode of the orchestrator will unlock quite a bit of potential

The Agentic mode of the Orchestrator can be unlocked by doing the following.

Pre-requisites

  • pg_vector installed in your postgres database
  • At minimum an api_key to talk to ChatGPT
  • The UI configured to with the LLM integration branch - still WIP - https://github.com/workfloworchestrator/example-orchestrator-ui/pull/72/files

Step 1 - Install the package:

Create a virtualenv and install the core including the LLM dependencies.

python -m venv .venv
source .venv/bin/activate
pip install orchestrator-core[llm]

Step 2 - Setup the database:

Create a postgres database, make sure your postgres install has the pgvector extension installed:

createuser -sP nwa
createdb orchestrator-core -O nwa

Choose a password and remember it for later steps.

As an example, you can run these docker commands in separate shells to start a temporary postgres instance:

docker run --rm --name temp-orch-db -e POSTGRES_PASSWORD=rootpassword -p 5432:5432 postgres:15

docker exec -it temp-orch-db su - postgres -c 'createuser -sP nwa && createdb orchestrator-core -O nwa'

Step 3 - Create the main.py:

Create a main.py file.

from orchestrator import AgenticOrchestratorCore
from orchestrator.cli.main import app as core_cli
from orchestrator.settings import app_settings
from orchestrator.llm_settings import llm_settings

llm_settings.LLM_ENABLED = True
llm_settings.AGENT_MODEL = 'gpt-4o-mini'
llm_settings.OPENAI_API_KEY = 'xxxxx'


app = AgenticOrchestratorCore(
    base_settings=app_settings,
    llm_settings=llm_settings,
    llm_model=llm_settings.AGENT_MODEL,
    agent_tools=[]
)

if __name__ == "__main__":
    core_cli()

Step 4 - Run the database migrations:

Initialize the migration environment and database tables.

export DATABASE_URI=postgresql://nwa:PASSWORD_FROM_STEP_2@localhost:5432/orchestrator-core

python main.py db init
python main.py db upgrade heads

Step 5 - Run the app

export DATABASE_URI=postgresql://nwa:PASSWORD_FROM_STEP_2@localhost:5432/orchestrator-core
export OAUTH2_ACTIVE=False

uvicorn --reload --host 127.0.0.1 --port 8080 main:app

Step 6 - Index all your current subscriptions, processes, workflows and products:

Warning

This will call out to external LLM services and cost money

python main.py index subscriptions
python main.py index products
python main.py index processes
python main.py index workflows  

Step 7 - Profit 💥 😁

Visit the ReDoc or OpenAPI to view and interact with the API.

Next: