diff --git a/test/schema/conditional_workflow.json b/test/schema/conditional_workflow.json new file mode 100644 index 0000000..15e4a6c --- /dev/null +++ b/test/schema/conditional_workflow.json @@ -0,0 +1,66 @@ +{ + "apiVersion": "beehive/v1", + "kind": "Workflow", + "metadata": { + "name": "beehive-deployment", + "labels": { + "app": "example2" + } + }, + "spec": { + "strategy": { + "type": "sequence" + }, + "template": { + "metadata": { + "name": "beehive-deployment", + "labels": { + "app": "example", + "use-case": "test" + } + } + }, + "agents": [ + "agent1", + "agent2", + "agent3" + ], + "exception": "step3", + "steps": [ + { + "name": "step1", + "agent": "agent1", + "condition": [ + { + "if": "{$in.some_condition == True}", + "then": "step2", + "else": "step3" + } + ] + }, + { + "name": "step2", + "agent": "agent2" + }, + { + "name": "step3", + "agent": "agent3", + "condition": [ + { + "case": "{$in.some_condition == True}", + "do": "step2" + }, + { + "case": "{$in.some_condition == False}", + "do": "step3" + }, + { + "default": { + "do": "step3" + } + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/schema/conditional_workflow.yml b/test/schema/conditional_workflow.yml new file mode 100644 index 0000000..110422d --- /dev/null +++ b/test/schema/conditional_workflow.yml @@ -0,0 +1,38 @@ +apiVersion: beehive/v1 +kind: Workflow +metadata: + name: beehive-deployment + labels: + app: example2 +spec: + strategy: + type: sequence + template: + metadata: + name: beehive-deployment + labels: + app: example + use-case: test + agents: + - agent1 + - agent2 + - agent3 + exception: step3 + steps: + - name: step1 + agent: agent1 + condition: + - if: '{$in.some_condition == True}' + then: step2 + else: step3 + - name: step2 + agent: agent2 + - name: step3 + agent: agent3 + condition: + - case: '{$in.some_condition == True}' + do: step2 + - case: '{$in.some_condition == False}' + do: step3 + - default: + do: step3 diff --git a/test/schema/funnier_workflow.json b/test/schema/funnier_workflow.json new file mode 100644 index 0000000..8e67842 --- /dev/null +++ b/test/schema/funnier_workflow.json @@ -0,0 +1,56 @@ +{ + "apiVersion": "beehive/v1alpha1", + "kind": "Workflow", + "metadata": { + "name": "beehive-deployment", + "labels": { + "app": "mas-example" + } + }, + "spec": { + "strategy": { + "type": "condition", + "output": "nonal" + }, + "template": { + "metadata": { + "labels": { + "app": "mas-example" + } + }, + "agents": [ + { + "name": "expert" + }, + { + "name": "colleague" + } + ], + "prompt": "Tell me a joke about IBM", + "start": "expert", + "steps": [ + { + "name": "expert", + "agent": "expert", + "condition": [ + { + "default": null, + "do": "colleague" + } + ] + }, + { + "name": "colleague", + "agent": "colleague", + "condition": [ + { + "if": "(input.find('funnier') != -1)", + "then": "expert", + "else": "end" + } + ] + } + ] + } + } +} \ No newline at end of file diff --git a/test/schema/funnier_workflow.yml b/test/schema/funnier_workflow.yml new file mode 100644 index 0000000..f863d0b --- /dev/null +++ b/test/schema/funnier_workflow.yml @@ -0,0 +1,31 @@ +apiVersion: beehive/v1alpha1 +kind: Workflow +metadata: + name: beehive-deployment + labels: + app: mas-example +spec: + strategy: + type: condition + output: nonal + template: + metadata: + labels: + app: mas-example + agents: + - name: expert + - name: colleague + prompt: Tell me a joke about IBM + start: expert + steps: + - name: expert + agent: expert + condition: + - default: + do: colleague + - name: colleague + agent: colleague + condition: + - if: { input.find('funnier') != -1 } + then: expert + else: end \ No newline at end of file diff --git a/test/schema/simple_workflow.yaml b/test/schema/simple_workflow.yml similarity index 100% rename from test/schema/simple_workflow.yaml rename to test/schema/simple_workflow.yml diff --git a/tools/workflow_schema.json b/tools/workflow_schema.json index 63d4092..fcac4f7 100644 --- a/tools/workflow_schema.json +++ b/tools/workflow_schema.json @@ -4,48 +4,121 @@ "title": "BeeAI Hive", "description": "A schema for defining Bee Hive workflows in YAML or JSON", "type": "object", - "metadata": { - "type": "object", - "properties": { - "name": { + "properties": { + "metadata": { + "apiVersion": { "type": "string", - "description": "workflow name" + "description": "beehive/v1" }, - "labels": { - "type": "object", - "description": "workflow labels, key: value pairs" - } - }, - "required": [ - "name" - ] - }, - "spec": { - "strategy": { - "type": "sequence" - }, - "properties": { - "name": { + "kind": { "type": "string", - "description": "workflow name" + "description": "Workflow" + }, + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "workflow name" + }, + "labels": { + "type": "object", + "description": "workflow labels, key: value pairs" + } }, - "labels": { - "type": "object", - "description": "workflow labels, key: value pairs" + "required": [ + "name" + ] + }, + "spec": { + "type": "object", + "properties": { + "strategy": { + "type": "object", + "properties": { + "type": { + "type":"string", + "description": "sequence, condition" + } + } + }, + "template": { + "type": "object", + "properties": { + "meatdata": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "workflow name" + }, + "labels": { + "type": "object", + "description": "workflow labels, key: value pairs" + } + } + } + } + }, + "agents": { + "type": "array", + "items": { + "type": "string" + } + }, + "exception": { + "type": "string" + }, + "prompt": { + "type": "string" + }, + "steps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "step name" + }, + "agent": { + "type": "string", + "description": "the agent for this step" + }, + "condition": { + "type": "array", + "description": "if/then/else or case/do/default condition", + "items": { + "type": "object", + "properties": { + "if": { + "type": "string" + }, + "then": { + "type": "string" + }, + "else": { + "type": "string" + }, + "case": { + "type": "string" + }, + "do": { + "type": "string" + }, + "default": { + "type": "string" + } + } + } + } + }, + "required": [ + "name", + "agent" + ] + } + } } } - }, - "agents": { - "type": "array", - "items": { - "type": "string" - } - }, - "steps": { - "type": "array", - "items": { - "type": "string" - } - }, - "exception": "string" + } } \ No newline at end of file