@@ -13,6 +13,10 @@ export class ChatManager {
13
13
this . setup ( container , app_ctx ) ;
14
14
}
15
15
async setup ( container , app_ctx ) {
16
+
17
+
18
+
19
+
16
20
ctx = app_ctx ;
17
21
this . chatMode = 'chat' ;
18
22
this . container = container ;
@@ -22,6 +26,16 @@ export class ChatManager {
22
26
this . conversationTitleInput = document . createElement ( 'input' ) ;
23
27
this . conversationTitleInput . type = 'text' ;
24
28
this . conversationTitleInput . style . width = '100%' ;
29
+
30
+
31
+
32
+
33
+
34
+ //await this.populateModelSelect();
35
+
36
+
37
+
38
+
25
39
//make it so that on change it saves the title
26
40
this . conversationTitleInput . addEventListener ( 'change' , async ( ) => {
27
41
const conversationId = this . conversationPicker . value ;
@@ -222,6 +236,50 @@ export class ChatManager {
222
236
this . autoApplyCheckbox . checked = this . autoApplyMode ;
223
237
this . setInput ( '' ) ;
224
238
}
239
+
240
+ async populateModelSelect ( ) {
241
+
242
+
243
+ // model selector
244
+ const modelData = await doAjax ( './llmSettings' , { } ) ;
245
+
246
+ // add a select element to the container
247
+ this . modelPicker = document . createElement ( 'select' ) ;
248
+ this . modelPicker . style . margin = '10px' ;
249
+ this . modelPicker . style . width = '100%' ;
250
+ this . modelPicker . size = 1 ;
251
+ this . modelPicker . addEventListener ( 'change' , async ( ) => {
252
+ const selectedModel = this . modelPicker . value ;
253
+ alert ( `Selected model: ${ selectedModel } ` ) ;
254
+ } ) ;
255
+
256
+ // add the model picker to the container
257
+ this . container . appendChild ( this . modelPicker ) ;
258
+
259
+
260
+
261
+ // Clear existing options
262
+ this . modelPicker . innerHTML = '' ;
263
+
264
+ Object . entries ( modelData ) . forEach ( ( [ provider , data ] ) => {
265
+ if ( data . models && Array . isArray ( data . models ) ) {
266
+ // Create optgroup for each provider
267
+ const group = document . createElement ( 'optgroup' ) ;
268
+ group . label = provider ;
269
+
270
+ data . models . forEach ( model => {
271
+ const option = document . createElement ( 'option' ) ;
272
+ option . value = `${ provider } :${ model } ` ;
273
+ option . textContent = model ;
274
+ group . appendChild ( option ) ;
275
+ } ) ;
276
+
277
+ this . modelPicker . appendChild ( group ) ;
278
+ }
279
+ } ) ;
280
+ }
281
+
282
+
225
283
async submitButtonHandler ( ) {
226
284
// test if message is empty. If empty, do not add message.
227
285
if ( this . userInput . value !== '' ) {
@@ -253,7 +311,7 @@ export class ChatManager {
253
311
} ) ;
254
312
}
255
313
async loadConversation ( conversationId ) {
256
- console . log ( 'conversationId' , conversationId ) ;
314
+ // console.log('conversationId', conversationId);
257
315
const response = await doAjax ( './pullMessages' , { id : conversationId } ) ;
258
316
ctx . targetFile = response . targetFile ;
259
317
await this . setTargetFile ( response . targetFile ) ;
@@ -524,11 +582,11 @@ export class ChatManager {
524
582
} ) ;
525
583
}
526
584
codeElements = Array . from ( codeElements ) ;
527
- console . log ( 'codeElements' , codeElements ) ;
585
+ // console.log('codeElements', codeElements);
528
586
if ( codeElements . length === 0 )
529
587
return ;
530
588
codeElements . forEach ( codeElement => {
531
- console . log ( 'codeElement' , codeElement ) ;
589
+ // console.log('codeElement', codeElement);
532
590
// Create a wrapper to hold the code and toolbar
533
591
const wrapper = document . createElement ( 'div' ) ;
534
592
wrapper . style . position = 'relative' ;
0 commit comments