Skip to content

feat: add MiniMax chat model and TTS support#5891

Open
ximiximi423 wants to merge 3 commits intoFlowiseAI:mainfrom
ximiximi423:feat/add-minimax-chatmodel
Open

feat: add MiniMax chat model and TTS support#5891
ximiximi423 wants to merge 3 commits intoFlowiseAI:mainfrom
ximiximi423:feat/add-minimax-chatmodel

Conversation

@ximiximi423
Copy link

  • Add ChatMiniMax node with FlowiseChatMiniMax integration
  • Add MiniMax api credential definition
  • Update models.json with MiniMax model list
  • Add MiniMax TTS support in textToSpeech.ts

- Add ChatMiniMax node with FlowiseChatMiniMax integration
- Add MiniMaxApi credential definition
- Update models.json with MiniMax model list
- Add MiniMax TTS support in textToSpeech.ts

Made-with: Cursor
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the platform's capabilities by integrating MiniMax's AI services. It introduces support for MiniMax chat models, allowing users to leverage their LLMs, and adds robust text-to-speech functionality powered by MiniMax. These additions provide more options for conversational AI and audio generation within the system.

Highlights

  • MiniMax Chat Model Integration: A new ChatMiniMax node has been added, allowing users to integrate MiniMax large language models into their workflows. This includes a custom wrapper for MiniMax's Anthropic-compatible API.
  • MiniMax API Credential: A dedicated credential definition for MiniMax API keys has been introduced, ensuring secure handling of API access.
  • Model List Update: The models.json file has been updated to include MiniMax chat models, specifically MiniMax-M2.5 and MiniMax-M2.5-highspeed, along with their associated input and output costs.
  • MiniMax Text-to-Speech (TTS) Support: Text-to-Speech functionality has been extended to support MiniMax, enabling conversion of text to audio streams using MiniMax's TTS API, complete with voice selection and streaming capabilities.
Changelog
  • packages/components/credentials/MiniMaxApi.credential.ts
    • Added a new credential definition for MiniMax API Key.
  • packages/components/models.json
    • Integrated MiniMax chat models (MiniMax-M2.5, MiniMax-M2.5-highspeed) with their respective input/output costs.
  • packages/components/nodes/chatmodels/ChatMiniMax/ChatMiniMax.ts
    • Implemented a new ChatMiniMax node for Flowise, allowing integration with MiniMax LLMs.
  • packages/components/nodes/chatmodels/ChatMiniMax/FlowiseChatMiniMax.ts
    • Created a custom ChatMiniMax class extending LangchainChatAnthropic to adapt MiniMax's Anthropic-compatible API, handling topP/topK parameters.
  • packages/components/nodes/chatmodels/ChatMiniMax/minimax.svg
    • Added an SVG icon for the MiniMax chat model node.
  • packages/components/src/textToSpeech.ts
    • Added MINIMAX_TTS type to the TextToSpeechType enum.
    • Implemented streaming text-to-speech conversion logic for MiniMax API, including error handling and SSE parsing.
    • Added a list of supported English voices for MiniMax TTS.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 support for MiniMax chat models and Text-to-Speech services. The changes include adding a new credential type for MiniMax, a new chat model node, and integrating MiniMax TTS into the existing text-to-speech functionality. The implementation is solid, but I've identified a few areas for improvement. Specifically, there's a potential runtime issue with how the temperature parameter is handled in the new chat model, a misleading type assertion, and a potential bug in the Server-Sent Events (SSE) stream processing for TTS that could result in incomplete audio. I've included suggestions to address these points.

Comment on lines +102 to +111
const obj: ChatMiniMaxInput = {
temperature: parseFloat(temperature),
modelName,
miniMaxApiKey,
streaming: streaming ?? true
}

if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (topP) obj.topP = parseFloat(topP)
if (cache) obj.cache = cache
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The temperature parameter is being unconditionally parsed and assigned. If a user clears this optional field in the UI, temperature could be undefined or an empty string. In both cases, parseFloat(temperature) would result in NaN, which is then passed to the model constructor. This is likely to cause a runtime error when making an API call. To prevent this, you should handle temperature conditionally, similar to how maxTokens and topP are handled.

Suggested change
const obj: ChatMiniMaxInput = {
temperature: parseFloat(temperature),
modelName,
miniMaxApiKey,
streaming: streaming ?? true
}
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (topP) obj.topP = parseFloat(topP)
if (cache) obj.cache = cache
const obj: ChatMiniMaxInput = {
modelName,
miniMaxApiKey,
streaming: streaming ?? true
}
if (temperature) obj.temperature = parseFloat(temperature)
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (topP) obj.topP = parseFloat(topP)
if (cache) obj.cache = cache

Copy link
Author

Choose a reason for hiding this comment

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

fixed


revertToOriginalModel(): void {
this.modelName = this.configuredModel
this.maxTokens = this.configuredMaxToken as number
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The as number type assertion here is unnecessary and potentially misleading. The configuredMaxToken property is of type number | undefined, and the this.maxTokens property on the parent class also accepts undefined. At runtime, if configuredMaxToken is undefined, this cast will not prevent undefined from being assigned, but it suppresses TypeScript's type checking and could confuse future maintainers. Removing the cast improves clarity and type safety.

Suggested change
this.maxTokens = this.configuredMaxToken as number
this.maxTokens = this.configuredMaxToken

Copy link
Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +199 to +201
if (eventData.data?.status === 2) {
break
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The break statement here exits the inner loop that processes Server-Sent Events (SSE) lines from the current data chunk. If there are more messages in the same chunk after the one with data.status === 2, they will be skipped, and the code will proceed to read the next chunk from the stream. This could lead to missed audio data if the provider sends more data in the same chunk. It's safer to remove this break and let the loop process all lines in the current buffer. The outer loop will terminate correctly when the stream is closed and reader.read() returns { done: true }.

- Make temperature conditional to avoid NaN when field is empty
- Remove unnecessary 'as number' cast in revertToOriginalModel
- Remove premature break in SSE loop to avoid missing audio chunks

Made-with: Cursor
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