feat(tools): add CAMB AI integration with 8 tool nodes#5829
feat(tools): add CAMB AI integration with 8 tool nodes#5829neilruaro-camb wants to merge 1 commit intoFlowiseAI:mainfrom
Conversation
Summary of ChangesHello @neilruaro-camb, 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 integrates a comprehensive suite of CAMB AI's audio and language processing tools into the platform. It provides users with new capabilities for text translation, text-to-speech, audio transcription, voice cloning, and audio separation. The changes include the addition of a new credential type for managing API keys and a robust set of shared helper functions to facilitate seamless interaction with the CAMB AI API. Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive integration with CAMB AI by adding a new API credential, eight tool nodes for various AI-powered audio and text operations, and a shared core.ts module for API interactions. The overall implementation is well-structured and follows good practices. The identified opportunities to improve error handling in the CambVoiceClone tool and the minor refactoring in the core.ts helper file are valid and have been kept. The rest of the new nodes are well-implemented.
| try { | ||
| params = JSON.parse(input) | ||
| } catch { | ||
| return JSON.stringify({ error: 'Input must be JSON with voice_name and audio_file_path' }) | ||
| } |
There was a problem hiding this comment.
When JSON parsing fails, the function returns a JSON string indicating an error. It's better practice for tools to throw an Error in such cases. This allows the framework or agent using the tool to catch the exception and handle the failure state correctly, rather than potentially misinterpreting the returned string as a successful result.
| try { | |
| params = JSON.parse(input) | |
| } catch { | |
| return JSON.stringify({ error: 'Input must be JSON with voice_name and audio_file_path' }) | |
| } | |
| try { | |
| params = JSON.parse(input) | |
| } catch (e) { | |
| throw new Error('Input must be a valid JSON string with "voice_name" and "audio_file_path" fields.') | |
| } |
| if (!fs.existsSync(filePath)) { | ||
| return JSON.stringify({ error: `Audio file not found: ${filePath}` }) | ||
| } |
There was a problem hiding this comment.
When the specified audio file is not found, the function returns an error message within a JSON string. For better error handling and to align with standard tool behavior, it's preferable to throw an Error. This ensures that the calling agent can properly recognize and manage the failure.
| if (!fs.existsSync(filePath)) { | |
| return JSON.stringify({ error: `Audio file not found: ${filePath}` }) | |
| } | |
| if (!fs.existsSync(filePath)) { | |
| throw new Error(`Audio file not found at path: ${filePath}`) | |
| } |
| if (status === 'SUCCESS' || status === 'completed' || status === 'complete') { | ||
| return data | ||
| } | ||
| if (status === 'FAILED' || status === 'ERROR' || status === 'TIMEOUT' || status === 'PAYMENT_REQUIRED' || status === 'error' || status === 'failed') { | ||
| throw new Error(`CAMB AI task failed: ${data.exception_reason || data.error || 'Unknown error'}`) | ||
| } |
There was a problem hiding this comment.
The multiple || conditions for status checking can be simplified by using arrays and the includes method. This improves readability and makes it easier to add or remove statuses in the future.
const successStates = ['SUCCESS', 'completed', 'complete']
if (successStates.includes(status)) {
return data
}
const failureStates = ['FAILED', 'ERROR', 'TIMEOUT', 'PAYMENT_REQUIRED', 'error', 'failed']
if (failureStates.includes(status)) {
throw new Error(`CAMB AI task failed: ${data.exception_reason || data.error || 'Unknown error'}`)
}
Summary
core.tswith authenticated fetch, JSON POST, multipart upload, task polling, and TTS streaming helpersNew Files
packages/components/credentials/CambAIApi.credential.ts— API key credentialpackages/components/nodes/tools/CambAI/core.ts— shared HTTP helperspackages/components/nodes/tools/CambAI/Camb*.ts— 8 tool node definitionspackages/components/nodes/tools/CambAI/camb-ai.svg— node icon