API Endpoints
- Generate FSM JSON
This endpoint converts a text prompt into an FSM JSON structure.
Endpoint: POST /generate-json
Content-Type: application/x-www-form-urlencoded or application/json (parameters can be sent as query parameters or in a JSON body).
Parameters:
msg (string, required): Description of the UI or chatbot flow.
extract_state_names_node (string, optional): Prompt version for the initial state extraction step. Defaults to "latest".
create_json_generation_prompt (string, optional): Prompt version for the JSON generation step. Defaults to "latest".
Example Request (using curl):
Bash
curl -X POST "http://localhost:8080/generate-json?msg=Create%20a%20chatbot%20for%20a%20tutor:%20introduction,%20lesson%20schedule,%20reminders,%20and%20FAQ." \
-H "accept: application/json"
Or with specific prompt versions:
Bash
curl -X POST "http://localhost:8080/generate-json?msg=Create%20a%20chatbot%20for%20a%20tutor:%20introduction,%20lesson%20schedule,%20reminders,%20and%20FAQ.&extract_state_names_node=v3&create_json_generation_prompt=v2" \
-H "accept: application/json"
Success Response: A dictionary containing the full State object after graph execution. The FSM JSON is available within result_state.valid_fsm_data.
JSON
{
"json": {
"user_prompts": [
"Create a chatbot for a tutor: introduction, lesson schedule, reminders, and FAQ."
],
"generations": [
// ... (LLM responses and intermediate prompts)
],
"actions_found": [],
"valid_fsm_data": [
{
"message_blocks": [
// ... generated message blocks
],
"trigger_blocks": [
// ... generated trigger blocks
],
"edges": [
// ... generated connections
]
}
],
"states": [
"message_block_schema",
"trigger_block_schema",
"edge_schema"
],
"gen_prompt": "...",
"user_history": null,
"prompt_version": {
"extract_state_names_node": "latest",
"create_json_generation_prompt": "latest"
}
}
}
Error Responses:
```Bash 400 Bad Request: Invalid input or prompt version issues.
# OR
500 Internal Server Error: Unexpected errors during LLM interaction, JSON parsing, or graph execution. ```
- Add/Update Prompt Template
This endpoint allows adding new or updating existing AI prompt templates in prompt_storage.json
Endpoint: POST /add-prompt
Content-Type: application/json
JSON Body Parameters:
name (string, required): The prompt's unique identifier (e.g., "extract_state_names_node").
version (string, required): The version string for the prompt (e.g., "v1.0", "latest").
template (string, required): The prompt template string, which can include placeholders (e.g., {prompt}, {schema}).
prompt_name (string, optional): A descriptive name for the prompt. Defaults to "base_prompt".
Example Request:
Bash
curl -X POST "http://localhost:8080/add-prompt" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"name": "new_prompt_type",
"version": "v1.0",
"template": "This is a new template: {input_data}. Analyze: {analysis_target}",
"prompt_name": "New Prompt for Testing"
}'
Success Response:
JSON
{
"status": "ok",
"message": "Prompt 'new_prompt_type' version 'v1.0' added/updated."
}
Error Responses:
Bash
500 Internal Server Error: Issues reading from or writing to prompt_storage.json.