mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-10 02:24:35 +08:00
feat: 添加 LiteLLM 嵌入后端支持及相关配置选项
This commit is contained in:
@@ -254,6 +254,11 @@ const i18n = {
|
|||||||
'codexlens.cleanAllIndexes': 'Clean All Indexes',
|
'codexlens.cleanAllIndexes': 'Clean All Indexes',
|
||||||
'codexlens.installCodexLens': 'Install CodexLens',
|
'codexlens.installCodexLens': 'Install CodexLens',
|
||||||
'codexlens.createIndex': 'Create Index',
|
'codexlens.createIndex': 'Create Index',
|
||||||
|
'codexlens.embeddingBackend': 'Embedding Backend',
|
||||||
|
'codexlens.localFastembed': 'Local (FastEmbed)',
|
||||||
|
'codexlens.apiLitellm': 'API (LiteLLM)',
|
||||||
|
'codexlens.backendHint': 'Select local model or remote API endpoint',
|
||||||
|
'codexlens.noApiModels': 'No API embedding models configured',
|
||||||
'codexlens.embeddingModel': 'Embedding Model',
|
'codexlens.embeddingModel': 'Embedding Model',
|
||||||
'codexlens.modelHint': 'Select embedding model for vector search (models with ✓ are installed)',
|
'codexlens.modelHint': 'Select embedding model for vector search (models with ✓ are installed)',
|
||||||
'codexlens.fullIndex': 'Full',
|
'codexlens.fullIndex': 'Full',
|
||||||
@@ -1901,6 +1906,11 @@ const i18n = {
|
|||||||
'codexlens.cleanAllIndexes': '清理所有索引',
|
'codexlens.cleanAllIndexes': '清理所有索引',
|
||||||
'codexlens.installCodexLens': '安装 CodexLens',
|
'codexlens.installCodexLens': '安装 CodexLens',
|
||||||
'codexlens.createIndex': '创建索引',
|
'codexlens.createIndex': '创建索引',
|
||||||
|
'codexlens.embeddingBackend': '嵌入后端',
|
||||||
|
'codexlens.localFastembed': '本地 (FastEmbed)',
|
||||||
|
'codexlens.apiLitellm': 'API (LiteLLM)',
|
||||||
|
'codexlens.backendHint': '选择本地模型或远程 API 端点',
|
||||||
|
'codexlens.noApiModels': '未配置 API 嵌入模型',
|
||||||
'codexlens.embeddingModel': '嵌入模型',
|
'codexlens.embeddingModel': '嵌入模型',
|
||||||
'codexlens.modelHint': '选择向量搜索的嵌入模型(带 ✓ 的已安装)',
|
'codexlens.modelHint': '选择向量搜索的嵌入模型(带 ✓ 的已安装)',
|
||||||
'codexlens.fullIndex': '全部',
|
'codexlens.fullIndex': '全部',
|
||||||
|
|||||||
@@ -1890,9 +1890,15 @@ async function renderCodexLensManager() {
|
|||||||
|
|
||||||
// Load LiteLLM API config for embedding backend options
|
// Load LiteLLM API config for embedding backend options
|
||||||
try {
|
try {
|
||||||
|
console.log('[CodexLens] Loading LiteLLM config...');
|
||||||
var litellmResponse = await fetch('/api/litellm-api/config');
|
var litellmResponse = await fetch('/api/litellm-api/config');
|
||||||
|
console.log('[CodexLens] LiteLLM response status:', litellmResponse.status);
|
||||||
if (litellmResponse.ok) {
|
if (litellmResponse.ok) {
|
||||||
window.litellmApiConfig = await litellmResponse.json();
|
window.litellmApiConfig = await litellmResponse.json();
|
||||||
|
console.log('[CodexLens] LiteLLM config loaded:', window.litellmApiConfig);
|
||||||
|
console.log('[CodexLens] Providers:', window.litellmApiConfig?.providers?.length || 0);
|
||||||
|
} else {
|
||||||
|
console.warn('[CodexLens] LiteLLM config response not ok:', litellmResponse.status);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.warn('[CodexLens] Could not load LiteLLM config:', e);
|
console.warn('[CodexLens] Could not load LiteLLM config:', e);
|
||||||
@@ -2180,13 +2186,21 @@ function buildModelSelectOptionsForPage() {
|
|||||||
function onEmbeddingBackendChange() {
|
function onEmbeddingBackendChange() {
|
||||||
var backendSelect = document.getElementById('pageBackendSelect');
|
var backendSelect = document.getElementById('pageBackendSelect');
|
||||||
var modelSelect = document.getElementById('pageModelSelect');
|
var modelSelect = document.getElementById('pageModelSelect');
|
||||||
if (!backendSelect || !modelSelect) return;
|
if (!backendSelect || !modelSelect) {
|
||||||
|
console.warn('[CodexLens] Backend or model select not found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var backend = backendSelect.value;
|
var backend = backendSelect.value;
|
||||||
|
console.log('[CodexLens] Backend changed to:', backend);
|
||||||
|
console.log('[CodexLens] Current litellmApiConfig:', window.litellmApiConfig);
|
||||||
|
|
||||||
if (backend === 'litellm') {
|
if (backend === 'litellm') {
|
||||||
// Load LiteLLM embedding models
|
// Load LiteLLM embedding models
|
||||||
modelSelect.innerHTML = buildLiteLLMModelOptions();
|
console.log('[CodexLens] Building LiteLLM model options...');
|
||||||
|
var options = buildLiteLLMModelOptions();
|
||||||
|
console.log('[CodexLens] Built options HTML:', options);
|
||||||
|
modelSelect.innerHTML = options;
|
||||||
} else {
|
} else {
|
||||||
// Load local fastembed models
|
// Load local fastembed models
|
||||||
modelSelect.innerHTML = buildModelSelectOptionsForPage();
|
modelSelect.innerHTML = buildModelSelectOptionsForPage();
|
||||||
@@ -2198,24 +2212,39 @@ function onEmbeddingBackendChange() {
|
|||||||
*/
|
*/
|
||||||
function buildLiteLLMModelOptions() {
|
function buildLiteLLMModelOptions() {
|
||||||
var litellmConfig = window.litellmApiConfig || {};
|
var litellmConfig = window.litellmApiConfig || {};
|
||||||
|
console.log('[CodexLens] litellmApiConfig:', litellmConfig);
|
||||||
|
|
||||||
var providers = litellmConfig.providers || [];
|
var providers = litellmConfig.providers || [];
|
||||||
|
console.log('[CodexLens] providers count:', providers.length);
|
||||||
|
|
||||||
var options = '';
|
var options = '';
|
||||||
|
|
||||||
providers.forEach(function(provider) {
|
providers.forEach(function(provider) {
|
||||||
|
console.log('[CodexLens] Processing provider:', provider.id, 'enabled:', provider.enabled);
|
||||||
if (!provider.enabled) return;
|
if (!provider.enabled) return;
|
||||||
var models = provider.models || [];
|
|
||||||
|
// Check embeddingModels array (config structure)
|
||||||
|
var models = provider.embeddingModels || provider.models || [];
|
||||||
|
console.log('[CodexLens] Provider', provider.id, 'embeddingModels:', models.length, models);
|
||||||
|
|
||||||
models.forEach(function(model) {
|
models.forEach(function(model) {
|
||||||
if (model.type !== 'embedding' || !model.enabled) return;
|
console.log('[CodexLens] Processing model:', model.id, 'type:', model.type, 'enabled:', model.enabled);
|
||||||
|
// Accept embedding type or models from embeddingModels array
|
||||||
|
if (model.type && model.type !== 'embedding') return;
|
||||||
|
if (!model.enabled) return;
|
||||||
var label = model.name || model.id;
|
var label = model.name || model.id;
|
||||||
|
var providerName = provider.name || provider.id;
|
||||||
var selected = options === '' ? ' selected' : '';
|
var selected = options === '' ? ' selected' : '';
|
||||||
options += '<option value="' + model.id + '"' + selected + '>' + label + '</option>';
|
options += '<option value="' + model.id + '"' + selected + '>' + label + ' (' + providerName + ')</option>';
|
||||||
|
console.log('[CodexLens] Added option:', label, 'from', providerName);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
if (options === '') {
|
if (options === '') {
|
||||||
|
console.warn('[CodexLens] No embedding models found in LiteLLM config');
|
||||||
options = '<option value="" disabled selected>' + (t('codexlens.noApiModels') || 'No API embedding models configured') + '</option>';
|
options = '<option value="" disabled selected>' + (t('codexlens.noApiModels') || 'No API embedding models configured') + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user