1
1
import { ContextItemId , IDE } from "core" ;
2
2
import { ConfigHandler } from "core/config/handler" ;
3
+ import { fetchwithRequestOptions } from "core/util/fetchWithOptions" ;
3
4
import {
4
5
setupLocalMode ,
5
6
setupOptimizedExistingUserMode ,
6
7
setupOptimizedMode ,
7
8
} from "core/config/onboarding" ;
9
+ import { SiteIndexingConfig } from "core"
8
10
import { addModel , addOpenAIKey , deleteModel } from "core/config/util" ;
9
11
import { indexDocs } from "core/indexing/docs" ;
10
12
import TransformersJsEmbeddingsProvider from "core/indexing/embeddings/TransformersJsEmbeddingsProvider" ;
@@ -379,7 +381,14 @@ export class VsCodeWebviewProtocol {
379
381
while ( ! next . done ) {
380
382
if ( protocol . abortedMessageIds . has ( msg . messageId ) ) {
381
383
protocol . abortedMessageIds . delete ( msg . messageId ) ;
382
- next = await gen . return ( { completion : "" , prompt : "" } ) ;
384
+ next = await gen . return ( {
385
+ completion : "" ,
386
+ prompt : "" ,
387
+ completionOptions : {
388
+ ...msg . data . completionOptions ,
389
+ model : model . model ,
390
+ } ,
391
+ } ) ;
383
392
break ;
384
393
}
385
394
yield { content : next . value } ;
@@ -403,7 +412,14 @@ export class VsCodeWebviewProtocol {
403
412
while ( ! next . done ) {
404
413
if ( protocol . abortedMessageIds . has ( msg . messageId ) ) {
405
414
protocol . abortedMessageIds . delete ( msg . messageId ) ;
406
- next = await gen . return ( { completion : "" , prompt : "" } ) ;
415
+ next = await gen . return ( {
416
+ completion : "" ,
417
+ prompt : "" ,
418
+ completionOptions : {
419
+ ...msg . data . completionOptions ,
420
+ model : model . model ,
421
+ } ,
422
+ } ) ;
407
423
break ;
408
424
}
409
425
yield { content : next . value . content } ;
@@ -465,6 +481,8 @@ export class VsCodeWebviewProtocol {
465
481
} ,
466
482
selectedCode,
467
483
config,
484
+ fetch : ( url , init ) =>
485
+ fetchwithRequestOptions ( url , init , config . requestOptions ) ,
468
486
} ) ) {
469
487
if ( content ) {
470
488
yield { content } ;
@@ -490,7 +508,11 @@ export class VsCodeWebviewProtocol {
490
508
}
491
509
492
510
try {
493
- const items = await provider . loadSubmenuItems ( { ide } ) ;
511
+ const items = await provider . loadSubmenuItems ( {
512
+ ide : this . ide ,
513
+ fetch : ( url , init ) =>
514
+ fetchwithRequestOptions ( url , init , config . requestOptions )
515
+ } ) ;
494
516
return items ;
495
517
} catch ( e ) {
496
518
vscode . window . showErrorMessage (
@@ -526,8 +548,10 @@ export class VsCodeWebviewProtocol {
526
548
embeddingsProvider : config . embeddingsProvider ,
527
549
reranker : config . reranker ,
528
550
fullInput,
529
- ide,
551
+ ide,
530
552
selectedCode,
553
+ fetch : ( url , init ) =>
554
+ fetchwithRequestOptions ( url , init , config . requestOptions ) ,
531
555
} ) ;
532
556
533
557
Telemetry . capture ( "useContextProvider" , {
@@ -542,20 +566,25 @@ export class VsCodeWebviewProtocol {
542
566
return [ ] ;
543
567
}
544
568
} ) ;
569
+
545
570
this . on ( "context/addDocs" , ( msg ) => {
546
- const { url, title } = msg . data ;
547
- const embeddingsProvider = new TransformersJsEmbeddingsProvider ( ) ;
571
+ const siteIndexingConfig : SiteIndexingConfig = {
572
+ startUrl : msg . data . startUrl ,
573
+ rootUrl : msg . data . rootUrl ,
574
+ title : msg . data . title ,
575
+ maxDepth : msg . data . maxDepth ,
576
+ } ;
577
+
548
578
vscode . window . withProgress (
549
579
{
550
580
location : vscode . ProgressLocation . Notification ,
551
- title : `Indexing ${ title } ` ,
581
+ title : `Indexing ${ msg . data . title } ` ,
552
582
cancellable : false ,
553
583
} ,
554
584
async ( progress ) => {
555
585
for await ( const update of indexDocs (
556
- title ,
557
- new URL ( url ) ,
558
- embeddingsProvider ,
586
+ siteIndexingConfig ,
587
+ new TransformersJsEmbeddingsProvider ( ) ,
559
588
) ) {
560
589
progress . report ( {
561
590
increment : update . progress ,
@@ -564,7 +593,7 @@ export class VsCodeWebviewProtocol {
564
593
}
565
594
566
595
vscode . window . showInformationMessage (
567
- `🎉 Successfully indexed ${ title } ` ,
596
+ `🎉 Successfully indexed ${ msg . data . title } ` ,
568
597
) ;
569
598
570
599
this . request ( "refreshSubmenuItems" , undefined ) ;
0 commit comments