From 56bb00e0f287d28e2f09935be6dcd770320dcf19 Mon Sep 17 00:00:00 2001 From: 622aa39c1f9b166ab1a38c05 <622aa39c1f9b166ab1a38c05@devide> Date: Thu, 13 Jul 2023 18:32:00 +0800 Subject: [PATCH] Thu Jul 13 18:32:00 CST 2023 inscode --- src/App.vue | 43 +++++++++++++++++++++++++------------------ src/js/config.js | 4 ++-- src/js/openai.js | 1 + 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1adb12e..22dffa6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -284,15 +284,30 @@ export default { return } + this.loading = true + + if (this.mode === 'draw') { this.draw() } else { + + const _this = this + const messages = this.message + const currentMsg = { + "user": "AI", "message": '' + } + const newPrompt = this.prompt + this.prompt = '' + messages.push({ "user": "User", "message": newPrompt }) + messages.push(currentMsg) + _this.$refs.messageList.scrollTop = _this.$refs.messageList.scrollHeight; + if (this.indexClient) { - this.indexClient.query(this.prompt).then(res => { - this.getAnswer(res) + this.indexClient.query(newPrompt).then(res => { + this.getAnswer(res, newPrompt, currentMsg) }).catch((err) => { - this.getAnswer() + this.getAnswer(null, newPrompt, currentMsg) }) } } @@ -358,21 +373,13 @@ export default { _this.loading = false }) }, - getAnswer(context) { - this.loading = true + getAnswer(context = null, prompt = null, currentMsg = null) { + + + const newPrompt = prompt ? prompt : this.prompt const _this = this + this.config.api_url = this.sdServerUrl const messages = this.message - const currentMsg = { - "user": "AI", "message": '' - } - messages.push({ "user": "User", "message": this.prompt }) - messages.push(currentMsg) - _this.$refs.messageList.scrollTop = _this.$refs.messageList.scrollHeight; - const newPrompt = this.prompt - console.info(this.prompt) - console.info(newPrompt) - this.prompt = '' - this.client.createCompletion( newPrompt, this.message, @@ -490,7 +497,7 @@ export default { handleSDServerTypeChange (type) { if (type === 'common') { - debugger + this.sdServerUrl = this.config.common_gpt_api } this.saveConfig() @@ -509,7 +516,7 @@ export default { document.title = this.name - if (data.ext && data.ext.common_sd_api) { + if (data.ext && data.ext.common_sd_api && this.sdServerType === 'common') { this.config.common_gpt_url = data.ext.common_gpt_url this.sdServerUrl = data.ext.common_gpt_url } diff --git a/src/js/config.js b/src/js/config.js index 8947e11..9d7962a 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -10,8 +10,8 @@ export default { "resource_type": "app", "ext": { "mode":"chat", - "model":"chatgl2-6b", - "common_gpt_url":"https://api.quickapi.cloud/temporary/gpt/", + "model":"chatglm2-6b", + "common_gpt_url":"https://api.quickapi.cloud/temporary/gpt", "api_type":"openai", "robot_img":null, "api_max_token":"2048", diff --git a/src/js/openai.js b/src/js/openai.js index 733b496..0781473 100644 --- a/src/js/openai.js +++ b/src/js/openai.js @@ -11,6 +11,7 @@ class OpenAI { } createCompletion (prompt, history, context, callback) { + debugger const config = this.config const abortController = new AbortController(); -- GitLab