LLM Nodes

Applies to: ChengOS v0.2.0+ | Last verified: 2026-09-25 | Source: crates/cheng-nodes/src/nodes/builtin/ai

ai/llm is the workhorse: one call, optional conversation context in and out, and a tools port that turns it into a function-calling step. ai/llm_config exists so the model, provider, and parameters live in one place and can be reused by every node downstream — configure once, connect many. ai/llm_branch routes on fields of a structured response instead of on free text, which is far more stable than parsing prose. ai/context_merge combines several AgentContext streams into the single history a later call should see.

AI Chat — ai/llm

Call large language model for dialogue generation

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullAgentContext (optional, carries conversation history). Connection port, not a form field.
llm_configobject (port)✅—LLM configuration (JSON string or object). Connection port, not a form field. Control: text
instruction_promptstring—""Instruction prompt (optional). Control: textarea
user_messagestring—""User message (can be empty if context.history already contains user messages). Control: textarea
user_message_richobject (port)—nullStructured user message with multimodal parts. Connection port, not a form field.
image_base64string (port)—nullBase64 image payload or data URL, connectable from io/file_upload.image_base64. Connection port, not a form field.
toolsarray<any>—nullAvailable tools list (dynamically add ports)

Outputs

FieldTypeDescription
contextobject (port)AgentContext output port (contains conversation history). Connection port, not a form field.
responsestringGenerated text response
prompt_tokensintegerTokens used in prompt
completion_tokensintegerTokens used in completion
total_tokensintegerTotal tokens used
finish_reasonstringFinish reason
tool_callsarrayTool calls made by the LLM (for function calling)
tool_resultsarrayTool execution results (when tools are connected and auto-executed)
llm_configobject (port)LLM configuration used for this call (reusable by downstream nodes). Connection port, not a form field. Control: text

LLM Field Branch — ai/llm_branch

Route by field conditions: supports operator comparison, dot nested path, Schema hint generation, enhanced fallback metadata

Inputs

FieldTypeRequiredDefaultDescription
contextobject (port)—nullInput AgentContext (optional). Connection port, not a form field. Control: code-editor
responsestring—""LLM response text (JSON format). Control: code-editor
custom_datastring—nullCustom JSON data. Control: code-editor
payload_sourceenum—responseSelect data extraction source. Control: select. Options: response (从 response 字段解析 JSON), context (从完整 context 序列化为 JSON), custom (从 custom_data 字段取值)
branch_fieldsarray<object>—[]Branch field list (click + to add; each entry auto-generates a corresponding output port)
route_shortcutany—nullRoute shortcut payload injected by ShortcutService (from execution metadata). Its value object is merged into the routing payload before field matching.
strict_modeboolean—falseError on JSON parse failure (false routes error reason to context_out fallback)
generate_schemaboolean—falseEnable auto-generated JSON Schema hint output to schema_hint port (can connect to upstream LLM's system_prompt)

Outputs

FieldTypeDescription
branch_outputsarray<any> (port)Branch output list, corresponding 1:1 with branch_fields (AgentContext on match, null on miss). Connection port, not a form field.
context_outobject (port)Fallback output: outputs AgentContext from this port when no branch fields match (includes routing diagnostic metadata). Connection port, not a form field.
schema_hintobject (port)Auto-generated structured output hint (can connect to upstream LLM node's system_prompt port). Connection port, not a form field.

LLM Config — ai/llm_config

Select connected LLM model, output complete configuration

Inputs

FieldTypeRequiredDefaultDescription
modelstring✅—Select a connected LLM model. Control: llm-model-select
model_overridestring—nullModel override (format: credential_id::model_name, takes priority over model)
temperaturenumber—0.699999988079071Controls randomness of generation, higher values are more random (0.0 - 2.0). Control: slider
max_tokensinteger—5000Maximum number of tokens to generate (default 5000)
top_pnumber—1.0Nucleus sampling threshold (0.0 - 1.0). Control: slider
frequency_penaltynumber—0.0Reduce likelihood of repeating the same line (-2.0 to 2.0). Control: slider
presence_penaltynumber—0.0Encourage the model to discuss new topics (-2.0 to 2.0). Control: slider
streamboolean—trueEnable real-time streaming of results
ephemeralboolean—falseRun as a one-off call without loading or saving conversation history
use_historyboolean—trueSend prior conversation turns to the model; when off, each turn is answered on its own while the reply is still saved
timeout_secsinteger—60API request timeout (1-600 seconds)
json_modeboolean—falseInject response_format: json_object (for weaker/open-source models, reduces non-JSON text; no system-level validation)
compatibility_profileenum—nullProtocol template for custom OpenAI-compatible endpoints only (conservative | openai | deepseek | minimax | zhipu). Overrides the credential-level default; ignored for built-in providers.

Outputs

FieldTypeDescription
llm_configobject (port)Complete LLM configuration. Connection port, not a form field.

Context Merge — ai/context_merge

Merge conversation contexts, intent text and data payloads into one AgentContext

Inputs

FieldTypeRequiredDefaultDescription
context_inputsarray<any>—[]对话上下文端口组(context_input_0, context_input_1, ...)
intent_inputsarray<any>—[]意图文本端口组(intent_input_0, intent_input_1, ...)
data_inputsarray<any>—[]数据负载端口组(data_input_0, data_input_1, ...)
intent_separatorstring—nullSeparator placed between several intents (default: a blank line)
custom_session_idstring—nullCustom session_id (optional)
system_messagestring—nullAdditional system message (optional). Control: textarea

Outputs

FieldTypeDescription
contextobject (port)AgentContext output port (merged conversation). Connection port, not a form field.
replystringAssistant reply text from the merged context
formatted_contentstringPlain text of the merged conversation (human-readable; excludes attached data)
dataanyPayloads received on the data ports, verbatim, tagged by port
statsobjectMerge statistics

Next steps