Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

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

Danny Avila7742b18c9cf4
diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.js
index d7864077e6..d8061fb68e 100644
--- a/api/server/services/Files/process.js
+++ b/api/server/services/Files/process.js
@@ -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 });
}
diff --git a/packages/api/src/files/audio.ts b/packages/api/src/files/audio.ts
index 27e25260cc..a2d93c1002 100644
--- a/packages/api/src/files/audio.ts
+++ b/packages/api/src/files/audio.ts
@@ -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 {
diff --git a/packages/api/src/types/files.ts b/packages/api/src/types/files.ts
index b0540a8d26..4bfcc23e46 100644
--- a/packages/api/src/types/files.ts
+++ b/packages/api/src/types/files.ts
@@ -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,
diff --git a/packages/api/src/types/http.ts b/packages/api/src/types/http.ts
index 972a48e44d..585797fe9c 100644
--- a/packages/api/src/types/http.ts
+++ b/packages/api/src/types/http.ts
@@ -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;
+};