Skip to main content

Orchestrator

Here is an architectural overview of the Orchestrator Service.

Orchestrator Architecture
Architecture

Orchestrator

Orchestrator service works as a dynamic tool that simplifies the execution of a bot by transforming an array of transformers into a structured state machine using the Xstate library. This facilitates the seamless coordination and execution of specific functionalities represented by individual transformers within the system. Orchestrator ingests a "logic definition" and creates a state machine out of it, which enables chaining different Transformers together to create a customized bot flow.

API Endpoints

1. /prompt

POST
/prompt Executes bot and sends response to outbound service

Request Body

NameTypeRequiredDescription
logicDefJSONYESA bot's logic definition, which is used to create a state machine. Learn more about how to chain multiple transformers to create a logic definition here.
messageXMessageYESUser's message in XMessage format.
userHistoryArray<XMessageModel>NOUser's conversation history with a bot. Currently, only last 2 (user's) messages are considered for processing.

Curl Request

curl --location 'http://localhost:3001/prompt' \
--header 'Content-Type: application/json' \
--data '{
"xstate": [
{
"id": "translate",
"type": "Translate",
"config": {
"provider": "bhashini",
"openAIAPIKey": "vault/openAIAPIKey",
"bhashiniAPIKey": "vault/bhashiniAPIKey",
"bhashiniUserId": "vault/bhashiniUserId",
"userLanguage": "hi",
"outputLanguage": "en"
},
"states": {
"onSuccess": "llm"
}
},
{
"id": "llm",
"type": "LLM",
"config": {
"model": "gpt-4",
"bhashiniURL": "vault/bhashiniURL",
"outboundURL": "vault/outboundURL",
"temperature": 0,
"openAIAPIKey": "vault/openAIAPIKey",
"bhashiniAPIKey": "vault/bhashiniAPIKey",
"bhashiniUserId": "vault/bhashiniUserId",
"outputLanguage": "hi"
},
"states": {
"onSuccess": "done"
}
}
],
"message": {
"messageType": "TEXT",
"messageId": {
"Id": "985adbc6-8481-4d85-89e0-1bf0cd131692",
"channelMessageId": "985adbc6-8481-4d85-89e0-1bf0cd131692"
},
"to": {
"userID": "5b1d9f5b-62d3-4e2b-93fd-9c46c94d2d15"
},
"from": {
"userID": "81ac6cb0-5956-4483-94c6-a7882fc723f5",
"meta": {
"mobileNumber": "9999999999"
}
},
"channelURI": "Whatsapp",
"providerURI": "Gupshup",
"timestamp": 0,
"messageState": "REPLY",
"payload": {
"text": "गेहूं उगाने का सबसे अच्छा समय?"
}
},
"userHistory": []
}'

In the above example we are executing a bot which uses 2 tranformers (Translate and LLM).

Where this bot flow works as below:

(user)[question in hindi] -> (bot)[translates user message from hindi to english] -> (bot)[sends this to LLM and gets response] -> (bot)[translates back to hindi] -> (bot)[sends response to user]

Above example is just an simple translate+LLM execution but, One can create any type of custom flow combining various transformers available.