Agent 消息处理
· One min read
AI tag description
View All Tags如何对流失数据优化,提高渲染性能。从以下两点切入:
懒加载渲染: 可视区外部的信息不用渲染,当滚动到可视区时再渲染。 注意,此时需要一个buff来缓冲渲染到页面的信息,防止给用户造成流暂停的假象。
增量式渲染: 已经渲染到页面上的数据不用重复渲染,只渲染新增的数据。
核心数据结构: 消息列表 (messages)
核心操作:调用模型接口,生成消息
次要操作:复制、引用、重新生成、编辑、参考附件选择
UI:聚合上操作以及数据
class CoreUI {
useMessage(){
// connect to message
return this
}
useHandle(){
// connect to handle
return this
}
useChat(){
// connect to AI
return this
}
render(){
// render ui
return <></>
}
}
new CoreUI().useMessage().useHandle().useChat().render();
Server-Send-Event: data is flowing from server to client format: tag:string for example:
data: "{ name: 'marvin', age: 20 }"
在SSE中 数据以固定的格式传输到客户端,在使用之前客户端或许需要先进行解析。