Skip to content

Commit

Permalink
perf: 优化ai机器人
Browse files Browse the repository at this point in the history
  • Loading branch information
kuaifan committed Feb 29, 2024
1 parent 81690d6 commit 9133f28
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
2 changes: 2 additions & 0 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ public static function getAvatar($userid, $userimg, $email, $nickname)
return url("images/avatar/default_openai.png");
case '[email protected]':
return url("images/avatar/default_claude.png");
case '[email protected]':
return url("images/avatar/default_gemini.png");
case '[email protected]':
return url("images/avatar/default_bot.png");
case '[email protected]':
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ services:

ai:
container_name: "dootask-ai-${APP_ID}"
image: "kuaifan/dooai:0.1.4"
image: "kuaifan/dooai:0.1.8"
networks:
extnetwork:
ipv4_address: "${APP_IPPR}.12"
restart: unless-stopped

okr:
container_name: "dootask-okr-${APP_ID}"
image: "kuaifan/doookr:0.0.35"
image: "kuaifan/doookr:0.0.37"
environment:
TZ: "${TIMEZONE:-PRC}"
DOO_TASK_URL: "http://${APP_IPPR}.3"
Expand Down
65 changes: 62 additions & 3 deletions resources/assets/js/pages/manage/components/DialogWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,7 @@ export default {
approvaUserStatus: '',
observers: [],
msgChangeCache: {},
unreadOne: 0, // 最早未读消息id
topPosLoad: 0, // 置顶跳转加载中
Expand Down Expand Up @@ -1586,22 +1587,80 @@ export default {
this.sendMsg(`<p><span data-quick-key="${item.key}">${item.label}</span></p>`)
},
/**
* 消息变化处理
* @param data
*/
onMsgChange(data) {
const item = this.allMsgs.find(({type, id}) => type == "text" && id == data.id)
if (item) {
const {tail} = this.scrollInfo()
if (typeof this.msgChangeCache[data.id] === "undefined") {
this.msgChangeCache[data.id] = []
this.msgChangeCache[`${data.id}_load`] = false
}
if (data.type === 'append') {
item.msg.text += data.text
this.msgChangeCache[data.id].push(...`${data.text}`.split("").map(text => {
return {
type: 'append',
text
}
}))
} else if (data.type === 'replace') {
item.msg.text = data.text
this.msgChangeCache[data.id] = [{
type: 'replace',
text: data.text
}]
}
this.onMsgOutput(data.id, item.msg)
}
},
/**
* 追加或替换消息
* @param id
* @param msg
*/
onMsgOutput(id, msg) {
const load = `${id}_load`
const arr = this.msgChangeCache[id]
if (!arr || arr.length === 0) return
if (this.msgChangeCache[load] === true) return
this.msgChangeCache[load] = true
try {
const data = arr.shift()
if (!data) {
this.msgChangeCache[load] = false
return
}
const {type, text} = data
const {tail} = this.scrollInfo()
if (type === 'append') {
msg.text += text
} else if (type === 'replace') {
msg.text = text
}
this.$nextTick(_ => {
if (tail <= 10 && tail != this.scrollInfo().tail) {
this.operatePreventScroll++
this.$refs.scroller.scrollToBottom()
setTimeout(_ => this.operatePreventScroll--, 50)
}
if (arr.length === 0) {
this.msgChangeCache[load] = false
return
}
setTimeout(_ => {
this.msgChangeCache[load] = false
this.onMsgOutput(id, msg)
}, 5)
})
} catch (e) {
this.msgChangeCache[load] = false
}
},
Expand Down

0 comments on commit 9133f28

Please sign in to comment.