Skip to content

feat(components): add Baidu Qianfan embeddings node#6147

Open
jimmyzhuu wants to merge 2 commits intoFlowiseAI:mainfrom
jimmyzhuu:codex/baidu-qianfan-embeddings-node
Open

feat(components): add Baidu Qianfan embeddings node#6147
jimmyzhuu wants to merge 2 commits intoFlowiseAI:mainfrom
jimmyzhuu:codex/baidu-qianfan-embeddings-node

Conversation

@jimmyzhuu
Copy link
Copy Markdown

What changed

This PR adds a new Baidu Qianfan embeddings node to Flowise.

Changes included:

  • add a new Baidu Qianfan Embedding node under packages/components
  • reuse the existing baiduQianfanApi credential
  • support shared embedding model options for common Baidu Qianfan models:
  • Embedding-V1
  • bge-large-zh
  • bge-large-en
  • tao-8k
  • add a customModelName override so users can enter newer or unsupported model IDs manually
  • expose additional supported embedding parameters:
  • stripNewLines
  • batchSize
  • timeout
  • add focused unit tests for model loading and parameter mapping

Why this change is needed

Flowise already supports Baidu Wenxin / Qianfan chat models, but there is currently no built-in Baidu embeddings node.

That makes it harder for users who want to build a Baidu-native RAG pipeline, especially for Chinese-language retrieval use cases. This PR fills that gap with a small, self-contained addition that follows the existing embeddings node pattern in Flowise.

User impact

Users can now:

  • create embeddings with Baidu Qianfan directly inside Flowise
  • select common built-in Baidu embedding models from a dropdown
  • provide a custom model ID when the provider adds newer models before the shared list is updated
  • configure a few basic embedding options without code changes

Tests / validation

Validated with:

  • targeted unit test for BaiduQianfanEmbedding
  • TypeScript no-emit check for packages/components

Commands used:

  • corepack pnpm@10.26.0 --dir packages/components test -- BaiduQianfanEmbedding.test.ts
  • corepack pnpm@10.26.0 --dir packages/components exec tsc --noEmit -p tsconfig.json

Notes for reviewers

This PR intentionally keeps scope small:

  • no server-side changes
  • no credential schema changes
  • no new dependencies
  • no rerank / OCR / other Baidu provider features included

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Baidu Qianfan Embedding component, including its model configurations, node implementation, and unit tests. The review feedback suggests improving the validation of numeric inputs such as batchSize and timeout by using nullish checks to correctly handle zero values, which would otherwise be skipped by truthiness checks.

Comment on lines +105 to +106
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using if (batchSize) and if (timeout) as truthiness checks will skip the assignment if the value is 0. Since these are numeric inputs, it is safer to use a nullish check (!= null) and also check for empty strings to ensure that a value of 0 is correctly processed and to maintain consistency between numeric and string inputs.

Suggested change
if (batchSize) obj.batchSize = parseInt(batchSize, 10)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (batchSize != null && batchSize !== '') obj.batchSize = parseInt(batchSize.toString(), 10)
if (timeout != null && timeout !== '') obj.timeout = parseInt(timeout.toString(), 10)
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

@jimmyzhuu
Copy link
Copy Markdown
Author

Addressed. I updated the numeric parameter checks so explicitly provided zero values are preserved instead of being skipped by truthiness checks, and added a focused test covering batchSize=0 and timeout=0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant