Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

♻️ refactor(tts): replace legacy webapi route with model runtime (#21084)

Bryand9e9dabcd731
diff --git a/.agents/skills/cli/references/generate.md b/.agents/skills/cli/references/generate.md
index 419d3721efe..5fb223b95ee 100644
--- a/.agents/skills/cli/references/generate.md
+++ b/.agents/skills/cli/references/generate.md
@@ -172,15 +172,19 @@ Text-to-speech generation.
**Source**: `apps/cli/src/commands/generate/tts.ts`
```bash
-lh gen tts <text> [-o <file>] [--voice <voice>] [--speed <n>] [--model <model>]
+lh gen tts <text> [-o <file>] [--voice <voice>] [--speed <n>] [-m <model>] [-p <provider>]
```
-| Option | Description | Default |
-| --------------------- | --------------------------- | ------------ |
-| `-o, --output <file>` | Output audio file path | `output.mp3` |
-| `--voice <voice>` | Voice name | `alloy` |
-| `--speed <n>` | Speed multiplier (0.25-4.0) | `1` |
-| `--model <model>` | TTS model | `tts-1` |
+| Option | Description | Default |
+| --------------------------- | ---------------------------------------- | ------------ |
+| `-o, --output <file>` | Output audio file path | `output.mp3` |
+| `--voice <voice>` | Voice name | `alloy` |
+| `--speed <n>` | Speed multiplier (0.25-4.0) | `1` |
+| `-m, --model <model>` | Model ID (`provider/model` supported) | `tts-1` |
+| `-p, --provider <provider>` | Provider (derived from model if omitted) | `openai` |
+
+Uses the selected provider's saved configuration through ModelRuntime, with the same
+authenticated tRPC client as `lh gen asr`.
---
diff --git a/apps/cli/src/commands/generate.test.ts b/apps/cli/src/commands/generate.test.ts
index 371b4269926..9997aaa82c9 100644
--- a/apps/cli/src/commands/generate.test.ts
+++ b/apps/cli/src/commands/generate.test.ts
@@ -38,10 +38,6 @@ const { getAuthInfo: mockGetAuthInfo } = vi.hoisted(() => ({
getAuthInfo: vi.fn(),
}));
-const { writeFileSync: mockWriteFileSync } = vi.hoisted(() => ({
- writeFileSync: vi.fn(),
-}));
-
const { uploadLocalFile: mockUploadLocalFile } = vi.hoisted(() => ({
uploadLocalFile: vi.fn(),
}));
@@ -53,10 +49,6 @@ vi.mock('../utils/uploadLocalFile', async (importOriginal) => {
vi.mock('../api/client', () => ({ getTrpcClient: mockGetTrpcClient }));
vi.mock('../api/http', () => ({ getAuthInfo: mockGetAuthInfo }));
-vi.mock('node:fs', async (importOriginal) => {
- const actual: Record<string, unknown> = await importOriginal();
- return { ...actual, writeFileSync: mockWriteFileSync };
-});
describe('generate command', () => {
let exitSpy: ReturnType<typeof vi.spyOn>;
let consoleSpy: ReturnType<typeof vi.spyOn>;
@@ -479,37 +471,6 @@ describe('generate command', () => {
});
});
- describe('tts', () => {
- it('should call OpenAI TTS endpoint and save file', async () => {
- const audioBuffer = new ArrayBuffer(100);
- vi.stubGlobal(
- 'fetch',
- vi.fn().mockResolvedValue({
- arrayBuffer: vi.fn().mockResolvedValue(audioBuffer),
- ok: true,
- }),
- );
-
- const program = createProgram();
- await program.parseAsync([
- 'node',
- 'test',
- 'generate',
- 'tts',
- 'Hello world',
- '--output',
- '/tmp/test.mp3',
- ]);
-
- expect(fetch).toHaveBeenCalledWith(
- 'https://app.lobehub.com/webapi/tts/openai',
- expect.objectContaining({ method: 'POST' }),
- );
- expect(mockWriteFileSync).toHaveBeenCalledWith('/tmp/test.mp3', expect.any(Buffer));
- expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('Audio saved'));
- });
- });
-
describe('asr', () => {
it('should exit when file not found', async () => {
const program = createProgram();
diff --git a/apps/cli/src/commands/generate/tts.ts b/apps/cli/src/commands/generate/tts.ts
index 857ab6b29a2..3f80e1fc733 100644
--- a/apps/cli/src/commands/generate/tts.ts
+++ b/apps/cli/src/commands/generate/tts.ts
@@ -1,10 +1,9 @@
-import { writeFileSync } from 'node:fs';
+import { writeFile } from 'node:fs/promises';
import type { Command } from 'commander';
import pc from 'picocolors';
-import { getAuthInfo } from '../../api/http';
-import { log } from '../../utils/logger';
+import { getTrpcClient } from '../../api/client';
export function registerTtsCommand(parent: Command) {
parent
@@ -13,45 +12,34 @@ export function registerTtsCommand(parent: Command) {
.option('-o, --output <file>', 'Output audio file path', 'output.mp3')
.option('--voice <voice>', 'Voice name', 'alloy')
.option('--speed <n>', 'Speed multiplier (0.25-4.0)', '1')
- .option('--model <model>', 'TTS model', 'tts-1')
+ .option('-m, --model <model>', 'Model ID (provider/model format)', 'tts-1')
+ .option('-p, --provider <provider>', 'Provider name (derived from model if omitted)')
.action(
async (
text: string,
options: {
model: string;
output: string;
+ provider?: string;
speed: string;
voice: string;
},
) => {
- const { serverUrl, headers } = await getAuthInfo();
+ const parts = options.model.split('/');
+ const provider = options.provider || (parts.length > 1 ? parts[0] : 'openai');
+ const model = parts.length > 1 ? parts.slice(1).join('/') : options.model;
+ const client = await getTrpcClient();
- const payload: Record<string, any> = {
+ const result = await client.tts.synthesize.mutate({
input: text,
- model: options.model,
- options: {
- model: options.model,
- voice: options.voice,
- },
+ model,
+ provider,
speed: Number.parseFloat(options.speed),
voice: options.voice,
- };
-
- const res = await fetch(`${serverUrl}/webapi/tts/openai`, {
- body: JSON.stringify(payload),
- headers,
- method: 'POST',
});
- if (!res.ok) {
- const errText = await res.text();
- log.error(`TTS failed: ${res.status} ${errText}`);
- process.exit(1);
- return;
- }
-
- const buffer = Buffer.from(await res.arrayBuffer());
- writeFileSync(options.output, buffer);
+ const buffer = Buffer.from(result.audioBase64, 'base64');
+ await writeFile(options.output, buffer);
console.log(
`${pc.green('✓')} Audio saved to ${pc.bold(options.output)} (${Math.round(buffer.length / 1024)}KB)`,
);
diff --git a/apps/server/src/routers/lambda/index.ts b/apps/server/src/routers/lambda/index.ts
index 3fd4c617365..ca2ba243879 100644
--- a/apps/server/src/routers/lambda/index.ts
+++ b/apps/server/src/routers/lambda/index.ts
@@ -99,6 +99,7 @@ import { threadRouter } from './thread';
import { topicRouter } from './topic';
import { topicCommentRouter } from './topicComment';
import { trashRouter } from './trash';
+import { ttsRouter } from './tts';
import { uploadRouter } from './upload';
import { usageRouter } from './usage';
import { userRouter } from './user';
@@ -138,6 +139,7 @@ export const lambdaRouter = router({
aiProvider: aiProviderRouter,
apiKey: apiKeyRouter,
asr: asrRouter,
+ tts: ttsRouter,
chunk: chunkRouter,
comfyui: comfyuiRouter,
config: configRouter,
diff --git a/apps/server/src/routers/lambda/tts.ts b/apps/server/src/routers/lambda/tts.ts
new file mode 100644
index 00000000000..f8e8da84f0a
--- /dev/null
+++ b/apps/server/src/routers/lambda/tts.ts
@@ -0,0 +1,45 @@
+import { TRPCError } from '@trpc/server';
+import { z } from 'zod';
+
+import {
+ requireWorkspaceRoleWhenScoped,
+ wsCompatProcedure,
+} from '@/business/server/trpc-middlewares/workspaceAuth';
+import { router } from '@/libs/trpc/lambda';
+import { serverDatabase } from '@/libs/trpc/lambda/middleware';
+import { initModelRuntimeFromDB } from '@/server/modules/ModelRuntime';
+
+const synthesizeInput = z.object({
+ input: z.string().min(1),
+ model: z.string().min(1),
+ provider: z.string().min(1).default('openai'),
+ speed: z.number().min(0.25).max(4).optional(),
+ voice: z.string().min(1).default('alloy'),
+});
+
+const ttsProcedure = wsCompatProcedure
+ .use(serverDatabase)
+ .use(requireWorkspaceRoleWhenScoped('member'));
+
+export const ttsRouter = router({
+ synthesize: ttsProcedure.input(synthesizeInput).mutation(async ({ ctx, input }) => {
+ const { provider, ...payload } = input;
+ const runtime = await initModelRuntimeFromDB(
+ ctx.serverDB,
+ ctx.userId,
+ provider,
+ ctx.workspaceId ?? undefined,
+ );
+
+ const audio = await runtime.textToSpeech(payload, { user: ctx.userId });
+
+ if (!audio) {
+ throw new TRPCError({
+ code: 'NOT_IMPLEMENTED',
+ message: `Provider "${provider}" does not support text-to-speech.`,
+ });
+ }
+
+ return { audioBase64: Buffer.from(audio).toString('base64') };
+ }),
+});
diff --git a/apps/server/src/utils/createSpeechResponse.ts b/apps/server/src/utils/createSpeechResponse.ts
deleted file mode 100644
index d164a87b0c1..00000000000
--- a/apps/server/src/utils/createSpeechResponse.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { ChatErrorType } from '@lobechat/types';
-
-import { createErrorResponse } from '@/utils/errorResponse';
-import { createNodeResponse } from '@/utils/server/response';
-
-export interface CreateSpeechResponseOptions {
- errorContentType?: string;
- logTag: string;
- messages?: {
- failure?: string;
- invalid?: string;
- };
- successContentType?: string;
-}
-
-/**
- * Wraps a third-party speech SDK response so the Node.js runtime always receives
- * a valid platform Response, while keeping logging and error handling consistent.
- */
-export const createSpeechResponse = async <T>(
- responseCreator: () => Promise<T>,
- {
- logTag,
- successContentType = 'audio/mpeg',
- errorContentType = 'application/json',
- messages,
- }: CreateSpeechResponseOptions,
-) => {
- const prefix = `[${logTag}]`;
- const invalidMessage = messages?.invalid ?? 'Unexpected payload from speech provider';
- const failureMessage = messages?.failure ?? 'Failed to synthesize speech';
-
- return createNodeResponse(responseCreator, {
- error: {
- cacheControl: 'no-store',
- defaultContentType: errorContentType,
- },
- onInvalidResponse: (response) => {
- console.error(`${prefix} ${invalidMessage}`, response);
-
- return createErrorResponse(ChatErrorType.InternalServerError);
- },
- onNonResponseError: (error) => {
- console.error(`${prefix} ${failureMessage}`, error);
-
- return createErrorResponse(ChatErrorType.InternalServerError, {
- message: error instanceof Error ? error.message : String(error),
- });
- },
- success: {
- cacheControl: 'no-store',
- defaultContentType: successContentType,
- },
- });
-};
diff --git a/package.json b/package.json
index 5ea82cc8842..65669d40033 100644
--- a/package.json
+++ b/package.json
@@ -325,7 +325,6 @@
"@lobehub/editor": "^5.0.0",
"@lobehub/icons": "^6.0.0",
"@lobehub/market-sdk": "0.42.0",
- "@lobehub/tts": "^6.0.0",
"@lobehub/ui": "^6.0.4",
"@modelcontextprotocol/sdk": "^1.30.0",
"@neondatabase/serverless": "^1.1.0",
diff --git a/packages/builtin-skills/src/lobehub/references/generate.ts b/packages/builtin-skills/src/lobehub/references/generate.ts
index 3017c0f4823..f6c0df88f05 100644
--- a/packages/builtin-skills/src/lobehub/references/generate.ts
+++ b/packages/builtin-skills/src/lobehub/references/generate.ts
@@ -7,7 +7,7 @@ Generate text, images, videos, and audio. Alias: \`lh generate\`.
- \`lh gen text <prompt> [-m <model>] [-p <provider>] [--stream] [--temperature <t>]\` - Generate text
- \`lh gen image <prompt> [-m <model>] [-n <count>] [--width <w>] [--height <h>]\` - Generate image
- \`lh gen video <prompt> -m <model> -p <provider> [--aspect-ratio <r>] [--duration <d>] [--resolution <res>]\` - Generate video
-- \`lh gen tts <text> [-o <output>] [--voice <v>] [--speed <s>]\` - Text-to-speech
+- \`lh gen tts <text> [-m <model>] [-p <provider>] [-o <output>] [--voice <v>] [--speed <s>]\` - Text-to-speech using the selected provider's saved configuration
- \`lh gen asr <audioFile> [--model <m>] [--language <l>]\` - Speech-to-text
- \`lh gen status <generationId> <asyncTaskId>\` - Check generation task status
- \`lh gen download <generationId> <asyncTaskId> [-o <output>]\` - Wait and download result
diff --git a/packages/const/src/apiKeyScope.ts b/packages/const/src/apiKeyScope.ts
index 88c2a67185f..13b609317bd 100644
--- a/packages/const/src/apiKeyScope.ts
+++ b/packages/const/src/apiKeyScope.ts
@@ -296,6 +296,7 @@ export const TRPC_NAMESPACE_API_KEY_RULES: Record<string, TrpcNamespaceScopeRule
// restore / purge is a destructive cross-cutting surface, so restricted keys
// never reach it; only full-access keys can.
trash: 'blocked',
+ tts: { any: 'model:invoke' },
upload: rw('file:read', 'file:write'),
usage: rw('usage:read', null),
user: rw('user:read', 'user:write'),
diff --git a/packages/const/src/fetch.ts b/packages/const/src/fetch.ts
index 42338d09f69..aec260107e9 100644
--- a/packages/const/src/fetch.ts
+++ b/packages/const/src/fetch.ts
@@ -1,30 +1,4 @@
-export const OPENAI_END_POINT = 'X-openai-end-point';
-export const OPENAI_API_KEY_HEADER_KEY = 'X-openai-api-key';
-export const LOBE_USER_ID = 'X-lobe-user-id';
-
-export const USE_AZURE_OPENAI = 'X-use-azure-openai';
-
-export const AZURE_OPENAI_API_VERSION = 'X-azure-openai-api-version';
-
-export const OAUTH_AUTHORIZED = 'X-oauth-authorized';
export const REQUEST_TRIGGER_HEADER = 'x-lobechat-request-trigger';
export const REQUEST_AGENT_ID_HEADER = 'x-agent-id';
export const REQUEST_TOPIC_ID_HEADER = 'x-topic-id';
export const CLIENT_VERSION_HEADER = 'x-lobe-client-version';
-
-/**
- * @deprecated
- */
-export const getOpenAIAuthFromRequest = (req: Request) => {
- const apiKey = req.headers.get(OPENAI_API_KEY_HEADER_KEY);
- const endpoint = req.headers.get(OPENAI_END_POINT);
- const useAzureStr = req.headers.get(USE_AZURE_OPENAI);
- const apiVersion = req.headers.get(AZURE_OPENAI_API_VERSION);
- const oauthAuthorizedStr = req.headers.get(OAUTH_AUTHORIZED);
- const userId = req.headers.get(LOBE_USER_ID);
-
- const oauthAuthorized = !!oauthAuthorizedStr;
- const useAzure = !!useAzureStr;
-
- return { apiKey, apiVersion, endpoint, oauthAuthorized, useAzure, userId };
-};
diff --git a/packages/database/vitest.config.mts b/packages/database/vitest.config.mts
index cd792b6ba9d..482f4235540 100644
--- a/packages/database/vitest.config.mts
+++ b/packages/database/vitest.config.mts
@@ -12,7 +12,6 @@ export default defineConfig({
],
optimizeDeps: {
exclude: ['crypto', 'util', 'tty'],
- include: ['@lobehub/tts'],
},
test: {
alias: {
diff --git a/packages/model-runtime/src/types/tts.ts b/packages/model-runtime/src/types/tts.ts
index a72ee96c197..a49b0046901 100644
--- a/packages/model-runtime/src/types/tts.ts
+++ b/packages/model-runtime/src/types/tts.ts
@@ -1,6 +1,7 @@
export interface TextToSpeechPayload {
input: string;
model: string;
+ speed?: number;
voice: string;
}
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 1e9892d0a63..3f9472a4a7c 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -66,7 +66,6 @@ overrides:
'@lobehub/icons': ^6.0.0
'@lobehub/editor': ^5.0.0
'@lobehub/charts': ^6.0.0
- '@lobehub/tts': ^6.0.0
'@lobehub/fluent-emoji': ^5.0.0
'@react-pdf/image': 3.0.4
'@types/react': 19.2.13
diff --git a/src/app/(backend)/_deprecated/createBizOpenAI/auth.test.ts b/src/app/(backend)/_deprecated/createBizOpenAI/auth.test.ts
deleted file mode 100644
index a8a5355602a..00000000000
--- a/src/app/(backend)/_deprecated/createBizOpenAI/auth.test.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-// @vitest-environment node
-import { checkAuth } from './auth';
-
-describe('checkAuth', () => {
- it('should pass with oauth authorized', () => {
- const { auth } = checkAuth({ oauthAuthorized: true });
- expect(auth).toBe(true);
- });
-
- it('should pass with api key', () => {
- const { auth } = checkAuth({ apiKey: 'test-api-key' });
- expect(auth).toBe(true);
- });
-
- it('should pass with no params', () => {
- const { auth } = checkAuth({});
- expect(auth).toBe(true);
- });
-});
diff --git a/src/app/(backend)/_deprecated/createBizOpenAI/auth.ts b/src/app/(backend)/_deprecated/createBizOpenAI/auth.ts
deleted file mode 100644
index d8769af27ae..00000000000
--- a/src/app/(backend)/_deprecated/createBizOpenAI/auth.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-interface AuthConfig {
- apiKey?: string | null;
- oauthAuthorized?: boolean;
-}
-
-export const checkAuth = ({ apiKey, oauthAuthorized }: AuthConfig) => {
- // If authorized by oauth
- if (oauthAuthorized) {
- return { auth: true };
- }
-
- // if apiKey exist
- if (apiKey) {
- return { auth: true };
- }
-
- return { auth: true };
-};
diff --git a/src/app/(backend)/_deprecated/createBizOpenAI/createAzureOpenai.ts b/src/app/(backend)/_deprecated/createBizOpenAI/createAzureOpenai.ts
deleted file mode 100644
index a5137753c13..00000000000
--- a/src/app/(backend)/_deprecated/createBizOpenAI/createAzureOpenai.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { ChatErrorType } from '@lobechat/types';
-import { type ClientOptions } from 'openai';
-import OpenAI from 'openai';
-import urlJoin from 'url-join';
-
-import { getLLMConfig } from '@/envs/llm';
-
-// create Azure OpenAI Instance
-export const createAzureOpenai = (params: {
- apiVersion?: string | null;
- endpoint?: string | null;
- model: string;
- userApiKey?: string | null;
-}) => {
- const { AZURE_API_VERSION, AZURE_API_KEY } = getLLMConfig();
- const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL || '';
-
- const endpoint = params.endpoint || OPENAI_PROXY_URL;
- const baseURL = urlJoin(endpoint, `/openai/deployments/${params.model.replace('.', '')}`); // refs: https://test-001.openai.azure.com/openai/deployments/gpt-35-turbo
-
- const defaultApiVersion = AZURE_API_VERSION || '2023-08-01-preview';
- const apiVersion = params.apiVersion || defaultApiVersion;
- const apiKey = params.userApiKey || AZURE_API_KEY;
-
- if (!apiKey) throw new Error('AZURE_API_KEY is empty', { cause: ChatErrorType.NoOpenAIAPIKey });
-
- const config: ClientOptions = {
- apiKey,
- baseURL,
- defaultHeaders: { 'api-key': apiKey },
- defaultQuery: { 'api-version': apiVersion },
- };
-
- return new OpenAI(config);
-};
diff --git a/src/app/(backend)/_deprecated/createBizOpenAI/createOpenai.ts b/src/app/(backend)/_deprecated/createBizOpenAI/createOpenai.ts
deleted file mode 100644
index e7edcebe352..00000000000
--- a/src/app/(backend)/_deprecated/createBizOpenAI/createOpenai.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { ChatErrorType } from '@lobechat/types';
-import OpenAI from 'openai';
-
-import { getLLMConfig } from '@/envs/llm';
-
-// create OpenAI instance
-export const createOpenai = (userApiKey: string | null, endpoint?: string | null) => {
- const { OPENAI_API_KEY } = getLLMConfig();
- const OPENAI_PROXY_URL = process.env.OPENAI_PROXY_URL;
-
- const baseURL = endpoint || OPENAI_PROXY_URL || undefined;
-
- const apiKey = userApiKey || OPENAI_API_KEY;
-
- if (!apiKey) throw new Error('OPENAI_API_KEY is empty', { cause: ChatErrorType.NoOpenAIAPIKey });
-
- return new OpenAI({ apiKey, baseURL });
-};
diff --git a/src/app/(backend)/_deprecated/createBizOpenAI/index.ts b/src/app/(backend)/_deprecated/createBizOpenAI/index.ts
deleted file mode 100644
index c0e93e09ce9..00000000000
--- a/src/app/(backend)/_deprecated/createBizOpenAI/index.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { ChatErrorType } from '@lobechat/types';
-import type OpenAI from 'openai';
-
-import { getOpenAIAuthFromRequest } from '@/const/fetch';
-import { createErrorResponse } from '@/utils/errorResponse';
-
-import { createOpenai } from './createOpenai';
-
-/**
- * @deprecated
- * createOpenAI Instance with Auth and azure openai support
- * if auth not pass ,just return error response
- */
-export const createBizOpenAI = (req: Request): Response | OpenAI => {
- const { apiKey, endpoint } = getOpenAIAuthFromRequest(req);
-
- let openai: OpenAI;
-
- try {
- openai = createOpenai(apiKey, endpoint);
- } catch (error) {
- if ((error as Error).cause === ChatErrorType.NoOpenAIAPIKey) {
- return createErrorResponse(ChatErrorType.NoOpenAIAPIKey);
- }
-
- console.error(error); // log error to trace it
- return createErrorResponse(ChatErrorType.InternalServerError);
- }
-
- return openai;
-};
diff --git a/src/app/(backend)/webapi/tts/openai/route.ts b/src/app/(backend)/webapi/tts/openai/route.ts
deleted file mode 100644
index 156ef950330..00000000000
--- a/src/app/(backend)/webapi/tts/openai/route.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { type OpenAITTSPayload } from '@lobehub/tts';
-import { createOpenaiAudioSpeech } from '@lobehub/tts/server';
-
-import { createBizOpenAI } from '@/app/(backend)/_deprecated/createBizOpenAI';
-import { createSpeechResponse } from '@/server/utils/createSpeechResponse';
-
-export const POST = async (req: Request) => {
- const payload = (await req.json()) as OpenAITTSPayload;
-
- // need to be refactored with jwt auth mode
- const openaiOrErrResponse = createBizOpenAI(req);
-
- // if resOrOpenAI is a Response, it means there is an error,just return it
- if (openaiOrErrResponse instanceof Response) return openaiOrErrResponse;
-
- return createSpeechResponse(
- () =>
- createOpenaiAudioSpeech({
- openai: openaiOrErrResponse as any,
- payload,
- }),
- {
- logTag: 'webapi/tts/openai',
- messages: {
- failure: 'Failed to synthesize speech',
- invalid: 'Unexpected payload from OpenAI TTS',
- },
- },
- );
-};
diff --git a/src/services/_header.ts b/src/services/_header.ts
deleted file mode 100644
index 995fb0018d1..00000000000
--- a/src/services/_header.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { LOBE_USER_ID, OPENAI_API_KEY_HEADER_KEY, OPENAI_END_POINT } from '@/const/fetch';
-import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
-import { useUserStore } from '@/store/user';
-
-/**
- * TODO: Need to be removed after tts refactor
- * @deprecated
- */
-
-export const createHeaderWithOpenAI = (header?: HeadersInit): HeadersInit => {
- const state = useUserStore.getState();
-
- const keyVaults: Record<string, any> =
- aiProviderSelectors.providerKeyVaults('openai')(useAiInfraStore.getState()) || {};
-
-
- return {
- ...header,
- [LOBE_USER_ID]: state.user?.id || '',
- [OPENAI_API_KEY_HEADER_KEY]: keyVaults.apiKey || '',
- [OPENAI_END_POINT]: keyVaults.baseURL || '',
- };
-};
diff --git a/vitest.config.mts b/vitest.config.mts
index 68ebd0712e3..30b8463fb30 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -75,7 +75,6 @@ export default defineConfig({
},
optimizeDeps: {
exclude: ['crypto', 'util', 'tty'],
- include: ['@lobehub/tts'],
},
plugins: [
tsconfigPaths({ projects: ['.', './apps/workbench'] }),