feat: add Astraflow (UCloud) chat model provider#6368
feat: add Astraflow (UCloud) chat model provider#6368ucloudnb666 wants to merge 3 commits intoFlowiseAI:mainfrom
Conversation
…flowApi.credential.ts
…ChatAstraflow/ChatAstraflow.ts
…ChatAstraflow/astraflow.svg
There was a problem hiding this comment.
Code Review
This pull request introduces the Astraflow (UCloud) integration, including a new credential class and a Chat Model node that wraps the LangChain ChatOpenAI implementation. Feedback was provided to improve the robustness of the node by handling optional temperature values to avoid NaN results, updating the token parameter to maxCompletionTokens for better alignment with newer LangChain versions, and ensuring custom headers in baseOptions are correctly passed to the underlying client.
| configuration: { | ||
| baseURL: basePath, | ||
| ...parsedBaseOptions | ||
| } |
There was a problem hiding this comment.
The baseOptions should be passed as defaultHeaders within the configuration object to ensure custom headers are correctly handled by the underlying OpenAI client, maintaining consistency with the ChatOpenAI node implementation.
| configuration: { | |
| baseURL: basePath, | |
| ...parsedBaseOptions | |
| } | |
| configuration: { | |
| baseURL: basePath, | |
| defaultHeaders: parsedBaseOptions | |
| } |
| const obj: ChatOpenAIFields = { | ||
| temperature: parseFloat(temperature), | ||
| modelName, | ||
| openAIApiKey: astraflowApiKey, | ||
| apiKey: astraflowApiKey, | ||
| streaming: streaming ?? true | ||
| } |
There was a problem hiding this comment.
The temperature input is optional. If it is missing or empty, parseFloat(temperature) will result in NaN, which can cause issues during model initialization. It is safer to only assign it if a value is present.
| const obj: ChatOpenAIFields = { | |
| temperature: parseFloat(temperature), | |
| modelName, | |
| openAIApiKey: astraflowApiKey, | |
| apiKey: astraflowApiKey, | |
| streaming: streaming ?? true | |
| } | |
| const obj: ChatOpenAIFields = { | |
| modelName, | |
| openAIApiKey: astraflowApiKey, | |
| apiKey: astraflowApiKey, | |
| streaming: streaming ?? true | |
| } | |
| if (temperature) obj.temperature = parseFloat(temperature) |
| streaming: streaming ?? true | ||
| } | ||
|
|
||
| if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) |
There was a problem hiding this comment.
Description
Adds support for Astraflow (by UCloud / 优刻得) as a Chat Model provider. Astraflow is an OpenAI-compatible AI model aggregation platform that provides access to 200+ models through a unified API.
Because Astraflow exposes an OpenAI-compatible Chat Completions API, the integration is implemented as a thin wrapper around
ChatOpenAI(same approach already used byChatCometAPI,ChatOpenRouter,Deepseek, etc.) — no new SDK is added.Changes
Three small files added, no existing files modified:
packages/components/credentials/AstraflowApi.credential.ts— new credential typeastraflowApiwith a singleastraflowApiKeypassword input.packages/components/nodes/chatmodels/ChatAstraflow/ChatAstraflow.ts— new chat model nodeChatAstraflowthat wrapsChatOpenAIand points it at the Astraflow base URL.packages/components/nodes/chatmodels/ChatAstraflow/astraflow.svg— node icon.Endpoints
The node exposes a
Base URLinput so users can switch between the two Astraflow endpoints:https://api-us-ca.umodelverse.ai/v1— corresponds toASTRAFLOW_API_KEYhttps://api.modelverse.cn/v1— corresponds toASTRAFLOW_CN_API_KEYNotes
ChatCometAPI).gulpfile.ts.