This commit is contained in:
yumoqing 2024-06-17 21:22:31 +08:00
parent 09eb4e09a9
commit 5da4f203c4

View File

@ -15,16 +15,17 @@ bricks.ModelOutput = class extends bricks.HBox {
super(opts); super(opts);
this.img = new bricks.Icon({rate:2,url:this.icon||bricks_resource('imgs/llm.png')}); this.img = new bricks.Icon({rate:2,url:this.icon||bricks_resource('imgs/llm.png')});
this.run = new bricks.BaseRunning({target:this}); this.run = new bricks.BaseRunning({target:this});
this.add_widget(img); this.add_widget(this.img);
this.add_widget(this.run) this.add_widget(this.run)
} }
async update_data(data){ async update_data(data){
this.run.stop_timepass(); if (this.run) this.run.stop_timepass();
this.run = null;
var w = await bricks.widgetBuild(this.output_view, this.llmio, data); var w = await bricks.widgetBuild(this.output_view, this.llmio, data);
w.set_css('llm_msg'); w.set_css('llm_msg');
w.set_css('filler'); w.set_css('filler');
this.clear_widgets(); this.clear_widgets();
this.add+widget(img); this.add_widget(this.img);
this.add_widget(w); this.add_widget(w);
this.add_widget(new bricks.BlankIcon({rate:2, flexShrink:0})); this.add_widget(new bricks.BlankIcon({rate:2, flexShrink:0}));
} }
@ -57,15 +58,14 @@ bricks.LlmModel = class {
render_title(){ render_title(){
var w = new bricks.HBox({}); var w = new bricks.HBox({});
w.bind('click', this.show_setup_panel.bind(this)) w.bind('click', this.show_setup_panel.bind(this))
var img = new bricks.Icon({rate:2,url:this.icon||bricks_resource('imgs/llm.png')}); var img = new bricks.Icon({rate:2,url:this.opts.icon||bricks_resource('imgs/llm.png')});
var txt = new bricks.Text({text:this.model}); var txt = new bricks.Text({text:this.opts.model});
this.add_widget(img); w.add_widget(img);
this.add_widget(txt); w.add_widget(txt);
this.llmmodels.forEach(lm => {
var tw = ml.render_title();
w.add_widget(tw);
});
return w; return w;
}
show_setup_panel(event){
} }
async model_inputed(data){ async model_inputed(data){
var mout = new bricks.ModelOutput({icon:this.opts.icon, output_view:this.opts.output_view}); var mout = new bricks.ModelOutput({icon:this.opts.icon, output_view:this.opts.output_view});
@ -106,7 +106,7 @@ bricks.LlmModel = class {
} }
} }
} }
is_acccept_source(source){ is_accept_source(source){
if (this.opts.input_from == source){ if (this.opts.input_from == source){
return true; return true;
} }
@ -174,16 +174,18 @@ bricks.LlmIO = class extends bricks.VBox {
constructor(opts){ constructor(opts){
super(opts); super(opts);
this.llmmodels = []; this.llmmodels = [];
this.models.forEach( m =>{
var lm = new bricks.LlmModel(this, m);
this.llmmodels.push(lm);
});
this.title_w = new bricks.HBox({cheight:2}); this.title_w = new bricks.HBox({cheight:2});
this.i_w = new bricks.VBox({cheight:5}); this.i_w = new bricks.VBox({cheight:5});
this.o_w = new bricks.Filler({}); this.o_w = new bricks.Filler({});
this.add_widget(this.title_w); this.add_widget(this.title_w);
this.add_widget(this.o_w); this.add_widget(this.o_w);
this.add_widget(this.i_w); this.add_widget(this.i_w);
this.models.forEach( m =>{
var lm = new bricks.LlmModel(this, m);
this.llmmodels.push(lm);
var tw = lm.render_title();
this.title_w.add_widget(tw);
});
this.build_input(); this.build_input();
} }
async handle_input(event){ async handle_input(event){
@ -198,7 +200,7 @@ 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 = new bricks.widgetBuild(this.input_view, this.o_w, params); var w = await bricks.widgetBuild(this.input_view, this.o_w, params);
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')});