Qwen icon

Qwen

Consume Qwen AI

Actions2

Chat → Complete

AI-generated

Overview

This node integrates with the Qwen AI service to generate text completions based on chat prompts. It is designed for scenarios where users want to interact with an AI language model in a conversational manner, such as building chatbots, virtual assistants, or generating contextual responses dynamically.

Typical use cases include:

  • Creating AI-driven chat interfaces that respond to user inputs.
  • Automating customer support conversations.
  • Generating creative writing or brainstorming ideas through dialogue.
  • Enhancing applications with natural language understanding and generation.

For example, a user can provide a series of messages representing a conversation history, and the node will return the AI-generated continuation or response from the assistant role.

Properties

Name Meaning
Model The AI model used to generate the completion. Users select from available models fetched dynamically from the service.
Prompt A collection of messages forming the conversation history. Each message has a Role (Assistant, System, User) and Content (text). This defines the context for the AI completion.
Simplify Whether to return a simplified version of the response containing only the relevant choices data, instead of the full raw API response. Defaults to true.
Options Additional parameters to customize the completion behavior:
- Frequency Penalty Penalizes new tokens based on their existing frequency to reduce repetition (range: -2 to 2).
- Logprobs Whether to return log probabilities of output tokens. If true, includes token-level log probability data.
- Maximum Tokens Maximum number of tokens to generate in the completion (up to 32768).
- Presence Penalty Penalizes new tokens based on whether they appear in the text so far to encourage topic diversity (range: -2 to 2).
- Response Format JSON object specifying the desired format of the model's output.
- Sampling Temperature Controls randomness of output; lower values make output more deterministic (range: 0 to 1).
- Top Logprobs Number of most likely tokens to return at each position with log probabilities (0 to 20). Requires logprobs to be true.
- Top P Controls nucleus sampling diversity; e.g., 0.5 means half of likelihood-weighted options are considered (range: 0 to 1).

Output

The node outputs a JSON object under the json field containing the AI completion results. By default (when "Simplify" is enabled), the output structure is:

{
  "data": [
    {
      "message": {
        "role": "assistant",
        "content": "Generated response text here"
      },
      "finish_reason": "stop",
      "index": 0
    }
  ]
}
  • data: An array of completion choices returned by the model.
  • Each choice contains a message object with the role and generated content.
  • Other metadata like finish_reason and index indicate why generation stopped and the choice index.

If "Simplify" is disabled, the node returns the full raw API response body.

The node does not output binary data.

Dependencies

  • Requires an API key credential for authenticating with the Qwen AI service.
  • The base URL for requests is https://dashscope.aliyuncs.com/compatible-mode/v1.
  • The node fetches available models dynamically via a GET request to /models.
  • No additional external dependencies beyond the configured API key and network access to the Qwen AI endpoint.

Troubleshooting

  • Common issues:

    • Invalid or missing API key credential will cause authentication failures.
    • Providing an unsupported or unavailable model name may result in errors.
    • Exceeding token limits (maxTokens) could cause request rejections.
    • Incorrectly formatted prompt messages (missing roles or content) might lead to unexpected responses or errors.
  • Error messages:

    • Authentication errors typically indicate invalid credentials; verify the API key setup.
    • Model not found errors suggest selecting a valid model from the dynamically loaded list.
    • Rate limit or quota exceeded errors require checking usage limits on the Qwen AI account.
    • Validation errors on input parameters should be resolved by ensuring correct types and value ranges.

Links and References

  • Qwen AI Official Console
  • Refer to the Qwen AI API documentation for detailed parameter descriptions and model capabilities (link not provided in source).

Discussion