Skip to content

Add AGIone chat model#6485

Open
KaiShaoCheng wants to merge 2 commits into
FlowiseAI:mainfrom
KaiShaoCheng:provider-add-agione
Open

Add AGIone chat model#6485
KaiShaoCheng wants to merge 2 commits into
FlowiseAI:mainfrom
KaiShaoCheng:provider-add-agione

Conversation

@KaiShaoCheng
Copy link
Copy Markdown

@KaiShaoCheng KaiShaoCheng commented Jun 6, 2026

Description

Adds AGIone as a Flowise chat model node using the OpenAI-compatible Chat endpoint.

This PR adds:

  • ChatAGIone under packages/components/nodes/chatmodels/ChatAGIone
  • AGIoneApi credential for AGIone Auth Token input
  • Default base URL: https://agione.pro/hyperone/xapi/api/v1
  • Default model: openai/GPT-5.5/c6fbe
  • Example model IDs for AGIone-hosted OpenAI, Anthropic, and DeepSeek models

The implementation follows the existing OpenAI-compatible provider pattern used by nodes such as ChatCometAPI: it wraps LangChain ChatOpenAI, sets the provider base URL, and prevents overriding baseURL through Base Options.

Submitted by the AGIone team.

Tests

pnpm install --ignore-scripts
cd packages/components
NODE_OPTIONS='--max-old-space-size=1536' pnpm build
> flowise-components@3.1.2 build
> tsc && gulp

[16:57:40] Requiring external module ts-node/register
[16:57:44] Using gulpfile /tmp/agione-flowise-verify/packages/components/gulpfile.ts
[16:57:44] Starting 'default'...
[16:57:45] Finished 'default' after 447 ms
pnpm prettier --check \
  packages/components/nodes/chatmodels/ChatAGIone/ChatAGIone.ts \
  packages/components/credentials/AGIoneApi.credential.ts
All matched files use Prettier code style!

Credential scan on the committed diff:

git diff upstream/main..HEAD | grep -E 'ak-[A-Za-z0-9_-]{12,}|sk-[A-Za-z0-9_-]{12,}|Bearer [A-Za-z0-9._-]{12,}' || echo clean

Output:

clean

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 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.

Comment on lines +136 to +148
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
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

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 = cache
References
  1. In JavaScript/TypeScript, use loose equality (== null) as a standard idiom for a 'nullish' check that covers both null and undefined.

Comment on lines +150 to +162
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)
}
}
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

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.

Suggested change
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)
}
}

@KaiShaoCheng KaiShaoCheng force-pushed the provider-add-agione branch from b2410b3 to a261373 Compare June 6, 2026 11:46
@KaiShaoCheng
Copy link
Copy Markdown
Author

Addressed the review feedback in a261373:

  • optional numeric params are now only forwarded when explicitly provided and valid, preserving 0 values
  • baseOptions parsing now guards against null / non-object values before reading baseURL

Also re-ran formatting and a focused TypeScript syntax check.

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