Qianfan
The Qianfan component lets you ask questions or give prompts to Baidu’s AI models and receive natural‑language answers. It’s a simple “chat” interface that connects your workflow to Baidu’s Qianfan service.
How it Works
When you add the Qianfan component to a workflow, it sends the text you provide to Baidu’s Qianfan API. The API processes the input with the selected model (for example, ERNIE‑Bot‑turbo or Llama‑2‑7b‑chat) and returns a reply. The component then passes that reply back into the workflow as a message. If you enable Mapping Mode, the component can handle many inputs at once, sending each one to the API and collecting the responses in a batch.
Inputs
Mapping Mode
This component has a special mode called “Mapping Mode”. When you enable this mode using the toggle switch, an additional input called “Mapping Data” is activated, and each input field offers you three different ways to provide data:
- Fixed: You type the value directly into the field.
- Mapped: You connect the output of another component to use its result as the value.
- Javascript: You write Javascript code to dynamically calculate the value.
This flexibility allows you to create more dynamic and connected workflows.
Note: This component requires a QianFan API credential.
- Configure the credential in the Credentials section of Nappai.
- Select that credential in the Credential field of the component.
Input Fields
- Endpoint: The URL of the Qianfan LLM endpoint. Required only if you are using a custom model.
- Input: The text or prompt you want the model to respond to.
- Mapping Mode: Toggle to enable batch processing of multiple inputs.
- Model Name: Choose which Baidu model to use (e.g., ERNIE‑Bot‑turbo, Llama‑2‑13b‑chat).
- Penalty Score: Controls how much the model penalizes repeated phrases (only for ERNIE‑Bot models).
- Stream: If checked, the model’s reply will be streamed back in real time. Works only in chat mode.
- System Message: A message that sets the behavior or context for the model.
- Temperature: Adjusts the randomness of the output (higher = more creative).
- Top p: Limits the probability mass considered for each token (only for ERNIE‑Bot models).
Outputs
- Text: The generated reply from the model, returned as a message.
- Model: The configured language model instance, useful if you want to pass it to another component.
Usage Example
- Set up credentials – In the Nappai dashboard, go to Credentials, add a new QianFan API credential, and paste your Qianfan Ak and Secret Key.
- Add the Qianfan component – Drag it onto the canvas.
- Select the credential – In the component’s Credential field, pick the credential you just created.
- Choose a model – For a quick test, keep the default ERNIE‑Bot‑turbo.
- Enter a prompt – In the Input field, type “What is the capital of France?”
- Run the workflow – The component sends the prompt to Baidu, receives the answer, and outputs it in the Text field.
- Optional – Mapping Mode – If you have a list of questions, enable Mapping Mode, connect the list to the Input field, and the component will return a list of answers.
Related Components
- OpenAIChatModel – Connects to OpenAI’s GPT models.
- AnthropicClaudeModel – Uses Anthropic’s Claude LLM.
- AzureOpenAIChatModel – Integrates with Azure’s OpenAI service.
- GoogleGeminiChatModel – Calls Google’s Gemini LLM.
These components share a similar interface, so you can swap them in and out of your workflow with minimal changes.
Tips and Best Practices
- Choose the right model – ERNIE‑Bot‑turbo is fast and cost‑effective for general queries; Llama‑2‑70b‑chat offers higher quality for complex tasks.
- Adjust temperature – Lower values (e.g., 0.3) give more deterministic answers; higher values (e.g., 0.8) produce more creative responses.
- Use Mapping Mode for batch jobs – When processing many records, enable Mapping Mode to avoid sending requests one by one.
- Keep credentials secure – Never expose your Qianfan Ak or Secret Key in public workflows; use the credential system.
- Test with small prompts first – Verify the model’s behavior before scaling up to large inputs.
Security Considerations
- Credential protection – Credentials are stored encrypted in Nappai. Only users with the appropriate permissions can view or edit them.
- Data privacy – Text sent to Baidu’s API leaves your local environment. If your data is sensitive, review Baidu’s privacy policy and consider using a local or on‑premise model.
- Rate limits – Baidu imposes limits on API calls. Monitor usage to avoid hitting quotas, especially when using Mapping Mode with many inputs.