Mon Jul 3 10:36:00 UTC 2023 inscode

上级 8f0300df
......@@ -98,6 +98,7 @@
// import { Configuration, OpenAIApi } from "openai"
import OpenAI from './js/openai.js'
import Config from './js/config.js'
import SDApi from './js/sd.js'
// import MarkdownItVue from 'markdown-it-vue'
// import 'markdown-it-vue/dist/markdown-it-vue.css'
......@@ -116,6 +117,7 @@ export default {
name: '加载中...',
userAvatarList: [],
robotAvatarList: [],
mode: 'draw',
message: [
// {"user": "User", "message": "创建一个用户表,要求分区"},
// {"user": "AI", "message": "在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:在GaussDB数据库中创建一个带有分区的用户表可以使用以下语句:"},
......@@ -211,16 +213,51 @@ export default {
return
}
if (this.indexClient) {
this.indexClient.query(this.prompt).then(res => {
this.getAnswer(res)
}).catch((err) => {
this.getAnswer()
})
if (this.mode === 'draw') {
this.draw()
} else {
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) {
this.loading = true
......
......@@ -19,8 +19,11 @@ export default {
"max_request_len":"10000",
"prompt_template":"",
"api_prompt_prefix":"",
"show_profile_setting":false
}
"show_profile_setting":false,
"sd_api": 'https://api.quickapi.cloud/sd/',
},
},
"message": "success"
}
......
export default {
draw (url, config) {
draw (config, prompt) {
debugger
return new Promise(function(resolve,rejcet){
debugger
const data = {
prompt: prompt,
steps: config?.steps??20,
negative_prompt: config?.negative_prompt??'',
width: config?.width??512,
height: config?.height??512,
cfg_scale: config?.cfg_scale??6,
seed : config?.seed??-1,
sampler_name: config?.sampler_name??"DPM++ SDE Karras"
}
const headers = {
'content-type': 'application/json'
};
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)
});
})
const data = {
prompt: config.prompt,
steps: config?.steps??20,
negative_prompt: config?.negative_prompt??'',
width: config?.width??512,
height: config?.height??512,
cfg_scale: config?.cfg_scale??6,
seed : config?.seed??-1,
sampler_name: config?.sampler_name??"DPM++ SDE Karras"
}
const headers = {
'content-type': 'application/json'
};
axios.post(url, data, { headers }).then(response => {
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册