@@ -13,6 +13,10 @@ export class ChatManager {
1313 this . setup ( container , app_ctx ) ;
1414 }
1515 async setup ( container , app_ctx ) {
16+
17+
18+
19+
1620 ctx = app_ctx ;
1721 this . chatMode = 'chat' ;
1822 this . container = container ;
@@ -22,6 +26,16 @@ export class ChatManager {
2226 this . conversationTitleInput = document . createElement ( 'input' ) ;
2327 this . conversationTitleInput . type = 'text' ;
2428 this . conversationTitleInput . style . width = '100%' ;
29+
30+
31+
32+
33+
34+ //await this.populateModelSelect();
35+
36+
37+
38+
2539 //make it so that on change it saves the title
2640 this . conversationTitleInput . addEventListener ( 'change' , async ( ) => {
2741 const conversationId = this . conversationPicker . value ;
@@ -222,6 +236,50 @@ export class ChatManager {
222236 this . autoApplyCheckbox . checked = this . autoApplyMode ;
223237 this . setInput ( '' ) ;
224238 }
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+
225283 async submitButtonHandler ( ) {
226284 // test if message is empty. If empty, do not add message.
227285 if ( this . userInput . value !== '' ) {
@@ -253,7 +311,7 @@ export class ChatManager {
253311 } ) ;
254312 }
255313 async loadConversation ( conversationId ) {
256- console . log ( 'conversationId' , conversationId ) ;
314+ // console.log('conversationId', conversationId);
257315 const response = await doAjax ( './pullMessages' , { id : conversationId } ) ;
258316 ctx . targetFile = response . targetFile ;
259317 await this . setTargetFile ( response . targetFile ) ;
@@ -524,11 +582,11 @@ export class ChatManager {
524582 } ) ;
525583 }
526584 codeElements = Array . from ( codeElements ) ;
527- console . log ( 'codeElements' , codeElements ) ;
585+ // console.log('codeElements', codeElements);
528586 if ( codeElements . length === 0 )
529587 return ;
530588 codeElements . forEach ( codeElement => {
531- console . log ( 'codeElement' , codeElement ) ;
589+ // console.log('codeElement', codeElement);
532590 // Create a wrapper to hold the code and toolbar
533591 const wrapper = document . createElement ( 'div' ) ;
534592 wrapper . style . position = 'relative' ;
0 commit comments