diff --git a/bricks/build.sh b/bricks/build.sh old mode 100644 new mode 100755 diff --git a/bricks/input.js b/bricks/input.js index 1e039cc..8e959fd 100644 --- a/bricks/input.js +++ b/bricks/input.js @@ -360,7 +360,12 @@ bricks.UiImage =class extends bricks.VBox { this.imgw = null; } take_photo(){ - var camera = new bricks.Camera({}); + var camera = new bricks.Camera({ + "archor":"cc", + "auto_open":true, + "height":"90%", + "width":"90%" + }); camera.bind('shot', function(d){ if (this.imgw){ this.remove_widget(this.imgw); diff --git a/bricks/llm.js b/bricks/llm.js index 0095bf3..4cab3d2 100644 --- a/bricks/llm.js +++ b/bricks/llm.js @@ -157,9 +157,7 @@ bricks.LlmModel = class extends bricks.JsWidget { constructor(llmio, opts){ super(opts); this.llmio = llmio; - if (opts.use_session){ - this.messages = []; - } + this.messages = []; } render_title(){ var w = new bricks.HBox({}); @@ -174,6 +172,9 @@ bricks.LlmModel = class extends bricks.JsWidget { } async model_inputed(data){ + if (!opts.use_session){ + this.messages = []; + } var mout = new bricks.ModelOutput({ textvoice:this.textvoice, tts_url:this.tts_url, @@ -184,20 +185,12 @@ bricks.LlmModel = class extends bricks.JsWidget { var fmt = this.opts.user_message_format || { role:'user', content:'${prompt}'}; var umsg = bricks.apply_data(fmt, data); var d = data; - if (this.messages){ - this.messages.push(umsg); - d = bricks.extend({}, data); - d.messages = this.messages; - d.model = this.opts.model; - d.modelinstanceid = this.opts.modelinstanceid; - d.modeltypeid = this.opts.modeltypeid; - } else { - d = bricks.extend({}, data); - d.model = this.opts.model; - d.mapi = this.mapi; - d.modelinstanceid = this.opts.modelinstanceid; - d.modeltypeid = this.opts.modeltypeid; - } + this.messages.push(umsg); + d = {}; + d.messages = this.messages; + d.model = this.opts.model; + d.modelinstanceid = this.opts.modelinstanceid; + d.modeltypeid = this.opts.modeltypeid; console.log('upload data=', d, this.options); if (this.response_mode == 'stream' || this.response_mode == 'async') { var hr = new bricks.HttpResponseStream(); diff --git a/bricks/llm_dialog.js b/bricks/llm_dialog.js index 6d29df2..7c3aabe 100644 --- a/bricks/llm_dialog.js +++ b/bricks/llm_dialog.js @@ -96,13 +96,12 @@ bricks.LlmMsgBox = class extends bricks.HBox { var d = { messages:this.messages, mapi:this.mapi, - prompt:prompt, model:this.model, } // console.log('messages=', this.messages, 'msg=', msg, 'umsg=', umsg); if (this.response_mode == 'stream') { var hr = new bricks.HttpResponseStream(); - var resp = await hr.post(this.url, {params:d}); + var resp = await hr.post(this.url, {data:d}); this.responsed(); await hr.handle_chunk(resp, this.chunk_response.bind(this)); this.chunk_ended();