QianFan Chat Model icon

QianFan Chat Model

Language Model QianFan

Overview

This node integrates with the QianFan Chat Model, a language model service provided by Baidu Cloud. It allows users to generate text completions or chat-based responses using specified QianFan models. This node is useful for scenarios such as generating conversational AI replies, drafting content, or performing creative writing tasks where natural language generation is required.

Practical examples include:

  • Building chatbots that respond naturally to user inputs.
  • Generating creative text based on prompts.
  • Automating content creation with configurable randomness and token selection parameters.

Properties

Name Meaning
Model The specific QianFan language model used to generate completions. Can be selected from a list of available models or specified by ID. Default is "ERNIE-SPEED-8K".
Options Additional configuration options affecting the text generation behavior:
- Temperature: Controls randomness in output (0 excluded to 1). Lower values yield more analytical responses; higher values produce more creative outputs.
- Top P: Probability mass threshold for token selection at each step (0 to 1).
- Penalty Score: Penalizes repeated tokens based on frequency, ranging from 1.0 to 2.0, defaulting to 1.0.

Output

The node outputs data under the json field representing the generated text completion or chat response from the QianFan model. The structure typically includes the generated text content and any relevant metadata returned by the API.

If binary data were supported, it would represent associated media or files, but this node focuses on textual output only.

Dependencies

  • Requires an API key credential for Baidu Cloud's QianFan service, including access key and secret key.
  • Uses the @baiducloud/qianfan and @langchain/baidu-qianfan packages to interact with the QianFan API.
  • The node expects these credentials to be configured in n8n prior to execution.

Troubleshooting

  • Authentication errors: Ensure that valid Baidu Cloud API keys are provided and have appropriate permissions for the QianFan chat service.
  • Model loading failures: If the model list fails to load, verify network connectivity and API quota limits.
  • Invalid parameter values: Temperature must be between 0 (exclusive) and 1; Top P between 0 and 1; Penalty Score between 1 and 2. Values outside these ranges may cause errors or unexpected behavior.
  • API rate limits: Exceeding request quotas can result in throttling or errors; monitor usage accordingly.

Links and References

Discussion