@@ -32,24 +32,35 @@ class Chat {
3232 let apiConfig = null ;
3333
3434 try {
35- console . log ( 'Fetching default config...' ) ;
36- const configResponse = await fetch ( '/api/config/default/full' ) ;
37- console . log ( 'Config response status:' , configResponse . status ) ;
38-
39- if ( configResponse . ok ) {
40- const configData = await configResponse . json ( ) ;
41- console . log ( 'Config data:' , configData ) ;
42- if ( configData . config ) {
43- apiConfig = configData . config ;
44- console . log ( 'API Config loaded:' , {
45- name : apiConfig . name ,
46- apiUrl : apiConfig . api_url ,
47- model : apiConfig . model ,
48- hasKey : ! ! apiConfig . api_key
49- } ) ;
50- }
35+ const currentConfig = localStorage . getItem ( 'currentConfig' ) ;
36+ if ( currentConfig ) {
37+ apiConfig = JSON . parse ( currentConfig ) ;
38+ console . log ( 'Using config from localStorage:' , {
39+ name : apiConfig . name ,
40+ apiUrl : apiConfig . api_url ,
41+ model : apiConfig . model ,
42+ hasKey : ! ! apiConfig . api_key
43+ } ) ;
5144 } else {
52- console . log ( 'No default config found or error fetching config' ) ;
45+ console . log ( 'Fetching default config...' ) ;
46+ const configResponse = await fetch ( '/api/config/default/full' ) ;
47+ console . log ( 'Config response status:' , configResponse . status ) ;
48+
49+ if ( configResponse . ok ) {
50+ const configData = await configResponse . json ( ) ;
51+ console . log ( 'Config data:' , configData ) ;
52+ if ( configData . config ) {
53+ apiConfig = configData . config ;
54+ console . log ( 'API Config loaded:' , {
55+ name : apiConfig . name ,
56+ apiUrl : apiConfig . api_url ,
57+ model : apiConfig . model ,
58+ hasKey : ! ! apiConfig . api_key
59+ } ) ;
60+ }
61+ } else {
62+ console . log ( 'No default config found or error fetching config' ) ;
63+ }
5364 }
5465 } catch ( error ) {
5566 console . error ( 'Error loading API config:' , error ) ;
0 commit comments