Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default defineTool({
renderTypeList: [FlowNodeInputTypeEnum.select, FlowNodeInputTypeEnum.reference],
valueType: WorkflowIOValueTypeEnum.string,
required: false,
defaultValue: '',
list: [
{ label: '自动', value: '' },
{ label: '高兴', value: 'happy' },
{ label: '悲伤', value: 'sad' },
{ label: '愤怒', value: 'angry' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { z } from 'zod';
import { POST } from '@tool/utils/request';
import { uploadFile } from '@tool/utils/uploadFile';
import { ErrorCodeMap } from '@tool/packages/minmax/constants';
import { ErrorCodeMap } from '@tool/packages/minimax/constants';

export const InputType = z.object({
apiKey: z.string(),
apiKey: z.string().nonempty(),
text: z.string().nonempty(),
model: z.string().nonempty(),
voice_id: z.string(),
speed: z.number(),
vol: z.number(),
pitch: z.number(),
emotion: z.string(),
speed: z.number().min(0.5).max(2),
vol: z.number().min(0.1).max(10),
pitch: z.number().min(-12).max(12),
emotion: z.enum(['', 'happy', 'sad', 'angry', 'fearful', 'disgusted', 'surprised', 'calm']),
english_normalization: z.boolean()
});

Expand Down Expand Up @@ -49,15 +49,15 @@ export async function tool({
speed,
vol,
pitch,
emotion,
...(emotion && { emotion }),
english_normalization
}
},
{
headers
}
);
console.log(syncData, 223232);

if (syncData.base_resp.status_code !== 0) {
return Promise.reject(
ErrorCodeMap[syncData.base_resp.status_code as keyof typeof ErrorCodeMap]
Expand Down
26 changes: 26 additions & 0 deletions modules/tool/packages/minimax/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineToolSet } from '@tool/type';
import { ToolTypeEnum } from '@tool/type/tool';

export default defineToolSet({
name: {
'zh-CN': 'minimax 工具集',
en: 'minimax Tool Set'
},
courseUrl: 'https://platform.minimaxi.com/document/quick_start',
type: ToolTypeEnum.tools,
description: {
'zh-CN': 'minimax 工具集, 包含文本转语音、语音转文本、语音合成、语音识别等功能',
en: 'minimax tool set, including text-to-speech, speech-to-text, speech synthesis, speech recognition等功能'
},
toolDescription:
'minimax tool set, including text-to-speech, speech-to-text, speech synthesis, speech recognition等功能',
secretInputConfig: [
{
key: 'apiKey',
label: 'API Key',
description: '可以在 minimax 官网获取',
required: true,
inputType: 'secret'
}
]
});
26 changes: 0 additions & 26 deletions modules/tool/packages/minmax/config.ts

This file was deleted.

44 changes: 30 additions & 14 deletions modules/tool/utils/uploadFile.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
import { fileUploadS3Server } from '@/s3';
import type { FileMetadata } from '@/s3/config';
import type { FileInput } from '@/s3/type';
import { parentPort } from 'worker_threads';

export const uploadFile = async (data: FileInput) => {
return new Promise<FileMetadata>((resolve, reject) => {
global.uploadFileResponseFn = ({ data, error }) => {
if (error) {
reject(error);
} else if (data) {
resolve(data);
} else {
reject('Unknow error');
}
};
parentPort?.postMessage({
type: 'uploadFile',
data
// 判断是否在 worker 线程中
const isWorkerThread = typeof parentPort !== 'undefined' && parentPort !== null;

if (isWorkerThread) {
// 在 worker 线程中,通过 parentPort 发送消息
return new Promise<FileMetadata>((resolve, reject) => {
const timer = setTimeout(() => {
reject('Upload file timeout');
}, 120000);
global.uploadFileResponseFn = ({ data, error }) => {
clearTimeout(timer);
if (error) {
reject(error);
} else if (data) {
resolve(data);
} else {
reject('Unknow error');
}
};
parentPort?.postMessage({
type: 'uploadFile',
data
});
});
} else {
return await fileUploadS3Server.uploadFileAdvanced({
...data,
...(data.buffer ? { buffer: Buffer.from(data.buffer) } : {})
});
});
}
};