diff --git a/bricks/jsoncall.js b/bricks/jsoncall.js index d482947..24f6be6 100755 --- a/bricks/jsoncall.js +++ b/bricks/jsoncall.js @@ -94,7 +94,7 @@ bricks.HttpText = class { var data = this.add_own_params(params); var header = this.add_own_headers(headers); var _params = { - "method":method, + method:method } // _params.headers = headers; if (method == 'GET' || method == 'HEAD') { diff --git a/bricks/llm.js b/bricks/llm.js index d69bbdb..4413ea1 100644 --- a/bricks/llm.js +++ b/bricks/llm.js @@ -57,7 +57,7 @@ bricks.ModelOutput = class extends bricks.HBox { var icon = event.target.bricks_widget; icon.rate = 2; icon.charsize_sizing(); - w = await bricks.widgetBuild(desc, this); + var w = await bricks.widgetBuild(desc, this); this.estimate_w.disabled(true); } async update_data(data){ @@ -65,6 +65,7 @@ bricks.ModelOutput = class extends bricks.HBox { this.run.stop_timepass(); this.remove_widget(this.run); } + console.log('update_data():data=', data); this.run = null; var w = await bricks.widgetBuild(this.output_view, this.llmio, data); w.set_css('llm_msg'); @@ -140,7 +141,7 @@ bricks.LlmModel = class extends bricks.JsWidget { d.modeltypeid = this.opts.modeltypeid; } console.log('upload data=', d, this.options); - if (this.response_mode == 'stream') { + if (this.response_mode == 'stream' || this.response_mode == 'async') { 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)); @@ -177,6 +178,7 @@ bricks.LlmModel = class extends bricks.JsWidget { d.content = bricks.escapeSpecialChars(d.content); this.resp_data = d; mout.update_data(d); + console.log('stream data=', d); } chunk_ended(){ if (! this.messages) { diff --git a/bricks/video.js b/bricks/video.js index 96cb6a1..fd68fde 100755 --- a/bricks/video.js +++ b/bricks/video.js @@ -39,7 +39,6 @@ bricks.Video = class extends bricks.Layout { this.hidedbtn = new bricks.Button({text:'click me'}); this.hidedbtn.hide(); this.add_widget(this.hidedbtn); - this.hidedbtn.bind('click', this.play.bind(this)); } destroy_resource(params, event){ var w = event.target.bricks_widget; @@ -61,24 +60,25 @@ bricks.Video = class extends bricks.Layout { } } auto_play(){ - this.hidedbtn.dispatch('click'); schedule_once(this.disable_captions.bind(this), 2); this.player.on('error',this.report_error.bind(this)); this.player.on('play', this.report_playok.bind(this)); this.player.on('ended', this.report_ended.bind(this)); + this.hidedbtn.dispatch('click'); } play(){ this.player.play(); } create_player(){ - this.player = videojs(this.video_body.dom_element, { - controls:true, - nativeTextTracks:false, - textTrackSettings: false - }); - - this.player.ready(this.auto_play.bind(this)); - this._set_source(); + if(this.url){ + this.player = videojs(this.video_body.dom_element, { + controls:true, + nativeTextTracks:false, + textTrackSettings: false + }); + this.player.ready(this.auto_play.bind(this)); + this._set_source(); + } } report_ended(){ this.dispatch('play_end',{src:this.video_body.cur_url,type:this.video_body.cur_vtype}); @@ -92,15 +92,19 @@ bricks.Video = class extends bricks.Layout { this.dispatch('play_failed', {'src':this.video_body.cur_url, type:this.video_body.cur_vtype}); } _set_source(){ - this.player.src({ - src:this.video_body.cur_url, - type:this.video_body.cur_vtype - }); + if (this.player){ + this.player.src({ + src:this.video_body.cur_url, + type:this.video_body.cur_vtype + }); + } } set_source(url, vtype){ - this.video_body.cur_url = url; - this.video_body.cur_vtype = vtype; - this._set_source(); + if(this.player){ + this.video_body.cur_url = url; + this.video_body.cur_vtype = vtype; + this._set_source(); + } } }