bugfix
This commit is contained in:
parent
91e24f567f
commit
3caea6bc6e
@ -73,11 +73,12 @@ bricks.UiAudioText = class extends bricks.UiType {
|
||||
clear_text(){
|
||||
this.text_w.setValue('');
|
||||
}
|
||||
getValue(){
|
||||
this.value = this.text_w.getValue();
|
||||
resultValue(){
|
||||
this.value = this.text_w.resultValue();
|
||||
return this.value;
|
||||
}
|
||||
setValue(v){
|
||||
this.value = v;
|
||||
this.text_w.setValue(v);
|
||||
}
|
||||
set_result_text(event){
|
||||
|
@ -1,5 +1,17 @@
|
||||
bricks = window.bricks || {}
|
||||
|
||||
var inputdata2dic = function(data){
|
||||
if (! data instanceof FormData) return data;
|
||||
var d = {}
|
||||
for (let k of data.keys()){
|
||||
var x = data.get(k);
|
||||
x = x instanceof File? x:x.toString();
|
||||
y = Object.prototype.toString.call(x)
|
||||
d[k] = x;
|
||||
console.log('x=', x, 'k=', k, 'x type=', y);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
bricks.LlmMsgAudio = class extends bricks.UpStreaming {
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
@ -171,6 +183,19 @@ bricks.LlmModel = class extends bricks.JsWidget {
|
||||
}
|
||||
show_setup_panel(event){
|
||||
|
||||
}
|
||||
inputdata2uploaddata(data){
|
||||
var d = data;
|
||||
if (data instanceof FormData){
|
||||
d.append('model', this.opts.model)
|
||||
d.append('modelinstanceid', this.opts.modelinstanceid)
|
||||
d.append('modeltypeid', this.opts.modeltypeid)
|
||||
} else {
|
||||
d.model = this.opts.model;
|
||||
d.modelinstanceid = this.opts.modelinstanceid;
|
||||
d.modeltypeid = this.opts.modeltypeid;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
async model_inputed(data){
|
||||
if (!opts.use_session){
|
||||
@ -184,27 +209,20 @@ bricks.LlmModel = class extends bricks.JsWidget {
|
||||
output_view:this.opts.output_view});
|
||||
this.llmio.o_w.add_widget(mout);
|
||||
var fmt = this.opts.user_message_format || { role:'user', content:'${prompt}'};
|
||||
var umsg = bricks.apply_data(fmt, data);
|
||||
var umsg = bricks.apply_data(fmt, inputdata2dic(data));
|
||||
var d = {};
|
||||
this.messages.push(umsg);
|
||||
d.model = this.opts.model;
|
||||
d.modelinstanceid = this.opts.modelinstanceid;
|
||||
d.modeltypeid = this.opts.modeltypeid;
|
||||
if (this.response_mode == 'stream' || this.response_mode == 'async') {
|
||||
d = {};
|
||||
d.messages = this.messages;
|
||||
d.model = this.opts.model;
|
||||
d.modelinstanceid = this.opts.modelinstanceid;
|
||||
d.modeltypeid = this.opts.modeltypeid;
|
||||
var d = this.inputdata2uploaddata(data);
|
||||
var hr = new bricks.HttpResponseStream();
|
||||
var resp = await hr.post(this.opts.url, {params:d});
|
||||
await hr.handle_chunk(resp, this.chunk_response.bind(this, mout));
|
||||
this.chunk_ended();
|
||||
} else {
|
||||
d = data
|
||||
d.model = this.opts.model;
|
||||
d.modelinstanceid = this.opts.modelinstanceid;
|
||||
d.modeltypeid = this.opts.modeltypeid;
|
||||
var d = this.inputdata2uploaddata(data);
|
||||
var hj = new bricks.HttpJson()
|
||||
var resp = await hj.post(this.opts.url, {params:d});
|
||||
if (this.response_mode == 'sync'){
|
||||
@ -302,8 +320,6 @@ bricks.LlmIO = class extends bricks.VBox {
|
||||
}
|
||||
async handle_input(event){
|
||||
var params = event.params;
|
||||
if (params.prompt)
|
||||
params.prompt = bricks.escapeSpecialChars(params.prompt);
|
||||
await this.show_input(params);
|
||||
for(var i=0;i<this.llmmodels.length;i++){
|
||||
var lm = this.llmmodels[i];
|
||||
@ -315,7 +331,12 @@ bricks.LlmIO = class extends bricks.VBox {
|
||||
}
|
||||
async show_input(params){
|
||||
var box = new bricks.HBox({width:'100%'});
|
||||
var w = await bricks.widgetBuild(this.input_view, this.o_w, params);
|
||||
var data = inputdata2dic(params);
|
||||
if (data.prompt){
|
||||
data.prompt = bricks.escapeSpecialChars(data.prompt);
|
||||
}
|
||||
console.log('data=', data, 'input_view=', this.input_view);
|
||||
var w = await bricks.widgetBuild(this.input_view, this.o_w, data);
|
||||
w.set_css(this.msg_css||'user_msg');
|
||||
w.set_css('filler');
|
||||
var img = new bricks.Icon({rate:2,url:this.user_icon||bricks_resource('imgs/user.png')});
|
||||
|
Loading…
Reference in New Issue
Block a user