From b360e0edc72be776b0d71a14c6c5e26744352a93 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 12 Jan 2026 15:12:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A7=94=E6=89=98=20ensureLiteLLMEmbed?= =?UTF-8?q?derReady=20=E4=BB=A5=E7=A1=AE=E4=BF=9D=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E6=80=A7=EF=BC=8C=E4=BC=98=E5=8C=96=20ccw-li?= =?UTF-8?q?tellm=20=E5=AE=89=E8=A3=85=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ccw/src/core/routes/litellm-api-routes.ts | 46 ++++++----------------- 1 file changed, 12 insertions(+), 34 deletions(-) diff --git a/ccw/src/core/routes/litellm-api-routes.ts b/ccw/src/core/routes/litellm-api-routes.ts index 8a51447d..6e78c92e 100644 --- a/ccw/src/core/routes/litellm-api-routes.ts +++ b/ccw/src/core/routes/litellm-api-routes.ts @@ -12,6 +12,7 @@ import { ensureUvInstalled, createCodexLensUvManager } from '../../utils/uv-manager.js'; +import { ensureLiteLLMEmbedderReady } from '../../tools/codex-lens.js'; import type { RouteContext } from './types.js'; // ========== Input Validation Schemas ========== @@ -105,43 +106,20 @@ export function clearCcwLitellmStatusCache() { /** * Install ccw-litellm using UV package manager - * Uses CodexLens venv for consistency with other Python dependencies - * @param packagePath - Local package path, or null to install from PyPI + * Delegates to ensureLiteLLMEmbedderReady for consistent dependency handling + * This ensures ccw-litellm installation doesn't break fastembed's onnxruntime dependencies + * @param _packagePath - Ignored, ensureLiteLLMEmbedderReady handles path discovery * @returns Installation result */ -async function installCcwLitellmWithUv(packagePath: string | null): Promise<{ success: boolean; message?: string; error?: string }> { - try { - await ensureUvInstalled(); - - // Reuse CodexLens venv for consistency - const uv = createCodexLensUvManager(); - - // Ensure venv exists - const venvResult = await uv.createVenv(); - if (!venvResult.success) { - return { success: false, error: venvResult.error }; - } - - if (packagePath) { - // Install from local path - const result = await uv.installFromProject(packagePath); - if (result.success) { - clearCcwLitellmStatusCache(); - return { success: true, message: 'ccw-litellm installed from local path via UV' }; - } - return { success: false, error: result.error }; - } else { - // Install from PyPI - const result = await uv.install(['ccw-litellm']); - if (result.success) { - clearCcwLitellmStatusCache(); - return { success: true, message: 'ccw-litellm installed from PyPI via UV' }; - } - return { success: false, error: result.error }; - } - } catch (err) { - return { success: false, error: (err as Error).message }; +async function installCcwLitellmWithUv(_packagePath: string | null): Promise<{ success: boolean; message?: string; error?: string }> { + // Delegate to the robust installation logic in codex-lens.ts + // This ensures consistent dependency handling within the shared venv, + // preventing onnxruntime conflicts that would break fastembed + const result = await ensureLiteLLMEmbedderReady(); + if (result.success) { + clearCcwLitellmStatusCache(); } + return result; } function sanitizeProviderForResponse(provider: any): any {