# Astron Workflow
You design, connect, automate.
Astron Workflow keeps it running.
# 1. Astron Workflow Core Advantages
| Advantage | Description |
|---|---|
| Multi-Paradigm, One-Stop Agent Development | End-to-end development and optimization across Prompt, Workflow, and Agentic Workflow — powered by a 1+N+X model (General + Vertical fields like Healthcare, Education, and Cultural Tourism + Open-Source High-Quality Models). |
| Voice & Virtual Human Agents | Native support for voice interaction, virtual humans, voice cloning, and persona customization — enabling truly human-like agent experiences. |
| Intelligent RPA for Cross-System Collaboration | Built-in RPA capabilities automate workflows across enterprise systems, desktop environments, and web applications. |
| AI Tools & Enterprise Plugin Ecosystem | 100+ curated AI plugins and enterprise-grade tools, with one-click MCP integration for rapidly assembling complex agent capabilities. |
| Agentic Workflow Auto-Generation | Automatically generates executable agent workflows, dramatically boosting development efficiency. |
| Enterprise-Grade Management & Operations | Team workspaces, granular access control, and performance feedback loops support agents' full lifecycle — from development to continuous optimization. |
# 2. How to Use Astron Workflow Platform
# 2.1 Development of Prompt Agents
# 2.1.1 Function Overview
Quickly configure prompts to build instruction-based agents in just a few clicks.
Ideal for lightweight conversational scenarios such as copywriting, story creation, text translation, and AI image generation — while also supporting knowledge base integration, H5 page publishing, and API-based output for external systems.
# 2.1.2 Agent Creation
After entering the Astron Workflow platform, click Create on the left panel, then select Prompt Creation from the pop-up dialog. Enter a one-sentence description in the dialog that appears, and click Create Agent to enter the instruction-based agent setup page, where developers can configure detailed agent settings.
The following section explains how to create an Prompt agent.
# 2.1.2.1 Basic Information Filling
Setting up a Prompt Agent requires four mandatory fields:
Agent Name, Agent Category, Agent Description, and Agent Avatar.
To provide users with clear guidance on how to use the agent, it's recommended to fill out this information as completely as possible.
# 2.1.2.2 Prompt Editing
The content in the dialog box serves as the input instructions for the large language model, and how these instructions are configured directly affects the agent's performance. Prompt editing consists of three key fields:
Role, Task, and Reply Requirements.
Details are as follows:
| Field | Description |
|---|---|
| Role | Define a role for the agent. For example, for an "Interviewer Simulator" assistant, the role could be set as "You are an experienced interviewer." |
| Task | Specify the task the agent needs to accomplish. For example, for an "Interviewer Simulator" assistant, the task could be "Based on the job position I provide, list common interview questions for that role." |
| Reply Requirements | Specify any additional instructions or requirements for the agent's responses. For example, for an "Interviewer Simulator" assistant, the requirement could be "Provide 5 questions, listed as separate items." |
# 2.1.2.3 Advanced Settings
Advanced Settings define capabilities beyond basic role-based conversation, including Knowledge Base and Conversation Enhancement. These settings help improve the agent's usability and conversational performance.
| Function | Description |
|---|---|
| Knowledge Base | Binding a knowledge base to the agent during creation allows the agent to retrieve answers from that knowledge base when interacting with users. Click the Add Knowledge Base button on the right, select the knowledge base you want to bind from the pop-up page, and click Add to complete the binding. |
| Conversation Enhancement | |
| Opening Remarks | The opening remarks are the first message automatically displayed when a user enters the agent, used to introduce the agent. You can configure this to help users quickly understand what the agent does. |
| Voice Persona | The agent supports configurable voice personas — when users choose to have the agent's generated content read aloud, it can be played back using different voice options. |
| Multi-Turn Conversation | This setting determines whether the agent retains contextual memory during a conversation. If Multi-Turn Conversation is turned off, the agent will not remember previous context, and each exchange will be treated as a new, independent conversation. If turned on, the agent will retain context from prior exchanges. |
| Background Image | Allows users to upload an image as a background during conversations. If disabled, this feature is not supported. |
# 2.1.3 Debug Preview, and Publish
The platform supports debugging an agent while it's being created. On the agent settings page, developers can write prompts and test their effects in real time, refining the prompt until satisfied with the results.
Prompt Agents can be published as embeddable web pages — you can embed the agent as an iframe into your own website.
# 2.1.4 Prompt and Model Comparison & Tuning
# 2.1.4.1 Prompt Comparison
Prompt comparison involves designing multiple sets of different prompts and comparing their effects on model output (e.g., accuracy, relevance, logical coherence) in order to optimize prompts and achieve results that better meet expectations. This process is essential in LLM applications, as it directly impacts the quality of model responses.
To use this feature:
Click the Prompt Comparison button. Two prompt editing boxes will appear on the pop-up page — a Default Prompt and a Comparison Prompt.
Users can edit and modify the prompts as needed to test the agent's performance under different prompt configurations. Once testing is complete, select the preferred prompt to finalize the comparison.
# 2.1.4.2 Model Comparison
The Model Comparison feature allows developers to test multiple models in parallel. By directly comparing the response quality of different models, developers can select the best-performing model to optimize the agent's responses.
To use this feature:
Click the Model Comparison button — two models will appear by default. Up to four models can be compared simultaneously. Click the Add Model button in the top-right corner to add additional models as needed.
Once the models are selected, enter test content in the input field to compare how the same input performs across different models, helping you choose the model best suited to your needs.
# 2.2 Development of Workflow Agents
# 2.2.1 Function Overview
Workflow Agents orchestrate multiple task nodes into a coherent process, enabling automated handling of a wide range of business scenarios. Nodes cover stages such as data input, processing, and output, working together to build workflows that are both efficient and flexible.
Once a workflow is complete, the Workflow Agent can be published as an embeddable web page or published as an API with one click, allowing for quick integration into your own business systems.
Typical use cases include:
- Boosting Office Efficiency: Quickly build workflows and applications for office, healthcare, and innovation scenarios — such as knowledge-based intelligent customer service systems, technical support agents combining knowledge and tools, campus student assistant agents, and hospital triage and consultation agents.
- Bringing Creative Ideas to Life: Build Workflow Agents for lightweight office, lifestyle, and entertainment scenarios — such as daily industry news briefing agents, picture book creation agents, and various casual game agents.
# 2.2.2 Agent Creation
After entering the Astron Workflow platform, click Create on the left panel, then select Workflow Creation from the pop-up dialog.
Workflow Agent creation supports two methods:
- Custom Creation: Provides a blank canvas, allowing users to build a Workflow Agent from scratch according to their own needs.
- Template Creation: The platform offers a rich library of templates, allowing users to replicate similar functionality with one click. This enables developers with zero coding experience to quickly complete workflow orchestration for even complex tasks.
This guide uses Custom Creation as an example to walk through the process of building a complete Workflow Agent. On the pop-up page, select Custom Creation to begin building your workflow from scratch.
# 2.2.2.1 Basic Information Filling
After selecting Custom Creation and entering the blank canvas, click the Edit icon in the top-left corner to configure the workflow's basic information. This includes two mandatory fields — Workflow Name and Workflow Description — and one optional field, Workflow Category.
# 2.2.2.2 Advanced Settings
Click the Setting icon in the top-right corner of the canvas to access Advanced Settings, which define capabilities beyond basic conversational interaction. These settings help improve the agent's usability and conversational performance.
Details are as follows:
| Function | Description |
|---|---|
| Conversation Opening | The opening remarks are the first message automatically displayed when a user enters the agent, used to introduce the agent. You can configure this to help users quickly understand what the agent does, and the opening message can also be AI-generated. Users can additionally set Reserved Questions for Opening (up to three). These questions appear within the agent's conversation window as reference prompts, helping guide users on how to interact with the agent and steer the direction of the conversation. |
| Next Question Suggestions | When enabled, this feature generates guiding follow-up prompts after a conversation ends, encouraging further interaction while helping surface users' underlying needs — better meeting diverse user requirements and improving the overall experience. |
| Role Voice | The agent supports configurable voice personas — when users choose to have the agent's generated content read aloud, it can be played back using different voice options. Users can select a voice persona suited to their needs, enhancing immersion and meeting voice-interaction requirements across different application scenarios. |
| Background Image | Allows users to upload an image as a background during conversations. If disabled, this feature is not supported. |
# 2.2.2.3 Workflow Orchestration
The system automatically creates a Start Node and an End Node. Developers only need to modify the relevant code or node logic according to their specific needs to build a complete workflow.
# 2.2.2.4 Version History
Click the Version History button in the top-right corner of the canvas to view previous versions in the pop-up page. You can switch between historical versions as needed.
# 2.2.2.5 Comparison Testing
Before running a comparison test, the workflow must first be bound to a prompt group. Click the Test Comparison button in the top-right corner of the canvas to perform comparison testing in the pop-up page.
# 2.2.2.6 Exporting and Importing Workflows
To facilitate the sharing and transfer of Workflow Agents, the platform provides convenient export and import functionality.
Please note: if a workflow includes custom tools, knowledge bases, or self-built models, these components will not be directly usable after import. Users will need to recreate the corresponding custom tools, or rebuild the knowledge base and self-built models, to ensure the workflow runs properly.
(1) Exporting a Workflow
On the My Agents page, locate the corresponding Workflow Agent, then select Export in the bottom-right corner to complete the export. Exported workflows are saved in YML format.
(2) Importing a Workflow
When creating a Workflow Agent, select the Import Workflow option in the top-right corner, then upload the workflow file in the pop-up page. The workflow file must be in YML format, with a file size limit of 20MB. Click Save to complete the import.
# 2.2.2.7 Partial Canvas Copy and Single Node Copy
To help developers quickly duplicate identical nodes, the platform offers a convenient copy-and-paste function. Note: the Start Node and End Node cannot be copied.
(1) Partial Canvas Copy
Hold Shift and press-and-hold the left mouse button to select a section of the canvas. A pop-up at the top will display the number of selected nodes (e.g., "N nodes selected"). Click the Copy button on the right to copy them.
Use Ctrl+V to paste the copied nodes onto the canvas.
(2) Single Node Copy
Click a single node, then press Ctrl+C to copy it — a pop-up will confirm "Copy successful."
Use Ctrl+V to paste it onto the canvas.
# 2.2.3 Node Overview
Nodes are the fundamental building blocks of a workflow. By correctly connecting individual nodes, developers can form a workflow tailored to a specific business process — achieving the goal of efficient, flexible, and easily extensible AI application development. Workflow Agents support five categories of nodes:
- Basic Nodes: Nodes that perform fundamental tasks within a workflow, including the Start Node, End Node, LLM Node, Code Node, and Knowledge Base Node.
- Tool Nodes: Nodes that integrate general-purpose or complex tools to extend the agent's capabilities, including the Tool Node.
- Logic Nodes: Nodes that control the workflow's direction according to specific logic, including the Decision Node, Branch Node, and Iteration Node.
- Transform Nodes: Nodes used to store, convert, or concatenate variables within a workflow, including the Variable Storage Node, Variable Extractor Node, and Text Concatenation Node.
- Other: Primarily includes the Message Node, which controls the output of related information during workflow execution.
In addition to the two functions shown by default, each node's toolbar (in the top-right corner) also includes some hidden functions:
- Add Comment: This feature allows developers to add text annotations to any node in the workflow (such as design intent or node functionality), effectively giving the workflow the equivalent of "code comments." When multiple people collaborate on maintaining a complex workflow, reviewing node comments helps developers quickly understand the design background, purpose, and other key details of that node.
- Duplicate: Creates a copy of a node that is identical to the original in every way except its name, making it easier for developers to batch-create nodes with similar functionality.
To help developers handle exceptions such as errors and timeouts, an exception handling feature has been added to select nodes, including the LLM Node, Code Node, Knowledge Base Node, Knowledge Base Pro Node, Database Node, Workflow Node, Tool Node, Decision Node, Agent Intelligent Decision Node, and Variable Extractor Node. This allows developers to configure the timeout duration, retry count, and exception handling method. Exception handling can be enabled via the toggle on the right.
- Timeout Duration: Measured in seconds. If the server does not respond within the specified time, it will be treated as an exception.
- Retry Count: After a timeout occurs, developers can select the number of retry attempts from the dropdown menu on the right.
- Exception Handling Method: Includes Interrupt Process, Return Preset Content, and Execute Exception Flow, selectable from the dropdown menu on the right.
- Return Preset Content allows developers to configure a fallback response to be returned when an exception occurs.
- Execute Exception Flow allows the node to connect to other nodes, which will be executed in the event of an exception.
# 2.2.3.1 Start Node
- Node Overview
The Start Node is the first node in a workflow, marking the beginning of the entire process. This node is typically responsible for receiving user input or trigger conditions, which serve as the basis for subsequent nodes to process tasks.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | The Start Node includes a default input parameter — AGENT_USER_INPUT — which is specifically used to receive and store the raw content entered by the user in the current conversation turn. In addition, the Start Node also supports other input parameters. Developers can click the Add button to configure additional input parameters as needed. |
# 2.2.3.2 End Node
- Node Overview
The End Node serves as the final stage of a workflow and plays a critical role: it is responsible for returning the results once the workflow has finished executing.
- Parameter Description
| Parameter | Description |
|---|---|
| Reply Mode | Determines how the End Node displays results. Return Parameters Generated by the Workflow: This method allows the End Node to return variable values processed during workflow execution. Return a Reply in a Custom Format: Typically used to allow users to customize the format and content of the returned result, in order to meet specific requirements across different use cases. |
| Output | Configures the parameters used by the End Node to display results. Additional output parameters can be added via the Add button. |
| Reasoning Content | This field displays the reasoning content generated by the large language model, and supports referencing output parameters using the syntax. The content in this field is rendered and displayed as "reasoning" on the conversation page. |
| Reply Content | This field displays the final result of the workflow's execution, and supports referencing output parameters using the syntax. The content in this field is rendered and displayed as the final result on the conversation page. |
| Streaming Output Toggle | Controls how the final result is output: Streaming: The workflow outputs and displays intermediate frames of the result along with the final result. Non-Streaming: Only the final result is displayed; intermediate frames are not shown. |
# 2.2.3.3 LLM Node
- Node Overview
The LLM Node invokes a large language model to generate responses based on input parameters and prompts. It is typically used for text generation tasks such as copywriting, text summarization, and article expansion.
The LLM Node relies on the language understanding and generation capabilities of large language models to handle complex natural language processing tasks. You can select different models based on your business needs and configure prompts to define the model's persona and response style. To gain more precise control over the generated output, you can also configure model parameters within the LLM Node to influence factors such as response length and content diversity.
- Parameter Description
| Parameter | Description |
|---|---|
| Model Selection | Select an appropriate large language model from the available model library. Different models produce output of varying quality, so it's recommended to choose based on your specific needs and use case. |
| Max Reply Length | Configurable within model parameter settings. Function: Controls the maximum number of tokens in the model's output. Different models have different token limits, with a default of 2048 tokens. Setting this appropriately helps prevent output from being truncated due to excessive length. |
| Top-P (Nucleus Sampling) | Configurable within model parameter settings. Function: Determines the randomness of the output — a higher value increases randomness, meaning the same question is more likely to produce different answers. Value range: (0, 1]. |
| Generation Diversity | Configurable within model parameter settings. Function: Increasing this value makes the model's output more diverse and creative; decreasing it makes the output adhere more closely to instructions but reduces diversity. Minimum value: 1, maximum value: 6. |
| Web Search Toggle | Configurable within model parameter settings. Function: Enables or disables web search capability. Currently, certain models (e.g., DeepSeek-V3, DeepSeek-R1) support web search. When enabled, the model can retrieve and reference information from the web while generating responses. Disabled by default. |
| Input | Dynamic content to be added to the prompt. Both the system prompt and user prompt support referencing input parameters, enabling dynamic adjustments. When adding an input parameter, you need to set a parameter name and a variable value — the variable value can be set as a fixed value or reference the output parameter of an upstream node. |
| Conversation History | In multi-turn conversation scenarios, enabling Conversation History allows the agent to pass the user's most recent conversation records, along with the prompt, to the large language model — helping it understand the context and generate responses appropriate to the current conversation. |
| System Prompt | Instructions preset by the developer or administrator, used to define the model's role, behavioral rules, and output style. |
| User Prompt | Questions, tasks, or instructions entered directly by the user, used to express specific requirements. |
| Prompt Library | Allows you to select and import preset prompts with one click from the Prompt Library pop-up window. For details on creating and using the Prompt Library, please refer to the "Precision Prompt Engineering" section. |
| Output | Specifies the output parameters of the LLM. The model outputs its results through the configured output parameters. |
| Output Format | Specifies the output format of the LLM. Currently supports both text and JSON formats. |
# 2.2.3.4 Code Node
- Node Overview
The Code Node allows users to implement data or business logic processing by writing Python code blocks. Users can use an integrated development environment (IDE) tool to write code that processes input parameters and outputs the corresponding results. The tool supports AI-generated code as well as AI-assisted error correction.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | Configure the input parameters for the Code Node. These parameters can reference the outputs of other nodes or user input. Input parameters must match the formal parameters of the main function in the code. |
| Code | Write custom code logic in the code editor, or have the code automatically generated by AI to implement specific functions or processing logic. The code editor also provides a test run feature — simply use auto-generated or manually entered test input. |
| Output | Configure the output format and type for the Code Node. The output parameters must match the parameters returned by the return statement in the code, to ensure subsequent nodes can correctly receive and process them. |
- Notes
- If your Code Node throws an error containing "Non-UTF-8," add the following line at the beginning of your code:
# -*- coding: utf-8 -*- - Do not use the print function when writing code. Using print will cause the returned result to be incorrect.
- The final result of the main function must be returned in JSON format. The field names and types in the JSON must match the variables defined in the Code Node, otherwise the Code Node will throw an error.
- The Code Node supports writing multiple functions, but only the code within the main function will be executed. If you want to execute another function, it must be called from within the main function.
- If your Code Node throws an error containing "Non-UTF-8," add the following line at the beginning of your code:
The Code Node's specific logic is as follows:
# -*- coding: utf-8 -*-
import json
import re
def main(input):
name = ""
age = -1
# Use regex to remove line breaks and indentation spaces, while preserving spaces within objects
compressed_json_str = re.sub(r'\s+(?=[{,\]}])|\s+', '', input)
# Convert the input string into a dictionary
input_data = json.loads(compressed_json_str)
for item in input_data: # Iterate through the roster list
if "Li Si" in item["name"]: # Find the person named "Li Si"
name = item["name"] # Get the name of "Li Si"
age = item["age"] # Get the age of "Li Si"
ret = {
"name": name,
"age": age
}
return ret
# 2.2.3.5 Knowledge Base Node
- Node Overview
The Knowledge Base Node quickly retrieves relevant knowledge chunks from a specified knowledge base based on the user's input query, then efficiently returns this information to the user. It is primarily used in scenarios such as information storage and retrieval, improving response efficiency, optimizing workflows, and enhancing model performance.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | Fixed as Query, representing the key search terms the user wants to retrieve from the knowledge base. |
| Add Knowledge Base | Click + Add Knowledge Base in the top-right corner of the knowledge base section. On the pop-up page, select the knowledge base(s) you want to add and click Add to attach them to the node. The Knowledge Base Node supports adding multiple knowledge bases. If you click Create New Knowledge Base on the pop-up page, you'll be redirected to the knowledge base creation page. For details on creating a knowledge base, please refer to the "Development Guide – Resource Management – Knowledge Base Management" section. |
| Parameter Settings | Configure parameters related to knowledge base retrieval. Developers can combine Top K and the Score Threshold to filter and obtain the desired knowledge base results. Details are as follows: Top K: Filters the K text fragments with the highest degree of match to the user's question. The larger the value, the more entries returned. By default, 3 retrieval results are recalled. Score Threshold: Sets the matching-degree threshold. The system selects paragraphs scoring no lower than the configured threshold and returns them to the large language model. Matching degree refers to the relevance between the user's question and a given text fragment — a knowledge base consists of multiple knowledge fragments, each with its own relevance score. |
| Output | Fixed output result (Array<Object>), containing multiple recall results. |
The structure of each recall result is as follows:
{
"score": , // Relevance score
"docId": ,
"title": ,
"content": , // Content of the matched knowledge chunk
"chunkId": ,
"references": ,
"docInfo": ,
"fileName":
}
# 2.2.3.6 Q&A Node
- Node Overview
Some nodes in a workflow require the user to provide necessary information or clarify their intent before the workflow can proceed. To handle this, the platform provides a dedicated Q&A Node, which precisely collects key information from the user through natural-language questions or multiple-choice options, ensuring a smooth conversational experience. When the agent detects a workflow containing a Q&A Node during a conversation, it will automatically present the preset question to the user and pause the current process until the user provides the required input before continuing.
- Parameter Description
| Parameter | Description |
|---|---|
| Model Selection | Sets the large language model used to extract fields from the user's response. |
| Input | Configure parameters to be included in the question. Parameter values can reference the output of preceding nodes or be set as fixed text. |
| Question Content | Set the question to be presented to the user. You can reference input parameters using syntax. |
| Reply Mode | The user's reply mode — supports two modes: Direct Reply and Option Reply. |
| Output | The output of the Q&A Node. The output content varies depending on the mode: Direct Reply mode: In addition to the fixed parameters query (the question content) and content (the user's reply content), if field extraction is enabled, the defined field values will also be returned. Option Reply mode: Returns three fields — query (the question content), id (the option selected by the user), and content (the content of the option selected by the user). |
The Q&A Node supports two reply modes — Direct Reply and Option Reply — for collecting user information or intent. Each mode is explained below.
Direct Reply
In the Question Content field, specify an open-ended question. The user replies directly in natural language, and the agent extracts either the user's entire response or specific key fields from it. If the user's response doesn't match the information the agent expects to extract — for example, a required field is missing, or the field's data type doesn't match — the agent will proactively ask again until it obtains the key field(s), or until the maximum number of reply attempts is reached (default: 2).
Click the button to the right of Reply Mode to configure additional parameters for this mode.
| Parameter | Description |
|---|---|
| Require User Response | When this toggle is off, after the agent asks a question in the conversation window, an "Skip This Question" button will appear below it. Clicking this button allows the user to skip the question without answering. In this case, the field(s) to be extracted will be assigned the default value(s) set in Field Extraction, and execution will continue. When this toggle is on, the "Skip This Question" button will not appear, meaning the user is required to answer the question. |
| Conversation Timeout | If the user remains on the question screen longer than the preset time, the workflow will be terminated. Minimum: 2 minutes; maximum: 5 minutes. |
| Max Reply Attempts | The maximum number of times the user is allowed to answer this question. If the required key field(s) still cannot be extracted after multiple attempts, the workflow will be terminated. Minimum: 2 attempts; maximum: 5 attempts. |
After enabling Extract Fields from User Reply (located to the right of Output), the system can extract key fields from the user's reply based on custom variables and descriptions. This is disabled by default.
| Parameter | Description |
|---|---|
| Variable Name | The name of the keyword to be extracted. May only contain letters, numbers, or underscores, and must begin with a letter or underscore. |
| Variable Type | The data type of the keyword. Supported types can be viewed and selected from the dropdown menu. |
| Description | The prompt describing the keyword to be extracted — i.e., a description explaining the purpose of extracting this term. The LLM extracts the keyword from the user's reply based on this description; the more detailed the description, the more accurate the extraction. |
| Default Value | If the user chooses to skip the question and a default value has been configured, this default value will be assigned to the corresponding keyword for subsequent processing. |
| Required | Specifies whether the keyword is mandatory. If not required, and the corresponding keyword is not extracted during a given round of questioning, the default value will be used for subsequent processing. If required, and the keyword is not extracted during a round of questioning, the agent will continue asking until the keyword is extracted or the maximum number of rounds is reached. |
Option Reply
The Q&A Node allows developers to preset fixed options, letting users respond by selecting from these options. This mode is typically used in chat-style agents to advance the conversation and enhance interactivity.
Click the button to the right of Reply Mode to configure additional parameters for this mode.
| Parameter | Description |
|---|---|
| Require User Response | When this toggle is off, after the agent asks a question in the conversation window, an "Skip This Question" button will appear below it. Clicking this button causes the Q&A Node to follow the "Other" option branch and continue execution. When this toggle is on, the "Skip This Question" button will not appear, meaning the user is required to answer. |
| Conversation Timeout | If the user remains on the question screen longer than the preset time, the workflow will be terminated. Minimum: 2 minutes; maximum: 5 minutes. |
You can set the available user actions as selectable options, helping users respond quickly within a defined range, or use common intents as options to serve as reply prompts for the user. Each option typically corresponds to a different workflow branch. Replies that fall outside the provided options also need a corresponding branch — for example, prompting the user to choose again or executing a fallback process.
| Parameter | Description |
|---|---|
| Option | The option's ID, represented by an uppercase English letter. This cannot be changed to another value. |
| Option Type | The data type of the option content. Currently supports only string or image. If image is selected, the option content must be an external URL link to the image. |
| Option Content | The answer or intent the user is expected to select from. |
| Other | The "Other" option is not visible to the user. This branch is only triggered when the user selects "Skip This Question." In this case, the returned id is "default". |
# 2.2.3.7 Database Node
The Database Node is designed for organizing and managing structured data. By creating a custom database and inserting a Database Node into a workflow, you can perform create, read, update, and delete (CRUD) operations. This platform provides persistent storage for structured data — as long as the data is not deleted or modified by the user, it remains permanently valid and fully preserved. Through a strict data isolation mechanism, the platform ensures that different developers' data resources are stored and accessed independently, safeguarding user privacy and security. In addition, the platform offers free cloud storage, helping users save on storage costs.
- Prerequisites
Before using the Database Node, you must first create a database in the Resource Management section — otherwise, the database selection field will have no databases available to choose from. For detailed instructions on creating a database, please refer to the "Development Guide – Resource Management – Database Management" section.
- Node Overview
The Database Node connects to a specified database and performs common operations such as inserting, querying, editing, and deleting data, enabling dynamic data management. The Database Node supports two methods for managing data: Custom SQL and Form-Based Data Processing. Select Custom SQL to write custom SQL statements to perform operations. If you're not familiar with SQL, you can instead select Form-Based Data Processing, which lets you manage data by selecting a specific data table and processing mode.
- Parameter Description
Custom SQL
| Parameter | Description |
|---|---|
| Database Selection | Specify the database to operate on from the dropdown list. |
| Input | Configure the input parameters the Database Node needs to receive. These parameters may come from other nodes or from user input. |
| SQL | Write custom SQL statements in this section to perform specific operations on the database. Variables defined in the input parameters can be referenced within the SQL statement using syntax. When using a variable as an SQL condition, if the variable's content is a string, it must be enclosed in single quotes (e.g., ''). |
| Output | Fixed outputs isSuccess and message, indicating the execution status of the SQL statement (true for success, false for failure) and the reason for failure, respectively. outputList defaults to the execution result; additional output sub-items can be added by clicking the blue icon. The variable name of each sub-item must match the field name defined in the SQL statement, and its data type must match the data type defined in the data table. |
Form-Based Data Processing
| Parameter | Description |
|---|---|
| Select Data Table | Specify the data table to operate on from the dropdown list. |
| Processing Mode | Select the specific operation to perform on the table: Insert Data, Update Data, Query Data, or Delete Data. |
| Output | Fixed outputs isSuccess and message, indicating the execution status of the SQL statement (true for success, false for failure) and the reason for failure, respectively. outputList defaults to the execution result; additional output sub-items can be added by clicking the blue icon. The variable name of each sub-item must match the field name defined in the SQL statement, and its data type must match the data type defined in the data table. |
Parameter details for each processing mode:
- Insert Data: Inserts data into the specified data table. When configuring the data to insert, parameter values can be defined either by referencing the output parameter of an upstream node, or by entering a fixed value.
- Update Data: Updates existing data in the specified data table.
- Set Data Range: Configure filter conditions here to specify the range of data to be updated (supports conditions such as equals, not equals, greater than, greater than or equal to, less than, less than or equal to, and fuzzy match). Comparison values can be defined either by referencing the output parameter of an upstream node, or by entering a fixed value.
- Set Update Data: Specify the data fields to update and their new values.
- Query Data: Queries data in the specified data table.
- Set Data Range: Configure the query conditions for the query fields here (supports conditions such as equals, not equals, greater than, greater than or equal to, less than, less than or equal to, and fuzzy match). Comparison values can be defined either by referencing the output parameter of an upstream node, or by entering a fixed value.
- Set Result Fields: Specify the fields to be queried.
- Sort: Configure how the query results should be sorted; the system will sort the results according to the specified parameters.
- Query Limit: Limits the number of results returned.
- Delete Data: Deletes data from the specified data table. When setting the range of data to delete, the comparison values for the conditions can be defined either by referencing the output parameter of an upstream node, or by entering a fixed value.
# 2.2.3.8 Workflow Node
- Node Overview
The Workflow Node allows developers to quickly integrate a previously published workflow into the current workflow canvas, efficiently reusing existing capabilities. By nesting workflows, complex task designs can be broken down into modular components — each module being an independent Workflow Agent — enabling multi-agent collaboration and making workflow orchestration easier to manage.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | The input for the sub-workflow's Start Node. Supports both outputs from upstream nodes and fixed user input. The format must match the input format defined in the sub-workflow's Start Node. |
| Output | The output of the sub-workflow. Streaming output is not currently supported for sub-workflows. |
Note: The Workflow Node can only add workflows that have already been published. Unpublished workflows must be published before they can be added.
# 2.2.3.9 Tool Node
- Node Overview
The Tool Node integrates a wide range of general-purpose and complex plugins, allowing users to directly invoke the plugins they need to extend the agent's capabilities. Common plugins include aggregated search, text-to-image generation, and general-purpose OCR models. Custom plugins are also supported.
- Parameter Description
| Parameter | Description |
|---|---|
| Plugin Selection | Select the plugin(s) you need from the list of available plugins. |
| Input Parameters | Configure the input parameters the Tool Node needs to receive. These parameters may come from other nodes or from user input. |
| Output Parameters | The Tool Node's output parameters cannot be customized; they are used to receive the results of the plugin's execution. |
- Usage Example
Select the Tool Node from the node list, then click the "+" icon to be redirected to the plugin selection interface. On this page, official plugins are grouped under "Official Tools", while custom plugins are grouped under "Created by Me." Developers can browse and locate the plugin they need, then click the Add button on the right to import it into the workflow for use. Note: before adding a custom plugin, developers must first create it. For instructions on creating a custom plugin, please refer to "Development Guide – Resource Management – Custom Plugins."
# 2.2.3.10 Decision Node
- Node Overview
The Decision Node leverages the capabilities of a large language model, with its primary function being to analyze input information, identify and classify user intent, and determine the logical direction of the subsequent workflow. Users can preset multiple distinct agent usage scenarios, and by chaining Decision Nodes together, the workflow can deliver more precise, tailored services.
- Parameter Description
| Parameter | Description |
|---|---|
| Model Selection | Select the LLM to use for intent classification from the model library. |
| Input | Fixed as Query, receiving input information from the user or upstream nodes — this information is what will be analyzed for intent classification. Input supports enabling Conversation History (disabled by default), along with setting the number of conversation turns to include. The more turns included, the higher the contextual relevance in multi-turn conversations, but this also consumes more tokens. |
| Intent | Users can define multiple intents. The LLM will thoroughly analyze and interpret the user's intent, match it against the preset intent categories, and automatically route the process to the corresponding downstream node. In addition to user-defined intents, the system includes a fixed default intent category, which is triggered when the input doesn't match any of the preset intent categories. |
| Advanced Settings | Define additional system prompts to improve the success rate of matching user input to the correct intent. You can add further constraints or provide additional examples. Supports referencing variables using syntax. |
| Output | Once an intent is identified, the node outputs this information and passes it to downstream nodes or the system, so that the appropriate action or process can be executed based on the user's intent. |
# 2.2.3.11 Branch Node
- Node Overview
While the Decision Node uses natural language processing (NLP) to interpret user intent or needs, the Branch Node instead operates through conditional logic and branching mechanisms — functioning similarly to an if-else statement. Depending on whether the node's input parameters meet the specified conditions, the corresponding downstream branch is executed. Each branch condition supports flexibly adding multiple criteria, which can be combined using the logical operators AND and OR to construct more complex and refined logic. Multiple branch conditions can also be added, each with a different priority level.
# 2.2.3.12 Iteration Node
- Node Overview
The Iteration Node allows users to configure tasks or operations that repeat — similar to a for loop in programming languages. It iterates over a known array, executing the same set of steps for each element in the array. With each iteration, the workflow executes each node within the canvas in sequence.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | Only accepts data of the Array variable type. This variable can come from the output of an upstream node or be set as a fixed user input. |
| Iteration Sub-Nodes | You can use any node type within the sub-canvas (except the Iteration Node itself — nesting an Iteration Node within another Iteration Node is not supported) to orchestrate the tasks that need to be repeated. The sub-canvas contains only one Start Node and one End Node; nested loops are not supported. |
| Output | Only supports outputting array variables, and multiple array outputs are supported. Once the loop finishes executing, the results of all iterations are packaged together and output to downstream nodes. |
# 2.2.3.13 Intelligent Decision Node
- Node Overview
The Agent Intelligent Decision Node primarily relies on the reasoning strategy selected by the user to invoke the chosen large language model, performing reasoning and analysis on complex input questions. It also has intelligent tool-scheduling capabilities, dynamically selecting and invoking suitable external tools based on the model's reasoning results — forming a closed loop of "think + execute." In addition, the node supports supplementary prompts to refine role settings, optimize the reasoning path, and enhance query semantics, in order to improve overall reasoning accuracy.
- Parameter Description
| Parameter | Description |
|---|---|
| Model Selection | Select a suitable model from the available LLM library. It's recommended to prioritize models with intermediate reasoning capabilities (such as Spark X1 or DeepSeek R1) to support step-by-step reasoning for complex problems. If faster response times are needed during reasoning, high-performance models such as DeepSeek V3 can be used to reduce latency. |
| Input | Define the input content this node needs to receive. Parameters can come from the output of preceding nodes or from user input. |
| Agent Strategy Selection | Guides how the LLM reasons and makes decisions while executing a task. The default is ReACT (Reasoning and Acting) mode, enabling a closed-loop cycle of "think – execute – feedback." |
| Plugin Selection | Supports selecting and adding multiple tools at once from the list of published plugins. Click "Add Plugin" to choose from common plugins, MCP Server tools, and knowledge base resources. Up to 30 plugins can be added to enhance the agent's tool-calling capabilities. |
| Custom MCP Server Address | Allows users to add custom external MCP Server addresses as needed, extending the range of tools and services available. Up to 3 custom addresses can be configured. |
| Prompt Configuration | By supplementing three prompt sections — Role Setting, Reasoning Steps, and User Query — you can further refine the agent's role positioning, reasoning path, and query precision, improving the model's response quality and task fit. |
| Max Reasoning Rounds | Sets the maximum number of reasoning rounds the model can perform. It's recommended that this number be no less than the number of configured tools. The system currently supports a maximum of 100 rounds, with a default of 10. More reasoning rounds allow for deeper thinking, increasing the likelihood of a logically sound, well-structured final answer — it's recommended to increase this value when handling highly complex tasks. |
| Output Parameters | Outputs the LLM's reasoning process and final response content. |
Details on select parameters:
a. Selecting the Model and Agent Reasoning Strategy
When configuring the Agent Intelligent Decision Node, users must first select an appropriate model — i.e., choose an LLM from the available library that fits the current task — and set the corresponding reasoning strategy based on task complexity and tool-calling requirements, ensuring the agent has a clear reasoning path and execution capability.
The Agent reasoning strategy defaults to ReACT mode. ReACT (Reasoning and Acting) is an alternating "think + act" reasoning strategy that allows the model to think while answering a question, call external tools as needed, and continue reasoning based on the results until the task is complete. When running in ReACT mode, the model alternates through the following steps:
User Question → Model's First Reasoning Step → Determines Tool A Is Needed → Tool Returns Data → Model Reasons Again → Determines Tool B Is Needed → Reasons Again → Outputs Final Answer
b. Adding Plugins, MCP Tools, and Knowledge Bases
The Agent Intelligent Decision Node can extend its capabilities by adding tool plugins. Click the "Add Plugin" button to browse and select the plugins you need in the pop-up window. The platform supports three types of plugin integration:
- Common Plugins: Built-in capabilities such as aggregated search, general-purpose OCR models, and image understanding.
- MCP Server Tools: Supports invoking official tool services provided by the Astron Agent development platform via the MCP protocol — such as Amap (Gaode Maps) location queries, Bilibili video search, and structured data processing — as well as invoking self-built or externally connected MCP Server instances.
- Knowledge Base Resources: Serves as external knowledge support for the LLM, suitable for tasks that require referencing industry materials, internal documents, or domain-specific knowledge.
The system supports adding up to 30 plugins, and users can select multiple as needed. Click "Add" on the right to complete the tool integration.
In addition, if no suitable tool currently meets your business needs, you can also create your own custom plugins and knowledge bases to fulfill specialized task requirements. For instructions on creating these, please refer to "Development Guide – Resource Management – Knowledge Base Management."
c. Adding a Custom MCP Server Address
The platform allows users to add custom third-party MCP server addresses based on business needs, extending the range of capabilities the model can invoke during task execution. This configuration is optional and applies to the following typical scenarios:
- An enterprise or individual has already deployed their own MCP Server and wants to connect it to the Astron Agent development platform.
- Certain tool services exist only as private APIs/MCP services and need to be manually integrated.
- Users have specific requirements around response speed, security isolation, or custom service logic.
The system supports configuring up to 3 addresses. Click "Add Address" to manually enter the server's API address.
d. Configuring Prompts
Prompts provide the LLM with clearer context and behavioral guidance. Users can configure three prompt sections: Role Setting, Reasoning Steps, and User Query.
| Parameter | Description |
|---|---|
| Role Setting (optional) | Defines the role, style, or output format the LLM should adopt for this task. |
| Reasoning Steps (optional) | Guides the LLM's reasoning process, specifying how the model should break down the task step by step. The LLM will schedule its reasoning based on these prompts and the selected strategy. |
| User Query (required) | Supplements the user's instruction or question to improve the model's understanding and precision. You can reference parameter values by inserting , such as . |
Example input:
| Parameter | Example |
|---|---|
| Role Setting (optional) | You are a marketing copywriting expert, skilled at writing content in a light and humorous style. |
| Reasoning Steps (optional) | Prioritize using the "Aggregated Search" plugin. |
| User Query (required) | Based on , write a promotional article for Labor Day. |
# 2.2.3.14 Variable Storage Node
- Node Overview
The Variable Storage Node assigns variables from within the workflow to conversation variables for temporary storage, allowing them to be referenced in subsequent turns of the conversation. Variables are cleared when the conversation is deleted or a new conversation is started.
- Parameter Description
| Parameter | Description |
|---|---|
| Set Variable Value | Used to assign a value to a variable. |
| Get Variable Value | Used to read and use a stored variable. |
Note:
- A variable's value must be set using the Variable Storage Node before it can be retrieved in Get mode — otherwise, the variable will not appear as an available parameter in Get mode.
- A single Variable Storage Node can only perform one operation — either storing or retrieving. Therefore, storing and retrieving a variable requires two separate Variable Storage Nodes.
# 2.2.3.15 Variable Extractor
- Node Overview
The Variable Extractor leverages the capabilities of a large language model to extract key information fields from natural language, improving the agent's ability to handle complex tasks and enabling more flexible interactions.
- Parameter Description
| Parameter | Description |
|---|---|
| Model Selection | Select the LLM used to extract variables from the user's input. |
| Input | The input information to extract from. Supports receiving output from upstream nodes or fixed user input. |
| Output | Supports outputting multiple data types, and allows users to define multiple output items. Based on the specific description of each parameter, the LLM will precisely extract the target content from the input data and assign it according to the predefined data type and output item. |
# 2.2.3.16 Text Processing Node
- Node Overview
The Text Processing Node is a specific node type within a workflow that receives multiple text inputs from upstream nodes and processes them as strings according to preset rules or logic. The resulting processed string can serve as input for subsequent nodes, or be output directly to the end user. The Text Concatenation Node currently supports two functions: String Concatenation and String Splitting.
- Parameter Description
String Concatenation
| Parameter | Description |
|---|---|
| Input | The Text Concatenation Node can receive multiple text inputs from upstream nodes. These inputs can be strings, text variables, or text arrays, among other types. |
| Rule | Defines the concatenation rule — the node will concatenate the input text and referenced variables according to this rule. The rule supports referencing input variables using syntax. |
| Output | Outputs the concatenated result. |
String Splitting
| Parameter | Description |
|---|---|
| Input | The Text Concatenation Node can receive multiple text inputs from upstream nodes. In String Splitting mode, the input must be a string. |
| Delimiter | Choose a delimiter: space, comma, line break, etc. The node will split the input content using the specified delimiter. Custom delimiters are also supported. |
| Output | Outputs the split content as a string array. |
# 2.2.3.17 Message Node
- Node Overview
The Message Node is an output node used at intermediate stages of a workflow, outputting content to the user during execution based on the configured settings. Its main function is to ensure information is effectively communicated throughout the agent's process, improving the overall user experience.
- Parameter Description
| Parameter | Description |
|---|---|
| Input | Can receive parameter input from upstream nodes, used to configure the reply content. |
| Reply Content | Defines clear reply rules or a logical framework used to generate the response content. This can be a simple, clear text reply, a carefully formatted message, or a detailed response containing specific key information. |
# 2.2.4 Agent Debugging
# 2.2.4.1 Debugging
Agent debugging is a critical step in optimizing an agent's performance and ensuring stable operation. It helps users identify and fix logic errors, optimize response efficiency and resource allocation, and calibrate the interaction experience to meet user expectations — ensuring the agent runs smoothly and effectively.
On the canvas page, click the Debug button in the top-right corner, then enter test input in the pop-up page to debug the agent. Debugging supports editing and testing simultaneously, allowing you to quickly adjust the orchestrated agent and verify its performance — helping you build an agent that meets user expectations.
# 2.2.4.2 Issue Feedback
To address the difficulty of troubleshooting node errors during Workflow Agent debugging, the platform offers a one-click feedback feature. This feature helps developers obtain complete runtime logs and submit relevant error information to the platform, enabling the platform's engineering team to troubleshoot issues efficiently. The process is shown below:
After clicking Save, the information entered by the developer — along with the username, Bot ID, Flow ID, SID, start time, end time, duration, tokens consumed, status, and error code — will be saved to the backend for use by the platform's engineering team in troubleshooting.
# 2.2.4.3 Trace Log Analysis
During agent development, the call chain of workflow requests can become quite complex. The platform's Trace Log feature tracks and records the calling sequence between components, helping developers analyze system behavior, pinpoint issues, and optimize performance — transforming the process from a "black box model" into "transparent decision-making."
Developers can locate the corresponding workflow from the Publish Management list, click Details, and then switch to the Trace Log tab to view the Trace data reported by the specified application within a given time range.
In the Trace list, select a target record and click it to view the Trace details.
The Trace log fields are described below:
| Field | Description |
|---|---|
| status | The execution status of this workflow run — success or failure. |
| sid | The unique identifier for this request. |
| question | The user's question for this request. |
| answer | The workflow's execution result for this request. |
| duration | The execution time for this request. |
| start_time | The start time of this request. |
| end_time | The end time of this request. |
| question_tokens | The number of tokens in the user's question for this request. |
| prompt_tokens | The number of tokens in the prompt for this request. |
| total_tokens | The total number of tokens consumed by this request. |
To help developers quickly view the Trace data they need during debugging, the platform provides a Column Management feature, making it easy to filter for the desired information. The process is as follows:
Click the Column Management button in the top-right corner of the Trace list, then check the desired dimensions in the dropdown menu that appears.
# 2.2.5 Agent Publishing
Once an agent has been created, developers can locate it from the Publish Management menu and click Publish.
Note: To publish as an API, you must configure it in advance. Click the Configure button to enter the agent's API configuration page.
# 2.3 Development of Interactive Digital Human Agents
# 2.3.1 Function Overview
Building on Workflow Agents, the Interactive Digital Human Agent breaks through the limitations of traditional text-based interaction, enabling real-time voice interaction and multimodal, avatar-driven scenarios. It supports multiple interaction modes, including traditional text chat, avatar broadcast, avatar call, and voice call.
The Interactive Digital Human Agent supports a wide range of use cases:
- Companionship
With the Interactive Digital Human Agent, users can build a virtual companion simply by selecting an existing character — no additional nodes required. The digital human supports not only traditional text conversation but also natural voice calls with the user, automatically generating context-appropriate facial expressions throughout the interaction. For example, you could build a travel companion assistant that provides travel planning, route navigation, and weather updates from anywhere, while also engaging in free-flowing voice conversation.
- Intelligent Customer Service
The Interactive Digital Human Agent upgrades traditional customer service into a visual, avatar-based experience. This gives users a more "face-to-face" communication experience when interacting with the digital human, improving the intuitiveness and responsiveness of the service. For example, an e-commerce platform could deploy a virtual shopping advisor for voice-based consultation or real-time voice calls, giving customers a more human-centered service experience.
- Education and Training
The Interactive Digital Human Agent can be used to create expressive virtual instructors for educational applications. For instance, a history course could use the voice of a historical figure to narrate lessons, making learning more engaging; language learning courses could likewise feature a virtual foreign-language teacher, creating a more natural language-learning environment.
# 2.3.2 Agent Creation
After entering the homepage of the Astron Agent development platform, click the Create button on the left. In the pop-up dialog, select Interactive Digital Human Creation.
# 2.3.2.1 Basic Configuration
After selecting this option, the Basic Configuration dialog will appear. Basic configuration for Voice/Digital Human creation includes two mandatory sections: Basic Information and Voice & Appearance.
Basic Information includes the name, category, and description. Click the logo icon to the left of the name field to change the agent's logo — you can either upload one locally or generate one with AI. The description can be written manually, or generated in detail by AI based on a few keywords.
The Voice & Appearance section allows developers to configure the digital human's appearance and voice for avatar broadcasts or avatar calls.
Steps for creating a custom voice:
- Select Character Voice, then go to Basic Voices.
- Click Create Voice to create a voice from a single spoken sentence. First select a gender, then click Start Recording.
- In the pop-up dialog, click Start Recording, read the provided text aloud in full, and then click Stop Recording.
- Once processing is complete, a voice persona based on your own voice will be generated.
After completing both Basic Information and Voice & Appearance, click Confirm to finish the basic configuration.
After entering the workflow canvas, you can still modify the basic configuration at any time by clicking the Avatar Settings button in the top-left corner.
# 2.3.2.2 Advanced Settings
After creating the workflow, click the Advanced Settings button in the top-right corner to access advanced configuration.
Advanced Settings define capabilities beyond basic role-based conversation, including Conversation Opening, Next Question Suggestions, Role Voice, and Background Settings. These settings help improve the agent's usability and conversational performance.
# 2.3.2.3 Workflow Orchestration
The system automatically creates a Start Node and an End Node. Developers only need to modify the relevant code or node logic according to their needs to build a complete workflow. The platform currently offers a rich set of nodes, including LLM, Code, Decision, and Knowledge Base nodes. For detailed node descriptions, see Section 2.2.3, "Node Overview."
# 2.3.2.4 Version History
Click the Version History button on the workflow canvas to view previous versions in the pop-up page. Users can switch between historical versions as needed.
# 2.3.3 Agent Debugging
# 2.3.3.1 Debugging
Agent debugging is a critical step in optimizing an agent's performance and ensuring stable operation. It helps users identify and fix logic errors, optimize response efficiency and resource allocation, and calibrate the interaction experience to meet user expectations — ensuring the agent runs smoothly and effectively. On the canvas page, click the Debug button in the top-right corner, then enter test input in the pop-up page to debug the agent. Debugging supports editing and testing simultaneously, allowing you to quickly adjust the orchestrated agent and verify its performance — helping you build an agent that meets user expectations.
For Voice/Digital Human Agents, you can switch between Voice Call, Avatar Call, Text Chat, and Voice Broadcast in the top-right corner to test multimodal performance.
# 2.3.3.2 Issue Feedback
To address the difficulty of troubleshooting node errors during Voice/Digital Human Agent debugging, the platform offers a one-click feedback feature. This feature helps developers obtain complete runtime logs and submit relevant error information to the platform, enabling the platform's engineering team to troubleshoot issues efficiently.
# 2.3.4 Agent Publishing
Once a Voice/Digital Human Agent has been created, developers can locate it from the Publish Management menu and click Publish to make it available.
# 3. Technical Practice Cases
# 3.1 Prompt Best Practices
# 3.1.1 Opening Formula (Define Role + State Problem + Set Goal + Supplement Requirements)
You are a time management trainer [Define Role]. I want to learn about time management [State Problem]. I want you to output a PPT outline about time management [Set Goal]. The format is to output code marked in Markdown language [Supplement Requirements].
# 3.1.2 Few-Shot Prompting
Sometimes it may not be easy to describe a Prompt clearly, and providing examples will make it easier.
For example: We ask the model to act as a text classifier to perform binary classification on user reviews, with classification results being: Positive Review or Negative Review.
Please help me distinguish whether the category of the user input text is a positive review or a negative review according to the following classification method, and please output directly: Positive Review / Negative Review.
Please refer to the following samples:
Sample 1:
User Input: I went to this restaurant last night, and their food and service were amazing. I will definitely come again.
Output: Positive Review
Sample 2:
User Input: This mobile phone has an ultra-long battery life and great camera effects, very satisfied!
Output: Positive Review
Sample 3:
User Input: The courier was delayed for a week, and the packaging was damaged, the experience was extremely poor.
Output: Negative Review
Sample 4:
User Input: The movie has a wonderful plot and the actors' acting is on point, highly recommended!
Output: Positive Review
Sample 5:
User Input: The product quality is terrible, it broke after one use, and the customer service ignored me.
Output: Negative Review
Please answer the following question:
User Input: I dined at this western restaurant last month, it was okay, but not particularly amazing.
Output:
# 3.1.3 CoT (Chain of Thought)
CoT (Chain of Thought) is a thinking tool that helps people conduct deeper thinking and draw more complex and comprehensive conclusions by gradually extending and expanding an idea.
Core Concepts:
- The core idea of CoT is to guide the model to show its step-by-step reasoning process before generating the final answer.
- It imitates the way humans solve complex problems: instead of jumping directly to conclusions, it derives answers through a series of intermediate, interpretable logical steps ("chains").
- These steps usually include: understanding the problem, decomposing the problem, invoking relevant knowledge, performing logical operations or reasoning, integrating information, and drawing conclusions.
# 3.1.3.1 Zero-Shot
Add Let's think step by step or Let's analyze and think step by step to the prompt.
# 3.1.3.2 Few-Shots
Provide several examples with detailed reasoning steps in the Prompt. These examples show the complete process of "Question -> Step-by-Step Reasoning -> Final Answer". By observing these examples, the model learns to generate a similar reasoning chain when answering new questions. This is the most commonly used method and usually has better effects.
Please solve the following math problems. I will first give several examples and their detailed problem-solving ideas, then ask you to solve the final problem.
Example 1:
Question: Xiao Ming has 15 apples. He ate 3 of them, then bought 2 bags of apples, with 4 apples in each bag. How many apples does he have now in total?
Reasoning Steps:
1. Initial number of apples: 15.
2. Remaining after eating 3: 15 - 3 = 12.
3. Bought 2 bags, 4 apples each: 2 * 4 = 8.
4. Total number of apples now: remaining apples + newly bought apples = 12 + 8 = 20.
Answer: 20
Example 2:
Question: A swimming pool is 25 meters long, 10 meters wide, and 2 meters deep. If 5 cubic meters of water can be injected per minute, how many minutes does it take to fill the swimming pool?
Reasoning Steps:
1. Calculate the volume of the swimming pool: length * width * depth = 25 meters * 10 meters * 2 meters = 500 cubic meters.
2. Known water injection speed per minute: 5 cubic meters/minute.
3. Required time = total volume / water injection speed = 500 cubic meters / 5 cubic meters/minute = 100 minutes.
Answer: 100
Now, please solve this problem:
Question: A bookstore holds a promotion, all books are sold at a 20% discount. Xiao Li bought a book with an original price of 50 yuan and another book with an original price of 30 yuan. How much did she actually pay?
Reasoning Steps:
If you are interested in Prompt and want to learn more about Prompt knowledge, you can also learn from the following learning websites by yourself.
| Name | Website |
|---|---|
| Selected Chinese Prompts | https://github.com/langgptai/wonderful-prompts (opens new window) |
| Popular Website System Prompts | https://github.com/jujumilk3/leaked-system-prompts (opens new window) |
| Theoretical Learning - Prompt Engineering Guide | https://www.promptingguide.ai/zh (opens new window) |
| Prompt Engineering Guide | https://learnprompting.org/zh-Hans/docs/introduction (opens new window) |
# 3.2 Development Practice of Photo-Based Q&A Agent
# 3.2.1 Case Introduction
With the continuous breakthroughs in large models and multimodal fusion technologies, the unified understanding and content generation of heterogeneous data such as text and images have been widely applied. AI applications such as photo-based Q&A and photo-based product searching have brought convenience to people.
This case mainly implements the photo-based Q&A function. When users encounter various unsolved problems in mathematics, English, etc., they only need to take a photo and upload it to the agent to get an accurate answer. This article will detail how to implement a multimodal agent application with photo-based Q&A function step by step.
# 3.2.2 Implementation Process
A complete agent product generally goes through four steps from development to application: creation, orchestration, debugging, and release, among which agent orchestration is the core of agent design and implementation.
The key points to realize the photo-based Q&A function lie in the recognition of image content and the generation of reasoning results by the large model. The overall design process of the workflow is as follows:
The specific implementation process will be explained step by step below.
# Step 1: Create a Workflow Agent
Click to enter the homepage of Xingchen Agent Development Platform (opens new window), click [My Agents] in the left navigation bar to enter the My Agents list page, click [New Agent] - [Create by Workflow] - [Custom Creation] to enter the agent canvas page. The agent canvas page has two mandatory nodes: Start and End by default.
# Step 2: Configure Support for Image Input
Click [+ Add] at the bottom left of the Start node to add an input variable, set the variable name to "image", and subsequent nodes will reference the network address of the image uploaded by the user through this variable name. Select "Image" as the variable type.
# Step 3: Implementation of Image-Text Recognition
The official provides a general OCR large model tool to support image and PDF recognition, which can be referenced through tool nodes. The operation process is as follows:
Click the [+] sign in the upper right corner of the [Tool] node in the node list on the left side of the canvas to enter the tool selection page, search and find the [General OCR Large Model] tool from the official tools, click the [Add] button on the right side of the tool to add the tool to the canvas, and click to return to the canvas page.
Connect the Start node and the General OCR Large Model node, and configure the input parameters of the General OCR Large Model node. The General OCR Large Model has three parameters:
| Parameter Name | Type | Parameter Description | Required |
|---|---|---|---|
| file_url | string | The address of the ocr file to be recognized. Currently supports images and PDFs | Yes |
| ocr_document_page_start | integer | For document data, specify the starting page range for recognition, starting from 0, -1 means no limit | No |
| ocr_document_page_end | integer | For document data, specify the ending page range for recognition, starting from 0, -1 means no limit | No |
For the input parameter "file_url", select to reference Start/image. For image data, ocr_document_page_start and ocr_document_page_end can be left blank by default.
# Step 4: Large Model Reasoning to Generate Answers
Connect a large model node after the General OCR Large Model node to reason and generate answers.
Configure two variables for the large model input parameters: input and image_content:
- input: Reference the text information input by the user (Start/AGENT_USER_INPUT)
- image_content: Reference the image OCR result (General OCR Large Model_1/data.content)
Select the model: Spark X1 for the answer mode;
The large model prompt configuration is as follows:
//System Prompt:
You are a teacher of all disciplines, please answer students' questions as required.
//User Prompt:
The picture of the question input by the user, after OCR, the result is: {{image_content}}. Please combine the user's requirements: {{input}}, and answer the question in a standard way that students can understand, and answer it standardizedly.
The large model node has 2 output variables:
REASONING_CONTENT: The thinking process of the large model;
output: The answer generated by the large model.
# Step 5: Output Configuration
Connect the large model node to the output node, and configure the End node as follows:
- Answer Mode: By default, it is sufficient to return the answer configured in the set format.
- Output definition references 2 variables:
- output: Reference the large model output result (Large Model_1/output)
- reasoning: Reference the thinking process of the large model (Large Model_1/REASONING_CONTENT)
- Reference variable in thinking content: {{
reasoning}} - Turn on streaming output for answer content, and reference variable for result: {{
output}}
So far, the orchestration of the workflow is completed.
# Step 6: Debug the Workflow
Click the [Debug] button in the upper right corner to enter the debugging page, enter the description and the picture of the question, and click Send to test the result.
# Step 7: Release the Agent
After debugging the workflow effect and configuring the workflow name, description and other information. After the information is completed, click the release button in the upper right corner to select release.
# 4. API Integration
Calling the API requires the following processes:
# 4.1 Preparation
The workflow agent must be published as an API before it can be called via the API. The specific publishing process is as follows:
# 4.1.1 Publish Workflow as API
After completing the development and debugging of the workflow, click the publish button in the upper right corner of the workflow canvas page to publish it.
In the pop-up page, click the "Configure" button on the right side of the "Publish as API" column to jump to the configuration page for publishing as an API.
# 4.1.2 Real-Name Authentication
Real-name authentication is required before publishing a workflow as an API. If you have not completed real-name authentication before, you can find the "Go to Authenticate" button in the "Complete Real-Name Authentication" column on the page and click it to jump to the user authentication center page, where developers can complete real-name authentication as prompted. If you have successfully completed real-name authentication before, you can skip this step.
# 4.1.3 Create Application
If you have not created an application before, or expect to bind this workflow to a new application, you need to create a new application through this step. If you have created an application and want to bind this workflow to an existing application, you can skip this step.
Step 1: When you want to create a new application, find the "Create Now" button in the "Bind Application" column and click it to jump to the application creation page.
Step 2: Fill in the relevant information of the application on the creation page and click the "Submit" button to complete the creation.
# 4.1.4 Bind Application
Return to the API publishing configuration page, find the "Service Interface Authentication Information" tab, and complete the binding of the workflow and the application in this tab. The specific steps are as follows:
Step 1: Click the drop-down box of "Select the application you want to bind", and all application names under the current account will be displayed. Select the application you need to bind from them.
Notes:
- If the newly created application name is not found in the drop-down box, refresh the configuration page.
- Once the application is bound, it cannot be modified. Please choose carefully.
Step 2: After selecting the application, click the "Bind Now" button to complete the application binding. At this time, the interface information required for calling the API, including APIKey, API Secret, and API Flowid, will be displayed.
Note: If there are new changes to your workflow, please click the "Update Binding" button to republish it as an API before calling the API, so that the new changes will take effect in the API call.
# 4.2 Workflow API Integration
# 4.2.1 Basic Information
# 4.2.1.1 Interface Description
| Request Method | POST |
|---|---|
| Request URL | https://agent-sg-ali.xf-yun.com/workflow/v1/chat/completions (opens new window) |
# 4.2.1.2 Interface Demo
# 4.2.1.3 Interface Requirements
Interface Type: Streaming HTTP(S)
Interface Authentication: Click here to view the document (opens new window)
# 4.2.1.4 Interface Permission Description
If authentication fails or the APPID does not match the current workflow, relevant flow control errors will be returned.
# 4.2.2 Initiate Session Request
# 4.2.2.1 Request Protocol Example
{
"flow_id": "7265177322515169282",
"uid": "123",
"parameters": {
"AGENT_USER_INPUT": "Hello"
},
"ext": {
"bot_id": "workflow",
"caller": "workflow"
},
"stream": true,
"chat_id": "xxx",
"history": [
{
"role": "user",
"content_type": "text",
"content": "Hello"
},
{
"role": "assistant",
"content_type": "text",
"content": "Hello, I am your workflow assistant. How can I help you?"
}
]
}
# 4.2.2.2 Request Parameters
# 4.2.2.2.1 Header
| Parameter Name | Parameter Value | Required | Description |
|---|---|---|---|
| Authorization | Bearer $API_KEY | Yes | Authentication key. Composition of authentication code: Bearer {API_KEY}:{API_SECRET} |
# 4.2.2.2.2 Body
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| flow_id | string | Yes | Workflow ID |
| uid | string | No | User ID |
| stream | bool | Yes | Whether to enable streaming return. Streaming: true; Non-streaming: false |
| ext | object | No | Used to specify some additional fields, such as some hidden plugin fields (not used for now) |
| parameters | object | Yes | Input parameters and their values of the workflow start node. You can view the parameter list on the orchestration page of the specified workflow. {"input1": "xxxxx", "input2": "xxxxx"} |
| chat_id | string | No | Session ID, used to distinguish different workflow sessions, with a maximum length of 32 characters |
| history | array of history_message object | No | Collection of historical conversation information [history_message object]. For example: [{"role": "user", "content_type": "text", "content": "Hello" },{"role": "assistant", "content_type": "text", "content": "Hello, I am your workflow assistant. How can I help you?" }] |
# 4.2.2.2.3 history_message Object**
| Parameter Name | Parameter Type | Required | Value Range | Default Value | Description |
|---|---|---|---|---|---|
| role | string | Yes | user, assistant | The entity that sent this message. user: indicates the message is sent by the user. assistant: indicates the message is a reply from the workflow. | |
| content_type | string | No | text, image | text | The type of message content, currently only two types are supported. If not filled in, the default type is text. text: indicates plain text. image: indicates image type. |
| content | string | Yes | Message content. If it is an image type, the image URL needs to be filled in here |
When processing the history_message object, the role of the first element must be user. The interaction history should be spliced in the order of user -> assistant -> user -> assistant. By default, a pair of interactions between user and assistant is regarded as one round of conversation. Fill in in the order of conversation time from first to last. For example: [{first time},{second time}...]
[
// Splice conversation history information:
{"role": "user", "content_type" : "text", "content": "What are the famous foods in Hunan?"}, // User's first question. role is user, indicating it is the user's question
{"role": "assistant", "content_type" : "text", "content": "Hunan has xxxxxxx"}, // AI's first reply. role is assistant, indicating it is the AI's reply
]
# 4.2.3 Response
# 4.2.3.1 Response Protocol Example
# 4.2.3.1.1 Streaming Result Example**
Streaming Output Process Frame
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": null
}
]
}
Streaming Output End Frame
{
"code": 0,
"message": "Success",
"id": "spf0016609f@dx193193f43cba44d782",
"created": 123412324431,
"workflow_step": {
"seq": 6,
"progress": 1
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "",
"reasoning_content": ""
},
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 0,
"total_tokens": 9
}
}
# 4.2.3.1.2 Non-Streaming Result Example**
{
"code": 0,
"message": "Success",
"id": "cha000b0003@dx1905cd86d6bb86d552",
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello, I am the Spark Cognitive Intelligence Model built by iFLYTEK.\nIf you have any questions or need help, please feel free to tell me! I will do my best to provide you with answers and support. How can I help you?",
"reasoning_content": ""
},
"index": 0,
"finish_reason": "stop",
"finish_reason": ""
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 42,
"total_tokens": 48
}
}
# 4.2.3.1.3 Interrupt Event**
When there is a Q&A node in the workflow, the workflow will be interrupted.
Q&A Node Interrupt Frame (Direct Answer)
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": "interrupt"
}
],
"event_data": {
"event_id": "7336690112690499584",
"event_type": "interrupt",
"need_reply": true,
"value": {
"type": "direct",
"content": "Which of the following packages do you want to purchase?"
}
}
}
Q&A Node Interrupt Frame (Option Answer)
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": null
}
],
"event_data": {
"event_id": "7336690112690499584",
"event_type": "interrupt",
"need_reply": false,
"value": {
"type": "option",
"content": "Please select your package",
"option": [
{
"id": "A",
"text": "Annual Package"
},
{
"id": "B",
"text": "Monthly Package"
}
]
}
}
}
# 4.2.3.1.4 Exception Result**
{
"code": 20805,
"message": "flow id : 7265177322515169282 is in draft status, please publish",
"id": "spf00dc0001@hf193621572a96806782",
"created": 1732517393,
"choices": [
{
"delta": {
"role": "assistant",
"content": "",
"reasoning_content": ""
},
"finish_reason": "stop"
}
],
"workflow_step": {
"seq": 0,
"progress": 1.0
},
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
# 4.2.3.2 Response Parameters
# 4.2.3.2.1 Response Data Parameters**
| Parameter Name | Type | Required | Parameter Description |
|---|---|---|---|
| code | int | Yes | Error code, 0 for success, non-0 indicates an error |
| message | string | Yes | Error message description |
| id | string | Yes | Server session ID |
| created | int | Yes | Conversation creation timestamp, unit: seconds |
| workflow_step | object | Yes | Workflow step |
| workflow_step.seq | int | Yes | Sequence number of the returned data, value range [0,9999999] |
| workflow_step.progress | float | Yes | Workflow progress |
| choices | array | Yes | |
| choices.delta | object | Yes | |
| choices.delta.role | string | Yes | Role of the workflow |
| choices.delta.content | string | Yes | Content output by the workflow |
| choices.delta.reasoning_content | string | Yes | Reasoning chain content of the workflow |
| choices.index | int | Yes | Result sequence number of the workflow, used in multiple candidates |
| choices.finish_reason | string | Yes | Indicates the reason for the termination of workflow generation, which is an enumeration value. - stop: Normal end. The workflow is executed and terminated normally. For specific results or error reasons, refer to the code field.- interrupt: Execution interrupted. The workflow is interrupted at an intermediate node, and subsequent processing is required according to the event_data event data.- ping: Heartbeat signal. A signal sent by the workflow to maintain the connection when executing long tasks, which does not mean the execution is over. |
| usage | object | No | Token metering, only provided in the workflow end frame |
| usage.prompt_tokens | int | Yes | Tokens requested by the workflow from the large model |
| usage.completion_tokens | int | Yes | Replies from the large model in the workflow |
| usage.total_tokens | int | Yes | Total token consumption of the workflow |
| event_data | object | No | Event data |
| event_data.event_id | str | Yes | Event ID, used as a marker for the resume interface to resume the event |
| event_data.event_type | str | Yes | Event type, "interrupt" when interrupted |
| event_data.need_reply | bool | Yes | Whether the Q&A node requires a reply |
| event_data.value | object | Yes | Details of interrupted data |
| event_data.value.type | str | Yes | Question type, enumeration values: - direct: Direct answer - option: Option answer |
| event_data.value.content | str | Yes | User's question content |
| event_data.value.option | array | No | Option content for option answers |
# 4.2.3.2.2 Supplementary Instructions on Result Format**
In addition to plain text type, the model results will include the following markup languages to meet typesetting requirements, and it is recommended that integrators adapt to them:
- markdown (tables, lists, etc.)
# 4.2.4 Resume Workflow Execution
When your workflow executes to a Q&A node, the workflow will be temporarily interrupted and return the corresponding event ID and the question set in the workflow. At this time, developers should call this interface to upload the user's reply, event ID and other information to resume the execution of the workflow.
# 4.2.4.1 Basic Information
# 4.2.4.1.1 Interface Description**
| Request Method | POST |
|---|---|
| Request URL | https://agent-sg-ali.xf-yun.com/workflow/v1/resume (opens new window) |
# 4.2.4.1.2 Interface Demo**
| Demo Type | Download Address |
|---|---|
| Python Demo | https://astron-oss-s.oss-ap-southeast-1.aliyuncs.com/code/workflow_open_api_resume.py.zip (opens new window) |
# 4.2.4.1.3 Interface Requirements**
Interface Type: Streaming HTTP(S)
# 4.2.4.2 Request
# 4.2.4.2.1 Request Protocol Example**
{
"event_id": "123456789012345",
"event_type": "resume",
"content": "My name is:xxxx, Age:xxxx"
}
# 4.2.4.2.2 Request Parameters**
- Header
| Parameter Name | Parameter Value | Required | Description |
|---|---|---|---|
| Authorization | Bearer $API_KEY | Yes | Authentication key. Composition of authentication code: Bearer {API_KEY}:{API_SECRET} |
- Body
| Parameter Name | Parameter Type | Required | Description |
|---|---|---|---|
| event_id | string | Yes | Event ID. Returned by the chat and resume interfaces when an interrupt event occurs, used to identify multiple events generated by one request in the same workflow, with the same value. |
| event_type | string | No | Used to process events, default to resume. resume: Resume; ignore: Ignore; abort: End |
| content | string | Yes | Answer content. For option answers, only pass option information A-Z |
# 4.2.4.3 Response
# 4.2.4.3.1 Response Protocol Example**
- Streaming Result Example
Streaming Output Process Frame
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": null
}
]
}
Streaming Output End Frame
{
"code": 0,
"message": "Success",
"id": "spf0016609f@dx193193f43cba44d782",
"created": 123412324431,
"workflow_step": {
"seq": 6,
"progress": 1
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "",
"reasoning_content": ""
},
"index": 0,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 1,
"completion_tokens": 0,
"total_tokens": 9
}
}
- Non-Streaming Result Example
{
"code": 0,
"message": "Success",
"id": "cha000b0003@dx1905cd86d6bb86d552",
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello, I am the Spark Cognitive Intelligence Model built by iFLYTEK.\nIf you have any questions or need help, please feel free to tell me! I will do my best to provide you with answers and support. How can I help you?",
"reasoning_content": ""
},
"index": 0,
"finish_reason": "stop",
"finish_reason": ""
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 42,
"total_tokens": 48
}
}
- Interrupt Event
When there is a Q&A node in the workflow, the workflow will be interrupted.
Q&A Node Interrupt Frame (Direct Answer)
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": null
}
],
"event_data": {
"event_id": "7336690112690499584",
"event_type": "interrupt",
"need_reply": true,
"value": {
"type": "direct",
"content": "Which of the following packages do you want to purchase?"
}
}
}
Q&A Node Interrupt Frame (Option Answer)
{
"code": 0,
"message": "Success",
"id": "cha000c0076@dx191c21ce879b8f3532",
"created": 123412324431,
"workflow_step": {
"seq": 0,
"progress": 0.4
},
"choices": [
{
"delta": {
"role": "assistant",
"content": "Hello,",
"reasoning_content": ""
},
"index": 0,
"finish_reason": null
}
],
"event_data": {
"event_id": "7336690112690499584",
"event_type": "interrupt",
"need_reply": false,
"value": {
"type": "option",
"content": "Please select your package",
"option": [
{
"id": "A",
"text": "Annual Package"
},
{
"id": "B",
"text": "Monthly Package"
}
]
}
}
}
- Exception Result
{
"code": 20805,
"message": "flow id : 7265177322515169282 is in draft status, please publish",
"id": "spf00dc0001@hf193621572a96806782",
"created": 1732517393,
"choices": [
{
"delta": {
"role": "assistant",
"content": "",
"reasoning_content": ""
},
"finish_reason": "stop"
}
],
"workflow_step": {
"seq": 0,
"progress": 1.0
},
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
# 4.2.4.3.2 Response Parameter Description**
- Response Data Parameters
| Parameter Name | Type | Required | Parameter Description |
|---|---|---|---|
| code | int | Yes | Error code, 0 for success, non-0 indicates an error |
| message | string | Yes | Error message description |
| id | string | Yes | Server session ID |
| created | int | Yes | Conversation creation timestamp, unit: seconds |
| workflow_step | object | Yes | Workflow step |
| workflow_step.seq | int | Yes | Sequence number of the returned data, value range [0,9999999] |
| workflow_step.progress | float | Yes | Workflow progress |
| choices | array | Yes | |
| choices.delta | object | Yes | |
| choices.delta.role | string | Yes | Role of the workflow |
| choices.delta.content | string | Yes | Content output by the workflow |
| choices.delta.reasoning_content | string | Yes | Reasoning chain content of the workflow |
| choices.index | int | Yes | Result sequence number of the workflow, used in multiple candidates |
| choices.finish_reason | string | Yes | When the workflow reaches a natural stopping point or a stop sequence provided by the user, it will set finish_reason to "stop" |
| usage | object | No | Token metering, only provided in the workflow end frame |
| usage.prompt_tokens | int | Yes | Tokens requested by the workflow from the large model |
| usage.completion_tokens | int | Yes | Replies from the large model in the workflow |
| usage.total_tokens | int | Yes | Total token consumption of the workflow |
| event_data | object | No | Event data |
| event_data.event_id | str | Yes | Event ID, used as a marker for the resume interface to resume the event |
| event_data.event_type | str | Yes | Event type, "interrupt" when interrupted |
| event_data.need_reply | bool | Yes | Whether the Q&A node requires a reply |
| event_data.value | object | Yes | Details of interrupted data |
| event_data.value.type | str | Yes | Question type, enumeration values: - direct: Direct answer - option: Option answer |
| event_data.value.content | str | Yes | User's question content |
| event_data.value.option | array | No | Option content for option answers |
- Supplementary Instructions on Result Format
In addition to plain text type, the model results will include the following markup languages to meet typesetting requirements, and it is recommended that integrators adapt to them:
- markdown (tables, lists, etc.)
# 4.2.5 File Upload
# 4.2.5.1 Basic Information
# 4.2.5.1.1 Interface Description**
| Request Method | POST |
|---|---|
| Request URL | https://agent-sg-ali.xf-yun.com/workflow/v1/upload_file (opens new window) |
# 4.2.5.1.2 Interface Demo**
curl -X POST 'https://agent-sg-ali.xf-yun.com/workflow/v1/upload_file' \
--header 'Authorization: Bearer {api_key}' \
--form 'file=@localfile;type=image/[png|jpeg|jpg|webp|gif]
# 4.2.5.1.3 Interface Requirements**
Interface Type: Streaming HTTP(S)
Interface Authentication: Bearer Authentication
# 4.2.5.2 Request Parameters
# 4.2.5.2.1 Header**
| Parameter Name | Type | Required | Parameter Description |
|---|---|---|---|
| Authorization | string | Yes | Authentication key. Composition of authentication code: Bearer {API_KEY}:{API_SECRET} |
| Content-Type | string | Yes | multipart/form-data |
# 4.2.5.2.2 Body**
| Parameter Name | Type | Required | Parameter Description |
|---|---|---|---|
| file | file | Yes | File to be uploaded |
# 4.2.5.3 Response
# 4.2.5.3.1 Response Protocol Example**
{
"code": 0,
"message": "success",
"sid": "spf001b23c7@dx1939b17d9e3a4f3700",
"data": {
"url": "xxxxxxxxxx"
}
}
2.5.3.2 Response Parameter Description
| Parameter Name | Type | Parameter Description |
|---|---|---|
| code | integer | Error code |
| message | string | Error description |
| sid | string | Session ID |
| data | object | Error code |
| data.url | string | Access external link of the file |
# 4.3 Error Code List
# 4.3.1 Workflow Errors
| Error Code | Description |
|---|---|
| 20201 | Corresponding Flow ID not found |
| 20202 | Invalid Flow ID |
| 20204 | Workflow not published |
| 20207 | Workflow is in draft status |
# 4.3.2 Model Errors
| Error Code | Description |
|---|---|
| 20303 | Model request failed |
| 20350 | Error occurred while upgrading to WebSocket |
| 20351 | Error reading user's message via WebSocket |
| 20352 | Error sending message to user via WebSocket |
| 20353 | Incorrect format of user's message |
| 20354 | Schema error of user data |
| 20355 | Incorrect value of user parameters |
| 20356 | User concurrency error: The current user is already connected, and the same user cannot connect from multiple places at the same time. |
| 20357 | User traffic limited: The service is processing the user's current question, and a new request can only be sent after the processing is completed. (You must wait for the large model to reply completely before sending the next question) |
| 20358 | Insufficient service capacity, contact staff |
| 20359 | Failed to establish connection with the engine |
| 20360 | Error receiving data from the engine |
| 20361 | Error sending data to the engine |
| 20362 | Internal engine error |
| 20363 | Input content failed review, suspected of violating regulations, please adjust the input content again |
| 20364 | Output content involves sensitive information, failed review, and subsequent results cannot be displayed to users |
| 20365 | appid is in the blacklist |
| 20366 | appid authorization error. For example: this function is not activated, the corresponding version is not activated, insufficient tokens, concurrency exceeds authorization, etc. |
| 20367 | Failed to clear history |
| 20368 | Indicates that the content of this session has a tendency to involve violating information; it is recommended that developers give users a prompt that the input involves violations after receiving this error code |
| 20369 | Service is busy, please try again later |
| 20370 | Abnormal parameters for requesting the engine, engine schema check failed |
| 20371 | Engine network exception |
| 20372 | Token quantity exceeds the upper limit. The total number of words in the conversation history + question is too large, and the input needs to be simplified |
| 20373 | Authorization error: the appId has no authorization for the relevant function or the business volume exceeds the limit |
| 20374 | Authorization error: daily flow control exceeded. Exceeded the limit of the maximum daily access volume |
| 20375 | Authorization error: second-level flow control exceeded. Second-level concurrency exceeds the authorized number of channels |
| 20376 | Authorization error: concurrency flow control exceeded. The number of concurrent channels exceeds the authorized number of channels |
| 20380 | External large model request failed |
# 4.3.3 API Authorization
| Error Code | Description |
|---|---|
| 20900 | Authentication failed: authorization restriction, service unauthorized or authorization expired |
| 20901 | Metering authentication failed: service exceeded limit, total business sessions exceeded limit or daily flow control exceeded |
| 20902 | Authentication failed: service exceeded limit, QPS second-level flow control exceeded |
| 20903 | Concurrency authentication failed: service exceeded limit, number of concurrent channels exceeded |
# 4.3.4 Text-to-Image
| Error Code | Description |
|---|---|
| 21200 | Image generation failed |
| 21201 | Image storage failed |
| 21203 | Incorrect format of user's message |
| 21204 | Schema error of user data |
| 21205 | Incorrect value of user parameters |
| 21206 | Insufficient service capacity |
| 21207 | Input failed review |
| 21208 | Images generated by the model involve sensitive information, failed review |
| 21209 | Text-to-image timeout |
# 4.3.5 Tool Errors
| Error Code | Description |
|---|---|
| 21800 | Tool request failed |
| 21801 | Tool initialization failed |
| 21802 | Tool JSON protocol parsing failed |
| 21803 | Tool protocol verification failed |
| 21804 | Tool OpenAPI protocol parsing failed |
| 21805 | Unsupported tool body type |
| 21806 | Tool server does not exist |
| 21807 | Official tool request failed |
| 21808 | Tool does not exist |
| 21809 | Tool Operation does not exist |
| 21810 | Tool request failed, connection exception |
| 21811 | Third-party tool execution failed |
| 21812 | Third-party tool request failed |
# 4.3.6 Node Execution Errors
| Error Code | Description |
|---|---|
| 20500 | Knowledge base request exception |
| 20501 | Knowledge base node execution exception |
| 20502 | Knowledge base parameter exception |
| 22500 | Incorrect start node protocol |
| 22600 | Incorrect end node protocol |
| 22601 | End node execution failed |
| 22701 | Message node execution failed |
| 21900 | Parameter extraction failed |
| 21600 | Code execution failed |
| 21601 | Code interpreter node construction failed |
| 21602 | The type of result returned by the code node does not meet the requirements |
| 21603 | Code execution timeout |
| 22801 | Workflow node execution failed |
| 22802 | Incorrect format of the execution response result of the workflow node |
| 22900 | Variable node execution failed |
| 23100 | Branch node execution failed |
| 23200 | Iteration node execution failed |
| 23300 | Large model node execution failed |
| 23400 | Tool node execution failed |
| 23500 | Text splicing node execution failed |
| 23700 | Agent node execution failed |
| 23800 | Q&A node execution failed |
# 4.3.7 Session
| Error Code | Description |
|---|---|
| 20804 | OpenAPI output timeout |
| 23900 | The conversation has timed out or does not exist |
# 5. Authentication Guide
# 5.1 Request URL
// Depends on specific AI capability
https://rest-api.xfyun.cn/v2/***
# 5.2 Signature and Authentication
API calls must sign HTTP requests. The server identifies and validates users through signatures. Users apply to the server for a credential, which is a key/secret key pair. The client concatenates Method, Accept, Date, other Header fields, and URL in a specified manner, then signs the request using a hash algorithm (such as HMAC-SHA256) and the user's secret. Finally, place the key, algorithm used, header fields involved in signing, and the calculated signature into the "Authorization" header field.
# Request Header Example:
Content-Type: application/json
Accept: application/json;version=1.0
Date: Tue, 26 Jun 2018 12:27:03 UTC
Host: "your host"
Digest: SHA-256=xxxxxxxxxxxxxxxxxxxxxxxx
Authorization: hmac api_key="your_key", algorithm="hmac-sha256", headers="host date request-line", signature="base64_digest"
# 5.3 Authentication Method
The client needs to use the hmac-sha256 algorithm to calculate a digest of relevant request parameters to generate a signature, building the Authorization header. The server parses the Authorization header and calculates the signature in the same way, comparing whether the signatures match. If they match, authentication passes.
# 5.4 Header Detailed Description
| Signature Parameter | Description |
|---|---|
| Date | Request date, UTC timezone. Format example: Tue, 26 Jun 2018 12:27:03 UTC |
| Host | Request host, this header is required for signature calculation |
| Authorization | Authentication parameter, specific construction method as follows |
| Digest | Body digest, calculation method is "SHA256="+sha256(${body}) |
# 5.5 Signature Generation Formula
api_key="${api_key}", algorithm="hmac-sha256", headers="host date request-line digest", signature="${signature}"
Explanation:
- api_key: API key applied from the open platform
- algorithm: Signature calculation algorithm, supports hmac-sha256
- headers: Parameters required for signature, must include at least host, date, and request-line
- signature: Calculated signature
# 5.6 Authentication Detailed Process
# 5.6.1 Build Signature Origin String (signature_origin_str)
The format of signature_origin_str is:
host: ${host}
date: ${date}
${method} ${path} HTTP/1.1
digest: ${digest}
- host: Request host header, e.g., iat-api.xfyun.cn. Must be placed in the request header, and the host used in signature calculation must be completely consistent with the header in the HTTP message.
- date: Current timestamp, format is Wed, 08 Jun 2022 08:12:15 UTC. Must be placed in the request header.
- method: Request method. Supports GET, POST, DELETE, PATCH, PUT. Must be consistent with the current HTTP request method.
- path: Request path. Does not include the query string part ('?' and following). For example, when URL is '/v2/iat?a=b&c=d', only take '/v2/iat' as the path value.
- digest: Request body digest part, calculation method is "SHA256="+sha256(${body})
Note: There is a space after ':', '\n' is a newline character. HTTP/1.1 is the HTTP protocol version. If the client uses HTTP/1.0 protocol, the value should be changed to HTTP/1.0.
# 5.6.2 Calculate Signature
Calculation method: Use hmac-sha256 algorithm to calculate the signature of signature_origin_str, and perform base64 encoding.
signature = base64(hmac-sha256(${signature_origin_str}, ${api_secret}))
Where api_secret is the secret part of the key pair obtained from the platform side, and signature_origin_str is the parameters concatenated in the previous step.
# 5.6.3 Concatenate Authorization Header
authorization_raw = api_key="${api_key}", algorithm="hmac-sha256", headers="host date request-line digest", signature="${signature}"
# 5.7 Signature Generation Example
Suppose there is the following request:
- Request URL: http://iat-api.xfyun.cn/v2/iat
- Request method: POST
- User's api_key = 5ccdf2b4d1b5cdf81846697bf8bcd05d
- api_secret = B00TFRS9KDCfTrdX5JQwhVSXaFoHLy34
- Current time: Wed, 08 Jun 2022 09:00:06 UTC
- Request body content: hello world
Step 1: Then signature_origin_str should be concatenated as:
host: iat-api.xfyun.cn
date: Wed, 08 Jun 2022 09:00:06 UTC
POST /v2/iat HTTP/1.1
digest: SHA256=uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=
Step 2: The signature calculated using signature_origin_str:
rRU2FA174RdsqpdxGzrLmJ6C1CPk5GgfP7bUQToxQIw=
Step 3: Then the authorization header is:
api_key="5ccdf2b4d1b5cdf81846697bf8bcd05d", algorithm="hmac-sha256", headers="host date request-line", signature="rRU2FA174RdsqpdxGzrLmJ6C1CPk5GgfP7bUQToxQIw="
Step 4: The final request headers are:
Authorization: api_key="5ccdf2b4d1b5cdf81846697bf8bcd05d", algorithm="hmac-sha256", headers="host date request-line", signature="VhEap7PkvX7ujjx8DjBtkRZFwQDIEOc62EM+M9N+pf8="
Host: iat-api.xfyun.cn
Date: Wed, 08 Jun 2022 08:12:15 UTC
Digest: SHA256=uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=
Users can use this example to verify whether their signature algorithm implementation is correct.
# 5.8 Key Function Description
| Function Name | Description |
|---|---|
| hmac-sha256 | A standard signature algorithm. Provide a key and data to be signed, and it can calculate the signature digest. The calculation result is raw bytes and should not be encoded. |
| base64 | A standard method to encode bytes into visible strings. Note to use standard base64, not base64_url. |
| sha256 | sha256 signature algorithm |
# 5.9 Authentication Failure Response Example
HTTP/1.1 403 Forbidden
Date: Thu, 06 Dec 2018 07:55:16 GMT
Content-Length: 116
Content-Type: text/plain; charset=utf-8
{
"message": "HMAC signature does not match"
}
# 5.10 Possible Causes of Authentication Failure Analysis
Users can determine where the authentication problem lies through the httpCode returned by the server and the message field in the response body.
| HTTP Code | Message | Cause |
|---|---|---|
| 401 | Unauthorized | User did not pass the Authorization header |
| 401 | HMAC signature cannot be verified, fail to retrieve credential | Server cannot query the api_key. Check if the apikey is correct. |
| 401 | HMAC signature cannot be verified, enforce header 'host' not used for HMAC Authentication | Server failed to parse 'Authorization' header. Check if the format of 'Authorization' header meets document requirements. |
| 403 | HMAC signature cannot be verified, a valid date or x-date header is required for HMAC Authentication | Date header format does not match document requirements or time deviation from server exceeds 300s. Check if the client machine timestamp is synchronized with the internet, or if the timezone is correct. |
| 403 | not found | Cannot find the request address. Check if the request address is correct. |
| 401 | HMAC signature does not match | Server calculated signature does not match client calculated signature value. There may be multiple causes. Try the following solutions: |
Troubleshooting Steps:
- Check if api_secret is correct
- Check if signature_origin_str format is concatenated correctly. The correct format is described in the document above. You can print parameters for comparison.
- Check if the hmac-sha256 calculated signature length is 44. If it is 88, the string used for base64 calculation has already been hex-encoded. You need to use raw unencoded byte stream for base64 encoding.
- Check if nginx proxy is used. Nginx defaults to using HTTP 1.0 for proxy requests, which causes the server to get HTTP version HTTP/1.0, resulting in signature calculation mismatch. Need to set nginx to use HTTP/1.1 protocol to request the server.
- If none of the above methods solve the issue, try using packet capture tools to analyze the packet. Some frameworks may send HTTP messages that differ slightly from the code, such as host, path, and HTTP version number may not match expectations. Focus on checking whether these parameters in the packet match the corresponding parameters used in code for concatenating signature_origin_str.
# 5.11 Pseudocode
func assembleRequestHeader(requestUrl, method, body, apikey, apisecret) {
url = urlparse(requestUrl)
host = url.host
path = url.path
date = now().format('Tue, 26 Jun 2018 12:27:03 UTC')
request-line = "$method $path HTTP/1.1"
signature_headers = "host date request-line"
signature_strs = "host: $host\ndate: $date\n$request-line"
digest = ""
if body != nil:
signature_headers = "host date request-line digest"
digest = "SHA-256=" + base64(sha256(body))
signature_strs = "host: $host\ndate: $date\n$request-line\ndigest: $digest"
else:
signature_strs = "host: $host\ndate: $date\n$request-line"
signature = base64(hmac-sha256(signature_strs, apisecret))
authorization = 'api_key="$apikey", algorithm="hmac-sha256", headers="$signature_headers", signature="$signature"'
return {
"Host": host,
"Date": date,
"Digest": digest,
"Authorization": authorization
}
}
# 5.12 Sample Code for Signature Generation
# 5.12.1 Golang
package iflyauth
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
"net/url"
"time"
)
// Build authentication headers
// @requestUrl: like http://api.xfyun.cn
// @method: GET, POST, etc....
// @body: request body
func NewAuthHeaders(requestUrl, method string, apiKey, apiSecret string, body []byte) map[string]string {
bodySign := ""
if body == nil {
bodySign = sha256Base64([]byte(nil))
} else {
bodySign = sha256Base64(body)
}
bodySign = "SHA256=" + bodySign
u, err := url.Parse(requestUrl)
if err != nil {
panic("parse url error" + err.Error())
}
host := u.Host
date := time.Now().UTC().Format(time.RFC1123)
if u.Path == "" {
u.Path = "/"
}
requestLine := method + " " + u.Path + " HTTP/1.1"
signUrl := fmt.Sprintf("host: %s\ndate: %s\n%s\ndigest: %s", host, date, requestLine, bodySign)
signature := hmacSha256Base64([]byte(apiSecret), []byte(signUrl))
authorization := fmt.Sprintf(`api_key="%s", algorithm="hmac-sha256", headers="host date request-line digest", signature="%s"`, apiKey, signature)
return map[string]string{
"host": host,
"date": date,
"authorization": authorization,
"digest": bodySign,
}
}
func sha256Base64(b []byte) string {
h := sha256.New()
h.Write(b)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
func hmacSha256Base64(secret []byte, data []byte) string {
h := hmac.New(sha256.New, secret)
h.Write(data)
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}
# 5.12.2 Java
/**
* Calculate header parameters needed for signature (HTTP interface)
* @param requestUrl like 'http://rest-api.xfyun.cn/v2/iat'
* @param apiKey
* @param apiSecret
* @method request method POST/GET/PATCH/DELETE etc....
* @param body HTTP request body
* @return header map, contains all headers should be set when accessing api
*/
public static Map<String, String> assembleRequestHeader(String requestUrl, String apiKey, String apiSecret, String method, byte[] body) {
URL url = null;
try {
url = new URL(requestUrl);
// Get date
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
format.setTimeZone(TimeZone.getTimeZone("UTC"));
String date = format.format(new Date());
// Calculate body digest (SHA256)
MessageDigest instance = MessageDigest.getInstance("SHA-256");
instance.update(body);
String digest = "SHA256=" + Base64.getEncoder().encodeToString(instance.digest());
// date = "Thu, 19 Dec 2024 07:47:57 GMT";
String host = url.getHost();
int port = url.getPort(); // port > 0 means url contains port
if (port > 0) {
host = host + ":" + port;
}
String path = url.getPath();
if ("".equals(path) || path == null) {
path = "/";
}
// Build parameters needed for signature calculation
StringBuilder builder = new StringBuilder()
.append("host: ").append(host).append("\n")
.append("date: ").append(date).append("\n")
.append(method).append(" ").append(path).append(" HTTP/1.1").append("\n")
.append("digest: ").append(digest);
Charset charset = Charset.forName("UTF-8");
System.out.println(builder.toString());
// Use hmac-sha256 to calculate signature
Mac mac = Mac.getInstance("hmacsha256");
// System.out.println(builder.toString());
SecretKeySpec spec = new SecretKeySpec(apiSecret.getBytes(charset), "hmacsha256");
mac.init(spec);
byte[] hexDigits = mac.doFinal(builder.toString().getBytes(charset));
String sha = Base64.getEncoder().encodeToString(hexDigits);
// Build header
String authorization = String.format("hmac-auth api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", apiKey, "hmac-sha256", "host date request-line digest", sha);
Map<String, String> header = new HashMap<String, String>();
header.put("authorization", authorization);
header.put("host", host);
header.put("date", date);
header.put("digest", digest);
System.out.println("header " + header.toString());
return header;
} catch (Exception e) {
throw new RuntimeException("assemble requestHeader error:" + e.getMessage());
}
}
# 5.12.3 JavaScript
function assembleRequestHeader(host, path, method, apiKey, apiSecret, body) {
var date = new Date().toGMTString()
var algorithm = 'hmac-sha256'
var headers = 'host date request-line digest'
var digest = "SHA256=" + CryptoJS.enc.Base64.stringify(CryptoJS.SHA256(body))
var signatureOrigin = `host: ${host}\ndate: ${date}\n${method} ${path} HTTP/1.1\ndigest: ${digest}`
var signatureSha = CryptoJS.HmacSHA256(signatureOrigin, apiSecret)
var signature = CryptoJS.enc.Base64.stringify(signatureSha)
var authorization = `api_key="${apiKey}", algorithm="${algorithm}", headers="${headers}", signature="${signature}"`
return {
// 'Host': host,
'X-Date': date, // In JS, may not be able to set Date header, use X-Date
'Authorization': authorization,
'Digest': digest,
}
}
var headers = assembleRequestHeader('rest-api-gz.xfyun.cn', '/v2/tts', 'POST', 'xxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxx', '')
# 5.12.4 Python 3
from datetime import datetime
from wsgiref.handlers import format_date_time
from time import mktime
import hashlib
import base64
import hmac
from urllib.parse import urlparse
import sys
# Calculate sha256 and encode to base64
def sha256base64(data):
sha256 = hashlib.sha256()
sha256.update(data)
digest = base64.b64encode(sha256.digest()).decode(encoding='utf-8')
return digest
# Build auth request url
def assemble_auth_header(requset_url, method="GET", api_key="", api_secret="", body=""):
u = urlparse(requset_url)
host = u.hostname
path = u.path
now = datetime.now()
date = format_date_time(mktime(now.timetuple()))
digest = "SHA256=" + sha256base64(body.encode())
# date = "Thu, 12 Dec 2019 01:57:27 GMT"
signature_origin = "host: {}\ndate: {}\n{} {} HTTP/1.1\ndigest: {}".format(host, date, method, path, digest)
# print(signature_origin)
signature_sha = hmac.new(api_secret.encode('utf-8'), signature_origin.encode('utf-8'),
digestmod=hashlib.sha256).digest()
signature_sha = base64.b64encode(signature_sha).decode(encoding='utf-8')
authorization = "api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"" % (
api_key, "hmac-sha256", "host date request-line digest", signature_sha)
# print(authorization_origin)
headers = {
"host": host,
"date": date,
"authorization": authorization,
"digest": digest,
}
return headers
requrl = "http://rest-api.xfyun.cn/v2/itr"
import requests
import json
import time
body = {
"common": {},
"business": {},
"data": {}
}
now = time.time()
bds = json.dumps(body)
headers = assemble_auth_header(requrl, method="POST", api_key="xxxxxxxxx",
api_secret="xxxxxxxxxxxxx", body=bds)
resp = requests.post(requrl, headers=headers, data=bds)
print(resp.status_code, resp.text)
# 5.12.5 PHP
class http_test {
function tocurl($url, $header, $content) {
$ch = curl_init();
if (substr($url, 0, 5) == 'https') {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Skip certificate check
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Check if SSL encryption algorithm exists in certificate
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
if (is_array($header)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
}
curl_setopt($ch, CURLOPT_POST, true);
if (!empty($content)) {
if (is_array($content)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
} else if (is_string($content)) {
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
}
}
$response = curl_exec($ch);
$error = curl_error($ch);
// var_dump($error);
if ($error) {
die($error);
}
$header = curl_getinfo($ch);
curl_close($ch);
$data = array('header' => $header, 'body' => $response);
return $data;
}
function xfyun() {
$app_id = "XXXXX";
$api_sec = "XXXXXXXXX";
$api_key = "XXXXXXXXX";
$resource = "resource/xx";
$url = "xx";
$host = "xx.xxx.cn"; # Request host
$path = "/v2/xxx"; # Request path
// Body assembly
$body = json_encode($this->getBody($app_id, $resource));
// Assemble HTTP request headers
// $date = gmstrftime("%a, %d %b %Y %H:%M:%S %Z", time());
$date = gmdate('D, d M Y H:i:s') . ' GMT';
$digestBase64 = "SHA-256=" . base64_encode(hash("sha256", $body, true));
$builder = sprintf("host: %s\ndate: %s\nPOST %s HTTP/1.1\ndigest: %s", $host, $date, $path, $digestBase64);
$sha = base64_encode(hash_hmac("sha256", $builder, $api_sec, true));
$authorization = sprintf("api_key=\"%s\", algorithm=\"%s\", headers=\"%s\", signature=\"%s\"", $api_key, "hmac-sha256", "host date request-line digest", $sha);
$header = [
"Authorization: " . $authorization,
'Content-Type: application/json',
'Accept: application/json;version=1.0',
'Host: rest-api.xfyun.cn', // Replace with actual domain host
'Date: ' . $date,
'Digest: ' . $digestBase64
];
$response = $this->tocurl($url, $header, $body);
var_dump($response['body']);
}
}
# 6. FAQ
# 6.1 Platform-Related
Q1: Is the Astron Workflow Platform free to use?
Yes, the Astron Workflow Platform is free to use.
Q2: What is the maximum number of agents a single account can create?
100 agents.
# 6.2 Prompt Agent–Related
Q3: What's the difference between a Prompt Agent and a Workflow Agent?
Prompt Agent: Functions more like an autonomous "executor." You give it a prompt persona and a goal (for example, "help me plan a weekend trip"), and it will independently plan the steps, call tools (checking the weather, searching for attractions, comparing prices), adapt to changes, and ultimately deliver a solution. It emphasizes intelligence and adaptability.
Workflow Agent: Functions more like a preset "assembly line." You need to predefine the rules and sequence for each step in advance, and the agent strictly follows this process during execution. It emphasizes standardization, automation, and predictability.
# 6.3 Workflow Agent–Related
Q4: Does the platform support multi-agent collaboration?
Currently, a Workflow Agent can nest another Workflow Agent using the Workflow Node. Note that the referenced workflow must be published before it can be used in a Workflow Node.
Q5: Can the Astron Workflow Platform be quickly embedded into a mini program or other systems via JS?
Yes. The platform currently supports publishing as an API, which can be integrated and called via API.
Q6: Does the default intent in the Decision Node need to be connected to a downstream node? Is this required?
Yes, the default intent must also be connected, functioning as an independent branch.
Q7: Does the platform offer workflow templates, such as for customer service scenarios?
Yes. In addition to that, the platform offers a rich variety of workflow scenario templates. You can find them at: Platform Homepage → My Agents → Create Agent → Workflow Creation → [choose from multiple available templates].
Q8: Can workflow templates be called directly via an interface?
Yes — after creating a workflow from a template, you can publish it as an API and call it accordingly.
Q9: What should I do if the LLM Node's output doesn't match expectations? Or how can I get the model to output in a specific template or format?
This is typically a prompt-related issue. Try optimizing your prompt — for example, by including a sample output in the prompt so the model strictly follows that format when generating its response.
Q10: Does the model remember the context of a Workflow Agent's conversation? How do I enable conversation history to work in the debug interface?
Simply enable Conversation History in the LLM Node, where you can also set the number of conversation turns to include.
Q11: I enabled Conversation History in the Workflow Agent's LLM Node, but it doesn't seem to be working — the "chat history" field is missing from the input in the execution results. What's going on?
This is most likely because the model's parameter settings are limiting the input character count, which can happen if too many turns or too much content is configured. Try increasing the model's Max Reply Length and reducing the number of conversation turns.
Q12: What's the difference between the System Prompt and User Prompt in a Workflow Agent's LLM Node?
The System Prompt is a preset, global instruction used to define the model's behavioral framework, role identity, capability boundaries, and output style.
The User Prompt refers to a specific task with a clearly defined scenario.
Q13: Does the model used in a Workflow Agent's LLM Node support web search?
No. If you need web search capability, add a Tool Node and select the Web Search tool.
Q14: How does the Agent Intelligent Decision Node in a Workflow Agent call plugins?
First, make sure the relevant plugins have been added to the Intelligent Decision Node — the node can then independently reason through the user's request and decide which added plugin to call.
You can also explicitly instruct the Agent Decision Node in the prompt regarding under what conditions it should call a specific plugin.
Q15: What should I do if a Workflow Agent's Agent Intelligent Decision Node throws a timeout error?
Currently, the gateway will disconnect and return a timeout error if no response is returned within 2 minutes. Try using a Message Node to stream the reasoning process as output instead — note that you'll need to enable the Streaming Output toggle for this to work.
Q16: What should I do if a Workflow Agent's Agent Decision Node fails (e.g., the model returns reasoning content in an incorrect format, or invalid plugin parameters)?
Check whether the LLM's output content is well-formed and correct (for example, check for unexpected characters in JSON content), and confirm that the relevant plugins have been added to the Agent Decision Node.
Q17: Why does a Workflow Agent's Workflow Node fail to produce output, or fail entirely?
Common causes include: (1) The referenced workflow is complex and produces a large amount of output, causing a timeout — since the Workflow Node doesn't support streaming output, this results in a failed output; (2) Check whether the referenced workflow contains a Q&A Node — if it does, the Workflow Node does not support output in that case.
Q18: What causes the error "Workflow engine node protocol validation failed" during workflow import?
This error can occur for several reasons: (1) The imported workflow includes a model belonging to someone else, and that model (Model ID) isn't available under your own account; (2) The imported workflow includes a tool belonging to someone else, and that tool (Plugin ID) isn't available under your own account; (3) The imported workflow includes a knowledge base belonging to someone else, and that knowledge base (Knowledge ID) isn't available under your own account. The underlying cause is generally a missing resource that exists in the original account but not in yours.
Q19: A Workflow Agent's node is taking too long to run / execution time is too long — how can I speed it up?
Long node execution times are usually caused by the model itself. Try switching to a smaller model to increase output speed, or use a model without a reasoning/chain-of-thought pipeline. You can also optimize your prompt to reduce unnecessary reasoning steps, which cuts down on processing time. It's also recommended to add a Message Node after this node to enable streaming output, which can reduce perceived wait time.
Q20: What should I do if a Workflow Agent's Code Node makes a network request but returns no output? How can I make network requests?
The Code Node does not support network requests. If you need to make network requests, go to Homepage → Resource Management → Create Plugin to set this up.
Q21: Why does a node fail to produce proper output even though the workflow runs without any errors? For example, why might an Iteration Node fail to output correctly?
Check the execution results and verify whether there's an issue with that node's input — correct input is required in order to produce the corresponding output.
Q22: How can I iterate and optimize a task?
Create a Workflow Agent and use the Iteration Node. The Iteration Node allows users to configure tasks or operations that repeat — similar to a for loop in programming languages. It iterates over a known array, executing the same set of steps for each element. With each iteration, the workflow executes each node within the canvas in sequence.
Q23: Can a Workflow Agent's Q&A Node enforce a timeout during API calls — for example, requiring a response within a certain time, after which it becomes invalid?
Yes. This can be configured under Reply Mode settings in the Q&A Node, via the Conversation Timeout setting.
Q24: How can I upload images, audio, PDF, Word, PPT, Excel, or other files within an agent?
The Start Node supports uploading multimodal files such as images, audio, PDF, Word, PPT, Excel, and TXT, and allows you to define a custom variable for the file. Once uploaded to the platform, these files are automatically converted into a URL, with no expiration on storage. The file can then be parsed and processed using the platform's related plugin tools. For API calls, please refer to the "API Calls – File Upload" section of the platform's official documentation.
Q25: Can audio files only be uploaded via the Start Node? Can audio be uploaded during a Q&A interaction?
Audio files can only be uploaded via the Start Node; uploading audio during a Q&A interaction is not supported.
Q26: What does "streaming output" mean?
Streaming output: Rather than generating the entire response at once, the model generates it word by word or piece by piece (typically in units of tokens or word fragments). Each small piece of generated content is immediately transmitted over the network to the client (such as your browser or app), which can display or process these partial results in real time. This means generation and transmission happen in parallel.
The opposite of this is non-streaming output: the model must first fully generate the entire response internally, then package all of the content together and return it to the client in a single, complete HTTP response. This means generation and transmission happen sequentially, and the user must wait for the entire process to finish before seeing any result.