8
8
ConfigValidationError ,
9
9
ModelRole ,
10
10
} from "@continuedev/config-yaml" ;
11
- import { fetchwithRequestOptions } from "@continuedev/fetch" ;
12
11
import * as JSONC from "comment-json" ;
13
12
import * as tar from "tar" ;
14
13
@@ -37,17 +36,15 @@ import {
37
36
slashCommandFromDescription ,
38
37
slashFromCustomCommand ,
39
38
} from "../commands/index" ;
40
- import { AllRerankers } from "../context/allRerankers" ;
41
39
import { MCPManagerSingleton } from "../context/mcp" ;
42
40
import CodebaseContextProvider from "../context/providers/CodebaseContextProvider" ;
43
41
import ContinueProxyContextProvider from "../context/providers/ContinueProxyContextProvider" ;
44
42
import CustomContextProviderClass from "../context/providers/CustomContextProvider" ;
45
43
import FileContextProvider from "../context/providers/FileContextProvider" ;
46
44
import { contextProviderClassFromName } from "../context/providers/index" ;
47
45
import { useHub } from "../control-plane/env" ;
48
- import { allEmbeddingsProviders } from "../indexing/allEmbeddingsProviders" ;
49
46
import { BaseLLM } from "../llm" ;
50
- import { llmFromDescription } from "../llm/llms" ;
47
+ import { LLMClasses , llmFromDescription } from "../llm/llms" ;
51
48
import CustomLLMClass from "../llm/llms/CustomLLM" ;
52
49
import FreeTrial from "../llm/llms/FreeTrial" ;
53
50
import { LLMReranker } from "../llm/llms/llm" ;
@@ -420,39 +417,32 @@ async function intermediateToFinalConfig(
420
417
function getEmbeddingsILLM (
421
418
embedConfig : EmbeddingsProviderDescription | ILLM | undefined ,
422
419
) : ILLM | null {
423
- if ( ! embedConfig ) {
424
- return null ;
425
- }
426
- // config.ts-injected ILLM
427
- if ( "providerName" in embedConfig ) {
428
- return embedConfig ;
429
- }
430
- const { provider, ...options } = embedConfig ;
431
- const embeddingsProviderClass = allEmbeddingsProviders [ provider ] ;
432
- if ( embeddingsProviderClass ) {
433
- if (
434
- embeddingsProviderClass . name === "_TransformersJsEmbeddingsProvider"
435
- ) {
436
- return new embeddingsProviderClass ( ) ;
420
+ if ( embedConfig ) {
421
+ // config.ts-injected ILLM
422
+ if ( "providerName" in embedConfig ) {
423
+ return embedConfig ;
424
+ }
425
+ const { provider, ...options } = embedConfig ;
426
+ if ( provider === "transformers.js" ) {
427
+ return new TransformersJsEmbeddingsProvider ( ) ;
437
428
} else {
438
- const llmOptions : LLMOptions = {
439
- model : options . model ?? "UNSPECIFIED" ,
440
- ...options ,
441
- } ;
442
- return new embeddingsProviderClass (
443
- llmOptions ,
444
- ( url : string | URL , init : any ) =>
445
- fetchwithRequestOptions ( url , init , {
446
- ...config . requestOptions ,
447
- ...options . requestOptions ,
448
- } ) ,
449
- ) ;
429
+ const cls = LLMClasses . find ( ( c ) => c . providerName === provider ) ;
430
+ if ( cls ) {
431
+ const llmOptions : LLMOptions = {
432
+ model : options . model ?? "UNSPECIFIED" ,
433
+ ...options ,
434
+ } ;
435
+ return new cls ( llmOptions ) ;
436
+ } else {
437
+ errors . push ( {
438
+ fatal : false ,
439
+ message : `Embeddings provider ${ provider } not found` ,
440
+ } ) ;
441
+ }
450
442
}
451
- } else {
452
- errors . push ( {
453
- fatal : false ,
454
- message : `Embeddings provider ${ provider } not found. Using default` ,
455
- } ) ;
443
+ }
444
+ if ( ideInfo . ideType === "vscode" ) {
445
+ return new TransformersJsEmbeddingsProvider ( ) ;
456
446
}
457
447
return null ;
458
448
}
@@ -470,7 +460,6 @@ async function intermediateToFinalConfig(
470
460
return rerankingConfig ;
471
461
}
472
462
const { name, params } = config . reranker as RerankerDescription ;
473
- const rerankerClass = AllRerankers [ name ] ;
474
463
475
464
if ( name === "llm" ) {
476
465
const llm = models . find ( ( model ) => model . title === params ?. modelTitle ) ;
@@ -483,17 +472,20 @@ async function intermediateToFinalConfig(
483
472
} else {
484
473
return new LLMReranker ( llm ) ;
485
474
}
486
- } else if ( rerankerClass ) {
487
- const llmOptions : LLMOptions = {
488
- model : "rerank-2" ,
489
- ...params ,
490
- } ;
491
- return new rerankerClass ( llmOptions , ( url : string | URL , init : any ) =>
492
- fetchwithRequestOptions ( url , init , {
493
- ...config . requestOptions ,
494
- ...params ?. requestOptions ,
495
- } ) ,
496
- ) ;
475
+ } else {
476
+ const cls = LLMClasses . find ( ( c ) => c . providerName === name ) ;
477
+ if ( cls ) {
478
+ const llmOptions : LLMOptions = {
479
+ model : params ?. model ,
480
+ ...params ,
481
+ } ;
482
+ return new cls ( llmOptions ) ;
483
+ } else {
484
+ errors . push ( {
485
+ fatal : false ,
486
+ message : `Unknown reranking provider ${ name } ` ,
487
+ } ) ;
488
+ }
497
489
}
498
490
return null ;
499
491
}
0 commit comments