@@ -792,7 +792,7 @@ function is_stopped() {
792792const ask_gpt = async ( message_id , message_index = - 1 , regenerate = false , provider = null , model = null , action = null ) => {
793793 if ( ! model && ! provider ) {
794794 model = get_selected_model ( ) ?. value || null ;
795- provider = providerSelect . options [ providerSelect . selectedIndex ] . value ;
795+ provider = providerSelect . options [ providerSelect . selectedIndex ] ? .value ;
796796 }
797797 let conversation = await get_conversation ( window . conversation_id ) ;
798798 if ( ! conversation ) {
@@ -1815,8 +1815,14 @@ async function on_load() {
18151815 let chat_url = new URL ( window . location . href )
18161816 let chat_params = new URLSearchParams ( chat_url . search ) ;
18171817 if ( chat_params . get ( "prompt" ) ) {
1818- messageInput . value = chat_params . get ( "prompt" ) ;
1819- await handle_ask ( ) ;
1818+ messageInput . value = chat_params . title
1819+ + chat_params . title ? "\n\n\n" : ""
1820+ + chat_params . prompt
1821+ + chat_params . prompt && chat_params . url ? "\n\n\n" : ""
1822+ + chat_params . url ;
1823+ messageInput . style . height = messageInput . scrollHeight + "px" ;
1824+ messageInput . focus ( ) ;
1825+ //await handle_ask();
18201826 } else {
18211827 say_hello ( )
18221828 }
@@ -1871,7 +1877,6 @@ async function on_api() {
18711877 setTimeout ( ( ) => prompt_lock = false , 3000 ) ;
18721878 await handle_ask ( ) ;
18731879 } else {
1874- messageInput . style . removeProperty ( "height" ) ;
18751880 messageInput . style . height = messageInput . scrollHeight + "px" ;
18761881 }
18771882 } ) ;
@@ -1970,7 +1975,11 @@ async function on_api() {
19701975 provider_options [ provider . name ] = option ;
19711976 }
19721977 } ) ;
1978+ }
1979+ if ( appStorage . getItem ( "provider" ) ) {
19731980 await load_provider_models ( appStorage . getItem ( "provider" ) )
1981+ } else {
1982+ providerSelect . selectedIndex = 0 ;
19741983 }
19751984 for ( let [ name , [ label , login_url , childs ] ] of Object . entries ( login_urls ) ) {
19761985 if ( ! login_url && ! is_demo ) {
@@ -1990,7 +1999,7 @@ async function on_api() {
19901999 }
19912000
19922001 register_settings_storage ( ) ;
1993- await load_settings_storage ( )
2002+ await load_settings_storage ( ) ;
19942003 Object . entries ( provider_options ) . forEach (
19952004 ( [ provider_name , option ] ) => load_provider_option ( option . querySelector ( "input" ) , provider_name )
19962005 ) ;
@@ -2156,9 +2165,14 @@ async function upload_files(fileInput) {
21562165 }
21572166 appStorage . setItem ( `bucket:${ bucket_id } ` , data . size ) ;
21582167 inputCount . innerText = "Files are loaded successfully" ;
2159- messageInput . value += ( messageInput . value ? "\n" : "" ) + JSON . stringify ( { bucket_id : bucket_id } ) + "\n" ;
2160- paperclip . classList . remove ( "blink" ) ;
2161- fileInput . value = "" ;
2168+ if ( ! messageInput . value ) {
2169+ messageInput . value = JSON . stringify ( { bucket_id : bucket_id } ) ;
2170+ handle_ask ( false ) ;
2171+ } else {
2172+ messageInput . value += ( messageInput . value ? "\n" : "" ) + JSON . stringify ( { bucket_id : bucket_id } ) + "\n" ;
2173+ paperclip . classList . remove ( "blink" ) ;
2174+ fileInput . value = "" ;
2175+ }
21622176 }
21632177 } ;
21642178 eventSource . onerror = ( event ) => {
0 commit comments