DashScope icon

DashScope

调用阿里云 DashScope (通义千问) API

聊天补全

AI-generated

Summary

Send a user message to a selected DashScope AI model with optional multiple contextual inputs and receive an AI-generated chat completion response.

Inputs

  • 模型 (model) — Select which DashScope model to use for the chat completion (Qwen Plus, Turbo, Max, Long). Defaults to Qwen Plus.
  • 上下文数量 (contextCount) — Set the number of additional context input endpoints (0–5). Each context can provide extra JSON data to inform the AI response.
  • 上下文 N 名称 (contextNName) — Define the display name of each context input endpoint (N=1 to 5), shown on the input port.
  • 上下文 N 数据字段 (contextNDataField) — Specify a JSON field from the corresponding context input to extract; if empty, the whole JSON from that input is used.
  • 系统提示词 (systemPrompt) — Provide a system prompt that configures the AI assistant's role and behavior. Defaults to 'You are a helpful assistant.'.
  • 用户消息 (userMessage) (required) — The main user message sent to the AI for completion, supporting multiline input.
  • 选项 (options) — Additional generation parameters including temperature (controls randomness), maxTokens (max tokens generated), topP (nucleus sampling), and whether to force JSON format response (jsonFormat).

Output shape

a list of JSON objects, one per input item

Each output item contains the AI response text under 'response', the model used, usage stats, the contexts sent, and the full raw API response. Partial failures can be handled if 'continueOnFail' is enabled, reporting errors per item.

Examples

Example 1: Basic use

Set model to 'Qwen Plus', enter the userMessage, leave contextCount at 0 to send only the user message without extra context, and get a chat completion response.

Example 2: With contexts

Increase contextCount to add one or more context inputs, name them meaningfully (e.g., 'User History'), optionally specify a JSON field to extract from each context input. The node concatenates context data with the user message before sending to the AI, enriching the prompt for more informed responses.

Links

Discussion