mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
🔧 fix: Upload Audio as Text missing Param (#9356)
This commit is contained in:
parent
b75b799e34
commit
7742b18c9c
4 changed files with 23 additions and 8 deletions
|
@ -616,7 +616,7 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
|
||||||
|
|
||||||
if (shouldUseSTT) {
|
if (shouldUseSTT) {
|
||||||
const sttService = await STTService.getInstance();
|
const sttService = await STTService.getInstance();
|
||||||
const { text, bytes } = await processAudioFile({ file, sttService });
|
const { text, bytes } = await processAudioFile({ req, file, sttService });
|
||||||
return await createTextFile({ text, bytes });
|
return await createTextFile({ text, bytes });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { logger } from '@librechat/data-schemas';
|
import { logger } from '@librechat/data-schemas';
|
||||||
import type { STTService, AudioFileInfo, FileObject, AudioProcessingResult } from '~/types';
|
import type {
|
||||||
|
AudioProcessingResult,
|
||||||
|
ServerRequest,
|
||||||
|
AudioFileInfo,
|
||||||
|
STTService,
|
||||||
|
FileObject,
|
||||||
|
} from '~/types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes audio files using Speech-to-Text (STT) service.
|
* Processes audio files using Speech-to-Text (STT) service.
|
||||||
* @param {Object} params - The parameters object.
|
* @returns A promise that resolves to an object containing text and bytes.
|
||||||
* @param {FileObject} params.file - The audio file object.
|
|
||||||
* @param {STTService} params.sttService - The STT service instance.
|
|
||||||
* @returns {Promise<AudioProcessingResult>} A promise that resolves to an object containing text and bytes.
|
|
||||||
*/
|
*/
|
||||||
export async function processAudioFile({
|
export async function processAudioFile({
|
||||||
|
req,
|
||||||
file,
|
file,
|
||||||
sttService,
|
sttService,
|
||||||
}: {
|
}: {
|
||||||
|
req: ServerRequest;
|
||||||
file: FileObject;
|
file: FileObject;
|
||||||
sttService: STTService;
|
sttService: STTService;
|
||||||
}): Promise<AudioProcessingResult> {
|
}): Promise<AudioProcessingResult> {
|
||||||
|
@ -24,7 +29,7 @@ export async function processAudioFile({
|
||||||
size: file.size,
|
size: file.size,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [provider, sttSchema] = await sttService.getProviderSchema();
|
const [provider, sttSchema] = await sttService.getProviderSchema(req);
|
||||||
const text = await sttService.sttRequest(provider, sttSchema, { audioBuffer, audioFile });
|
const text = await sttService.sttRequest(provider, sttSchema, { audioBuffer, audioFile });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import type { ServerRequest } from './http';
|
||||||
export interface STTService {
|
export interface STTService {
|
||||||
getInstance(): Promise<STTService>;
|
getInstance(): Promise<STTService>;
|
||||||
getProviderSchema(): Promise<[string, object]>;
|
getProviderSchema(req: ServerRequest): Promise<[string, object]>;
|
||||||
sttRequest(
|
sttRequest(
|
||||||
provider: string,
|
provider: string,
|
||||||
schema: object,
|
schema: object,
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import type { Request } from 'express';
|
||||||
|
import type { IUser } from '@librechat/data-schemas';
|
||||||
|
import type { AppConfig } from './config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LibreChat-specific request body type that extends Express Request body
|
* LibreChat-specific request body type that extends Express Request body
|
||||||
* (have to use type alias because you can't extend indexed access types like Request['body'])
|
* (have to use type alias because you can't extend indexed access types like Request['body'])
|
||||||
|
@ -7,3 +11,8 @@ export type RequestBody = {
|
||||||
conversationId?: string;
|
conversationId?: string;
|
||||||
parentMessageId?: string;
|
parentMessageId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ServerRequest = Request & {
|
||||||
|
user?: IUser;
|
||||||
|
config?: AppConfig;
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue