Add AGIone chat model#6485
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the AGIone integration by adding the AGIone API credential and the ChatAGIone chat model node, which wraps AGIone models using an OpenAI-compatible endpoint. The review feedback identifies two potential runtime issues: first, parsing optional numeric inputs directly without nullish checks can result in NaN values or incorrectly ignore valid 0 values; second, accessing properties on parsedBaseOptions without checking if it is null could lead to a TypeError. Both issues should be addressed to ensure robust input handling.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const obj: ChatOpenAIFields = { | ||
| temperature: parseFloat(temperature), | ||
| modelName, | ||
| openAIApiKey: agioneApiKey, | ||
| apiKey: agioneApiKey, | ||
| streaming: streaming ?? true | ||
| } | ||
|
|
||
| if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10) | ||
| if (topP) obj.topP = parseFloat(topP) | ||
| if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty) | ||
| if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty) | ||
| if (cache) obj.cache = cache |
There was a problem hiding this comment.
Parsing optional numeric inputs directly with parseFloat or parseInt without checking if they are defined or empty can result in NaN values being passed to the ChatOpenAI constructor, which can cause runtime errors or API validation failures. Additionally, using simple truthiness checks like if (frequencyPenalty) will incorrectly ignore valid 0 values. Using a nullish check (!= null) ensures that 0 is correctly preserved while safely ignoring empty or undefined values.
const obj: ChatOpenAIFields = {
modelName,
openAIApiKey: agioneApiKey,
apiKey: agioneApiKey,
streaming: streaming ?? true
}
if (temperature != null && temperature !== '') {
obj.temperature = parseFloat(temperature)
}
if (maxTokens != null && maxTokens !== '') {
obj.maxTokens = parseInt(maxTokens, 10)
}
if (topP != null && topP !== '') {
obj.topP = parseFloat(topP)
}
if (frequencyPenalty != null && frequencyPenalty !== '') {
obj.frequencyPenalty = parseFloat(frequencyPenalty)
}
if (presencePenalty != null && presencePenalty !== '') {
obj.presencePenalty = parseFloat(presencePenalty)
}
if (cache) obj.cache = cacheReferences
- In JavaScript/TypeScript, use loose equality (
== null) as a standard idiom for a 'nullish' check that covers bothnullandundefined.
| let parsedBaseOptions: any | undefined = undefined | ||
|
|
||
| if (baseOptions) { | ||
| try { | ||
| parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions) | ||
| if (parsedBaseOptions.baseURL) { | ||
| console.warn("The 'baseURL' parameter is not allowed when using the ChatAGIone node.") | ||
| parsedBaseOptions.baseURL = undefined | ||
| } | ||
| } catch (exception) { | ||
| throw new Error('Invalid JSON in the BaseOptions: ' + exception) | ||
| } | ||
| } |
There was a problem hiding this comment.
If baseOptions is null or parses to null (since typeof null === 'object'), parsedBaseOptions will be null. Accessing parsedBaseOptions.baseURL directly will then throw a TypeError. Adding a nullish and type check ensures that we only access properties on valid, non-null objects.
| let parsedBaseOptions: any | undefined = undefined | |
| if (baseOptions) { | |
| try { | |
| parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions) | |
| if (parsedBaseOptions.baseURL) { | |
| console.warn("The 'baseURL' parameter is not allowed when using the ChatAGIone node.") | |
| parsedBaseOptions.baseURL = undefined | |
| } | |
| } catch (exception) { | |
| throw new Error('Invalid JSON in the BaseOptions: ' + exception) | |
| } | |
| } | |
| let parsedBaseOptions: any | undefined = undefined | |
| if (baseOptions) { | |
| try { | |
| parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions) | |
| if (parsedBaseOptions && typeof parsedBaseOptions === 'object' && 'baseURL' in parsedBaseOptions) { | |
| console.warn("The 'baseURL' parameter is not allowed when using the ChatAGIone node.") | |
| parsedBaseOptions.baseURL = undefined | |
| } | |
| } catch (exception) { | |
| throw new Error('Invalid JSON in the BaseOptions: ' + exception) | |
| } | |
| } |
b2410b3 to
a261373
Compare
|
Addressed the review feedback in a261373:
Also re-ran formatting and a focused TypeScript syntax check. |
Description
Adds AGIone as a Flowise chat model node using the OpenAI-compatible Chat endpoint.
This PR adds:
ChatAGIoneunderpackages/components/nodes/chatmodels/ChatAGIoneAGIoneApicredential for AGIone Auth Token inputhttps://agione.pro/hyperone/xapi/api/v1openai/GPT-5.5/c6fbeThe implementation follows the existing OpenAI-compatible provider pattern used by nodes such as
ChatCometAPI: it wraps LangChainChatOpenAI, sets the provider base URL, and prevents overridingbaseURLthrough Base Options.Submitted by the AGIone team.
Tests
Credential scan on the committed diff:
Output: