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