bugfix
This commit is contained in:
parent
b43d2e7cbd
commit
bd706943ce
119
bricks/llmout.js
119
bricks/llmout.js
@ -77,17 +77,54 @@ bricks.LlmOut = class extends bricks.VBox {
|
|||||||
super(opts);
|
super(opts);
|
||||||
this.rc_w = null;
|
this.rc_w = null;
|
||||||
this.c_w = null;
|
this.c_w = null;
|
||||||
this.v_w = null;
|
|
||||||
this.i_w = null;
|
|
||||||
this.a_w = null;
|
|
||||||
this.glb_w = null;
|
|
||||||
this.s_w = null; // 状态
|
this.s_w = null; // 状态
|
||||||
|
this.videos = [];
|
||||||
|
this.glbs = [];
|
||||||
|
this.audios = []
|
||||||
this.images = [];
|
this.images = [];
|
||||||
this.reasoning_content = '';
|
this.reasoning_content = '';
|
||||||
this.content = '';
|
this.content = '';
|
||||||
this.error = '';
|
this.error = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render_video(v){
|
||||||
|
var w = new bricks.VideoPlayer({
|
||||||
|
width: '100%',
|
||||||
|
url: v,
|
||||||
|
autoplay: true
|
||||||
|
});
|
||||||
|
this.add_widget(w);
|
||||||
|
}
|
||||||
|
render_glb(glb){
|
||||||
|
var w = new bricks.GlbViewer({
|
||||||
|
url:glb,
|
||||||
|
width: '100%'
|
||||||
|
});
|
||||||
|
this.add_widget(w);
|
||||||
|
}
|
||||||
|
render_audio(a){
|
||||||
|
var url = a;
|
||||||
|
if (! url.startsWith('http')){
|
||||||
|
if (! url.startsWith('data:audio/')){
|
||||||
|
url = 'data:audio/wav;base64,' + url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var w = new bricks.AudioPlayer({
|
||||||
|
width: '100%',
|
||||||
|
autoplay: true,
|
||||||
|
url: url,
|
||||||
|
cheight:2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.add_widget(w);
|
||||||
|
}
|
||||||
|
render_image(i){
|
||||||
|
var w = new bricks.Image({
|
||||||
|
width: '100%',
|
||||||
|
url: i
|
||||||
|
});
|
||||||
|
this.add_widget(w);
|
||||||
|
}
|
||||||
update(data){
|
update(data){
|
||||||
if (data.status){
|
if (data.status){
|
||||||
this.s_w = new bricks.Text({
|
this.s_w = new bricks.Text({
|
||||||
@ -97,38 +134,31 @@ bricks.LlmOut = class extends bricks.VBox {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (data.audio){
|
if (data.audio){
|
||||||
var url = data.audio;
|
if (Array.isArray(data.audio)){
|
||||||
if (! data.audio.startsWith('http')){
|
this.audios.concat(data.audio);
|
||||||
if (! data.audio.startsWith('data:audio/')){
|
|
||||||
url = 'data:audio/wav;base64,' + url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.a_w) {
|
|
||||||
this.a_w = new bricks.AudioPlayer({
|
|
||||||
width: '100%',
|
|
||||||
autoplay: true,
|
|
||||||
url: url,
|
|
||||||
cheight:2
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.a_w.add_url(url);
|
this.audios.push(data.audio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.glb){
|
if (data.glb){
|
||||||
this.glb_w = new bricks.GlbViewer({
|
if (Array.isArray(data.glb)){
|
||||||
url:data.glb,
|
this.glbs.concat(data.glb);
|
||||||
width: '100%'
|
} else {
|
||||||
});
|
this.glbs.push(data.glb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (data.video){
|
if (data.video){
|
||||||
if (!this.v_w){
|
if (Array.isArray(data.video)){
|
||||||
this.v_w = new bricks.VideoPlayer({
|
this.videos.concat(data.video);
|
||||||
width: '100%',
|
|
||||||
url: data.video,
|
|
||||||
autoplay: true
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
this.v_w.add_url(data.video);
|
this.videos.push(data.video);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (data.image){
|
||||||
|
if (Array.isArray(data.image)){
|
||||||
|
this.images.concat(data.image);
|
||||||
|
} else {
|
||||||
|
this.images.push(data.image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (data.error){
|
if (data.error){
|
||||||
@ -140,13 +170,6 @@ bricks.LlmOut = class extends bricks.VBox {
|
|||||||
if (data.content){
|
if (data.content){
|
||||||
this.content += data.content;
|
this.content += data.content;
|
||||||
}
|
}
|
||||||
if (data.image){
|
|
||||||
if (Array.isArray(data.image)){
|
|
||||||
this.images.concat(data.image);
|
|
||||||
} else {
|
|
||||||
this.images.push(data.image);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.clear_widgets();
|
this.clear_widgets();
|
||||||
if (this.error.length) {
|
if (this.error.length) {
|
||||||
var txt = bricks.escapeSpecialChars(this.error);
|
var txt = bricks.escapeSpecialChars(this.error);
|
||||||
@ -178,23 +201,17 @@ bricks.LlmOut = class extends bricks.VBox {
|
|||||||
});
|
});
|
||||||
this.add_widget(this.c_w);
|
this.add_widget(this.c_w);
|
||||||
}
|
}
|
||||||
if (this.v_w) {
|
this.videos.forEach(v => {
|
||||||
this.add_widget(this.v_w);
|
this.render_video(v);
|
||||||
|
})
|
||||||
|
this.glbs.forEach(glb => {
|
||||||
|
this.render_glb(glb);
|
||||||
}
|
}
|
||||||
if (this.glb_w){
|
this.audios.forEach(a => {
|
||||||
this.add_widget(this.glb_w);
|
this.render_audio(a);
|
||||||
}
|
}
|
||||||
if (this.a_w) {
|
this.imges.forEach(i => {
|
||||||
this.add_widget(this.a_w);
|
this.render_image(i);
|
||||||
}
|
|
||||||
if (this.images.length){
|
|
||||||
this.images.forEach( i => {
|
|
||||||
var w = new bricks.Image({
|
|
||||||
width: '100%',
|
|
||||||
url: i
|
|
||||||
});
|
|
||||||
this.add_widget(w)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if(this.s_w){
|
if(this.s_w){
|
||||||
this.add_widget(this.s_w);
|
this.add_widget(this.s_w);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user