Mon Jul 3 10:36:00 UTC 2023 inscode

上级 8f0300df
...@@ -98,6 +98,7 @@ ...@@ -98,6 +98,7 @@
// import { Configuration, OpenAIApi } from "openai" // import { Configuration, OpenAIApi } from "openai"
import OpenAI from './js/openai.js' import OpenAI from './js/openai.js'
import Config from './js/config.js' import Config from './js/config.js'
import SDApi from './js/sd.js'
// import MarkdownItVue from 'markdown-it-vue' // import MarkdownItVue from 'markdown-it-vue'
// import 'markdown-it-vue/dist/markdown-it-vue.css' // import 'markdown-it-vue/dist/markdown-it-vue.css'
...@@ -116,6 +117,7 @@ export default { ...@@ -116,6 +117,7 @@ export default {
name: '加载中...', name: '加载中...',
userAvatarList: [], userAvatarList: [],
robotAvatarList: [], robotAvatarList: [],
mode: 'draw',
message: [ message: [
// {"user": "User", "message": "创建一个用户表,要求分区"}, // {"user": "User", "message": "创建一个用户表,要求分区"},
// {"user": "AI", "message": "在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:"}, // {"user": "AI", "message": "在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:"},
...@@ -211,16 +213,51 @@ export default { ...@@ -211,16 +213,51 @@ export default {
return return
} }
if (this.indexClient) { if (this.mode === 'draw') {
this.indexClient.query(this.prompt).then(res => { this.draw()
this.getAnswer(res)
}).catch((err) => {
this.getAnswer()
})
} else { } else {
this.getAnswer() this.getAnswer()
} }
// if (this.indexClient) {
// this.indexClient.query(this.prompt).then(res => {
// this.getAnswer(res)
// }).catch((err) => {
// this.getAnswer()
// })
// } else {
// this.getAnswer()
// }
},
draw () {
if (this.prompt) {
}
const currentMsg = {
"user": "AI", "message": '', img: null, viewMode: 'image'
}
const query = this.prompt
const _this = this
const messages = this.message
messages.push(currentMsg)
this.loading = true
this.prompt = ''
SDApi.draw(this.config, query).then(res => {
debugger
_this.loading = false
_this.saveHistory()
console.info('close')
currentMsg.img = res
messages.splice(messages.length - 1, 1)
messages.push(currentMsg)
}).catch(err => {
_this.loading = false
})
}, },
getAnswer(context) { getAnswer(context) {
this.loading = true this.loading = true
......
...@@ -19,8 +19,11 @@ export default { ...@@ -19,8 +19,11 @@ export default {
"max_request_len":"10000", "max_request_len":"10000",
"prompt_template":"", "prompt_template":"",
"api_prompt_prefix":"", "api_prompt_prefix":"",
"show_profile_setting":false "show_profile_setting":false,
} "sd_api": 'https://api.quickapi.cloud/sd/',
},
}, },
"message": "success" "message": "success"
} }
......
export default { export default {
draw (url, config) { draw (config, prompt) {
debugger
return new Promise(function(resolve,rejcet){
debugger
const data = { const data = {
prompt: config.prompt, prompt: prompt,
steps: config?.steps??20, steps: config?.steps??20,
negative_prompt: config?.negative_prompt??'', negative_prompt: config?.negative_prompt??'',
width: config?.width??512, width: config?.width??512,
...@@ -16,10 +17,22 @@ export default { ...@@ -16,10 +17,22 @@ export default {
'content-type': 'application/json' 'content-type': 'application/json'
}; };
axios.post(url, data, { headers }).then(response => { axios.post(config?.sd_api, data, { headers }).then(response => {
debugger
if (response.statusCode === 200 && response?.data?.images){
const image = res?.data?.images[0]
resolve('data:image/png;base64,' + image)
}
}).catch(err => {
rejcet(err)
}); });
})
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册