refactor: optimize core engine and retrieval logic for v2.80.43
This commit is contained in:
+9
-9
@@ -61,18 +61,18 @@ export function resolveEngine(baseUrl: string): EngineKind {
|
||||
return 'ollama';
|
||||
}
|
||||
|
||||
export function buildApiUrl(baseUrl: string, engine: EngineKind, endpoint: 'models' | 'chat'): string {
|
||||
export function buildApiUrl(baseUrl: string, engine: EngineKind, endpoint: 'models' | 'chat' | 'embeddings'): string {
|
||||
const normalized = normalizeBaseUrl(baseUrl);
|
||||
if (engine === 'lmstudio') {
|
||||
if (normalized.endsWith('/v1')) {
|
||||
return endpoint === 'models' ? `${normalized}/models` : `${normalized}/chat/completions`;
|
||||
}
|
||||
return endpoint === 'models' ? `${normalized}/v1/models` : `${normalized}/v1/chat/completions`;
|
||||
const root = normalized.endsWith('/v1') ? normalized : `${normalized}/v1`;
|
||||
if (endpoint === 'models') return `${root}/models`;
|
||||
if (endpoint === 'embeddings') return `${root}/embeddings`;
|
||||
return `${root}/chat/completions`;
|
||||
}
|
||||
if (normalized.endsWith('/api')) {
|
||||
return endpoint === 'models' ? `${normalized}/tags` : `${normalized}/chat`;
|
||||
}
|
||||
return endpoint === 'models' ? `${normalized}/api/tags` : `${normalized}/api/chat`;
|
||||
const apiRoot = normalized.endsWith('/api') ? normalized : `${normalized}/api`;
|
||||
if (endpoint === 'models') return `${apiRoot}/tags`;
|
||||
if (endpoint === 'embeddings') return `${apiRoot}/embed`;
|
||||
return `${apiRoot}/chat`;
|
||||
}
|
||||
|
||||
export function summarizeText(text: string, maxLength: number = 400): string {
|
||||
|
||||
Reference in New Issue
Block a user