Thu Jul 13 19:31:00 CST 2023 inscode

上级 56bb00e0
...@@ -88,7 +88,7 @@ ...@@ -88,7 +88,7 @@
<img v-if="item.img" :src="item.img"/> <img v-if="item.img" :src="item.img"/>
<img v-else src="/loading.gif" class="w-[512px]"/> <img v-else src="/loading.gif" class="w-[512px]"/>
</template> </template>
<template> <template v-else>
{{ item.message ? item.message : '...' }} {{ item.message ? item.message : '...' }}
</template> </template>
...@@ -446,7 +446,11 @@ export default { ...@@ -446,7 +446,11 @@ export default {
StorageApi.get(this.history.name).then(data => { StorageApi.get(this.history.name).then(data => {
if (data && data.data) { if (data && data.data) {
this.message = JSON.parse(data.data) const historyMessage = JSON.parse(data.data)
if (historyMessage !== null && historyMessage.length > 0) {
this.message = historyMessage
}
} }
}) })
}, },
...@@ -498,16 +502,16 @@ export default { ...@@ -498,16 +502,16 @@ export default {
if (type === 'common') { if (type === 'common') {
this.sdServerUrl = this.config.common_gpt_api this.sdServerUrl = this.config.common_gpt_url
} }
this.saveConfig() this.saveConfig()
}, },
recoverConfig () { recoverConfig () {
const config = localStorage.getItem('ai-docs-config') const config = localStorage.getItem('ai-docs-config')
debugger
if (config) { if (config) {
const configJSON = JSON.parse(config) const configJSON = JSON.parse(config)
this.config = configJSON this.config = configJSON
this.sdServerType = configJSON.sdServerType
this.sdServerUrl = configJSON.sdServerUrl this.sdServerUrl = configJSON.sdServerUrl
this.sdServerType = configJSON.sdServerType??'common' this.sdServerType = configJSON.sdServerType??'common'
...@@ -516,7 +520,7 @@ export default { ...@@ -516,7 +520,7 @@ export default {
document.title = this.name document.title = this.name
if (data.ext && data.ext.common_sd_api && this.sdServerType === 'common') { if (data.ext && data.ext.common_gpt_url && this.sdServerType === 'common') {
this.config.common_gpt_url = data.ext.common_gpt_url this.config.common_gpt_url = data.ext.common_gpt_url
this.sdServerUrl = data.ext.common_gpt_url this.sdServerUrl = data.ext.common_gpt_url
} }
...@@ -555,6 +559,7 @@ export default { ...@@ -555,6 +559,7 @@ export default {
if (this.mode === 'chat') { if (this.mode === 'chat') {
this.initAIClient() this.initAIClient()
this.initIndexClient() this.initIndexClient()
this.prompt = this.config.default_prompt
} }
} }
......
...@@ -11,7 +11,7 @@ class OpenAI { ...@@ -11,7 +11,7 @@ class OpenAI {
} }
createCompletion (prompt, history, context, callback) { createCompletion (prompt, history, context, callback) {
debugger
const config = this.config const config = this.config
const abortController = new AbortController(); const abortController = new AbortController();
...@@ -41,6 +41,7 @@ class OpenAI { ...@@ -41,6 +41,7 @@ class OpenAI {
stop: stop_key stop: stop_key
// prefix: prefix // prefix: prefix
} }
if (mode === 'chat') { if (mode === 'chat') {
data.messages = Prompt.getPromptByChatMode(config, context, history) data.messages = Prompt.getPromptByChatMode(config, context, history)
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册