|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
Declarative YAML/JSON loader for AI Workflows. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <yaml.h>#include "cJSON.h"#include "csilk/app/workflow.h"
Data Structures | |
| struct | handler_entry_t |
Functions | |
| void | csilk_wf_register_handler (const char *name, csilk_wf_handler_t handler) |
| Register a global handler for use in declarative workflows. | |
| static csilk_wf_handler_t | find_handler (const char *name) |
| Internal: look up a handler by name in the singly-linked list registry. | |
| csilk_wf_t * | csilk_wf_from_json (const char *json_str) |
| Build a complete workflow from a JSON string. | |
| static cJSON * | parse_yaml_file (const char *path) |
| Internal: parse a YAML file into a cJSON tree using libyaml. | |
| csilk_wf_t * | csilk_wf_load_yaml (const char *path) |
| Load a workflow from a YAML file on disk. | |
Variables | |
| static handler_entry_t * | g_handlers = NULL |
Declarative YAML/JSON loader for AI Workflows.
| struct handler_entry_t |

| Data Fields | ||
|---|---|---|
| csilk_wf_handler_t | handler | |
| char * | name | |
| struct handler_entry_s * | next | |
| csilk_wf_t * csilk_wf_from_json | ( | const char * | json_str | ) |
Build a complete workflow from a JSON string.
Create a workflow from a JSON string.
Parses the JSON into a three-pass construction: Pass 1: Create all nodes from the "steps" array. Each step has an "id", optional "type" ("ai" or "handler"), and optional "config" for AI nodes. AI nodes use csilk_wf_add_ai() with prompt/model config; handler nodes use csilk_wf_add() with a registered callback. Pass 2: Create connections from the "connections" array. Each connection links a source ("from") to a target ("to"), optionally with a "condition" for conditional edges or "loop: true" for loops. Pass 3: Set error targets from each step's "on_error" field.
| json_str | Null-terminated JSON string. |
| csilk_wf_t * csilk_wf_load_yaml | ( | const char * | path | ) |
Load a workflow from a YAML file on disk.
Load a workflow definition from a YAML file.
Parses the YAML into cJSON via parse_yaml_file(), then delegates to csilk_wf_from_json() for workflow construction. This two-step approach avoids duplicated parsing logic.
| path | Path to a .yaml or .yml file. |
| void csilk_wf_register_handler | ( | const char * | name, |
| csilk_wf_handler_t | handler | ||
| ) |
Register a global handler for use in declarative workflows.
| name | Unique name (matches 'handler' key in YAML/JSON). |
| handler | Function pointer. |
|
static |
Internal: look up a handler by name in the singly-linked list registry.
| name | Handler name (case-sensitive). |
|
static |
Internal: parse a YAML file into a cJSON tree using libyaml.
Algorithm (iterative, no recursion):
| path | Filesystem path to the YAML file. |
|
static |