This commit is contained in:
yumoqing 2024-07-18 18:25:42 +08:00
parent 0731970918
commit e3d7df7aea
2 changed files with 19 additions and 14 deletions

View File

@ -18,23 +18,27 @@ bricks.ModelOutput = class extends bricks.HBox {
this.run = new bricks.BaseRunning({target:this}); this.run = new bricks.BaseRunning({target:this});
this.add_widget(this.img); this.add_widget(this.img);
this.add_widget(this.run); this.add_widget(this.run);
this.filler = new bricks.VBox({});
this.filler.set_css('filler');
this.add_widget(this.filler);
this.add_widget(new bricks.BlankIcon({rate:2, flexShrink:0}));
this.build_estimate_widgets(); this.build_estimate_widgets();
} }
build_estimate_widgets(){ build_estimate_widgets(){
if (!this.estimate_url) return; if (!this.estimate_url) return;
this.estimate_w = new bricks.HBox({width:'100%', cheight:2}); this.estimate_w = new bricks.HBox({width:'100%', cheight:2});
txtw = new bricks.Text({ var txtw = new bricks.Text({
otext:'结果满意吗?', otext:'结果满意吗?',
i18n:true, i18n:true,
}); });
likew = new bricks.Icon({rate:2, url:bricks_resource('imgs/like.png')}); var likew = new bricks.Icon({rate:2, url:bricks_resource('imgs/like.png')});
unlikew = new bricks.Icon({rate:2, url:bricks_resource('imgs/unlike.png')}); var unlikew = new bricks.Icon({rate:2, url:bricks_resource('imgs/unlike.png')});
likew.bind('click', this.estimate_llm.bind(this, 1)); likew.bind('click', this.estimate_llm.bind(this, 1));
unlike.bind('click', this.estimate_llm.bind(this, -1)) unlikew.bind('click', this.estimate_llm.bind(this, -1))
this.estimate_w.add_widget(txtw); this.estimate_w.add_widget(txtw);
this.estimate_w.add_widget(likew); this.estimate_w.add_widget(likew);
this.estimate_w.add_widget(new bricks.BlankIcon({rate:1, flexShrink:0}));
this.estimate_w.add_widget(unlikew); this.estimate_w.add_widget(unlikew);
this.add_widget(this.estimate_w);
likew.set_style('cursor', 'pointer'); likew.set_style('cursor', 'pointer');
unlikew.set_style('cursor', 'pointer'); unlikew.set_style('cursor', 'pointer');
this.estimate_w.hide(); this.estimate_w.hide();
@ -57,21 +61,22 @@ bricks.ModelOutput = class extends bricks.HBox {
this.estimate_w.disabled(true); this.estimate_w.disabled(true);
} }
async update_data(data){ async update_data(data){
if (this.run) this.run.stop_timepass(); if (this.run) {
this.run.stop_timepass();
this.remove_widget(this.run);
}
this.run = null; this.run = null;
var w = await bricks.widgetBuild(this.output_view, this.llmio, data);
w.set_css('llm_msg');
this.filler.clear_widgets();
this.filler.add_widget(w);
this.filler.add_widget(this.estimate_w);
if (data.logid){ if (data.logid){
this.logid = data.logid; this.logid = data.logid;
if (this.estimate_url){ if (this.estimate_url){
this.estimate_w.show(); this.estimate_w.show();
} }
} }
var w = await bricks.widgetBuild(this.output_view, this.llmio, data);
w.set_css('llm_msg');
w.set_css('filler');
this.clear_widgets();
this.add_widget(this.img);
this.add_widget(w);
this.add_widget(new bricks.BlankIcon({rate:2, flexShrink:0}));
} }
} }

View File

@ -259,7 +259,7 @@ bricks.absurl = function(url, widget){
} }
var base_uri = widget.baseURI; var base_uri = widget.baseURI;
if (url.startsWith('/')){ if (url.startsWith('/')){
base_uri = Body.baseURI; base_uri = bricks.Body.baseURI;
url = url.substring(1); url = url.substring(1);
} }
paths = base_uri.split('/'); paths = base_uri.split('/');