🔧 fix: Upload Audio as Text missing Param (#9356)

This commit is contained in:
Danny Avila 2025-08-28 21:07:30 -04:00 committed by GitHub
parent b75b799e34
commit 7742b18c9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 8 deletions

View file

@ -616,7 +616,7 @@ const processAgentFileUpload = async ({ req, res, metadata }) => {
if (shouldUseSTT) {
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 });
}

View file

@ -1,18 +1,23 @@
import fs from 'fs';
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.
* @param {Object} params - The parameters object.
* @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.
* @returns A promise that resolves to an object containing text and bytes.
*/
export async function processAudioFile({
req,
file,
sttService,
}: {
req: ServerRequest;
file: FileObject;
sttService: STTService;
}): Promise<AudioProcessingResult> {
@ -24,7 +29,7 @@ export async function processAudioFile({
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 });
return {

View file

@ -1,6 +1,7 @@
import type { ServerRequest } from './http';
export interface STTService {
getInstance(): Promise<STTService>;
getProviderSchema(): Promise<[string, object]>;
getProviderSchema(req: ServerRequest): Promise<[string, object]>;
sttRequest(
provider: string,
schema: object,

View file

@ -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
* (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;
parentMessageId?: string;
};
export type ServerRequest = Request & {
user?: IUser;
config?: AppConfig;
};