@@ -817,6 +817,37 @@ class Me {
817
817
818
818
}
819
819
820
+ /**
821
+ * Auto create ui input elements for fields in ChatRequestOptions
822
+ * Currently supports text and number field types.
823
+ * @param {HTMLDivElement } elDiv
824
+ */
825
+ show_settings_chatrequestoptions ( elDiv ) {
826
+ let typeDict = {
827
+ "string" : "text" ,
828
+ "number" : "number" ,
829
+ } ;
830
+ let fs = document . createElement ( "fieldset" ) ;
831
+ let legend = document . createElement ( "legend" ) ;
832
+ legend . innerText = "ChatRequestOptions" ;
833
+ fs . appendChild ( legend ) ;
834
+ elDiv . appendChild ( fs ) ;
835
+ for ( const k in this . chatRequestOptions ) {
836
+ let val = this . chatRequestOptions [ k ] ;
837
+ let type = typeof ( val ) ;
838
+ if ( ! ( ( type == "string" ) || ( type == "number" ) ) ) {
839
+ continue ;
840
+ }
841
+ let inp = ui . el_creatediv_input ( `Set${ k } ` , k , typeDict [ type ] , this . chatRequestOptions [ k ] , ( val ) => {
842
+ if ( type == "number" ) {
843
+ val = Number ( val ) ;
844
+ }
845
+ this . chatRequestOptions [ k ] = val ;
846
+ } ) ;
847
+ fs . appendChild ( inp . div ) ;
848
+ }
849
+ }
850
+
820
851
/**
821
852
* Show settings ui for configurable parameters, in the passed Div element.
822
853
* @param {HTMLDivElement } elDiv
@@ -834,11 +865,6 @@ class Me {
834
865
inp . el . placeholder = "Bearer OPENAI_API_KEY" ;
835
866
elDiv . appendChild ( inp . div ) ;
836
867
837
- inp = ui . el_creatediv_input ( "SetModel" , "Model" , "text" , this . chatRequestOptions [ "model" ] , ( val ) => {
838
- this . chatRequestOptions [ "model" ] = val ;
839
- } ) ;
840
- elDiv . appendChild ( inp . div ) ;
841
-
842
868
let bb = ui . el_creatediv_boolbutton ( "SetStream" , "Stream" , { true : "[+] yes stream" , false : "[-] do oneshot" } , this . bStream , ( val ) => {
843
869
this . bStream = val ;
844
870
} ) ;
@@ -869,6 +895,8 @@ class Me {
869
895
} ) ;
870
896
elDiv . appendChild ( sel . div ) ;
871
897
898
+ this . show_settings_chatrequestoptions ( elDiv ) ;
899
+
872
900
}
873
901
874
902
}
0 commit comments