feat(components): add Baidu Qianfan embeddings node#6147
feat(components): add Baidu Qianfan embeddings node#6147jimmyzhuu wants to merge 2 commits intoFlowiseAI:mainfrom
Conversation
There was a problem hiding this comment.
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.
| if (batchSize) obj.batchSize = parseInt(batchSize, 10) | ||
| if (timeout) obj.timeout = parseInt(timeout, 10) |
There was a problem hiding this comment.
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.
| 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
- In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.
|
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. |
What changed
This PR adds a new Baidu Qianfan embeddings node to Flowise.
Changes included:
Baidu Qianfan Embeddingnode underpackages/componentsbaiduQianfanApicredentialEmbedding-V1bge-large-zhbge-large-entao-8kcustomModelNameoverride so users can enter newer or unsupported model IDs manuallystripNewLinesbatchSizetimeoutWhy 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:
Tests / validation
Validated with:
BaiduQianfanEmbeddingpackages/componentsCommands used:
corepack pnpm@10.26.0 --dir packages/components test -- BaiduQianfanEmbedding.test.tscorepack pnpm@10.26.0 --dir packages/components exec tsc --noEmit -p tsconfig.jsonNotes for reviewers
This PR intentionally keeps scope small: