mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
修复bing图片识别问题
This commit is contained in:
parent
eb2618b141
commit
8dab6fd0b5
1 changed files with 17 additions and 6 deletions
|
|
@ -410,7 +410,7 @@ export default class SydneyAIClient {
|
||||||
// }
|
// }
|
||||||
let maxConv = Config.maxNumUserMessagesInConversation
|
let maxConv = Config.maxNumUserMessagesInConversation
|
||||||
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')
|
const currentDate = moment().format('YYYY-MM-DDTHH:mm:ssZ')
|
||||||
const imageDate = await this.kblobImage(opts.imageUrl)
|
const imageDate = await this.kblobImage(opts.imageUrl, conversationId)
|
||||||
let argument0 = {
|
let argument0 = {
|
||||||
source,
|
source,
|
||||||
optionsSets,
|
optionsSets,
|
||||||
|
|
@ -880,20 +880,31 @@ export default class SydneyAIClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async kblobImage (url) {
|
async kblobImage (url, conversationId) {
|
||||||
if (!url) return false
|
if (!url) return false
|
||||||
|
if (!conversationId) return false
|
||||||
|
// 获取并转换图片为base64
|
||||||
|
let imgBase64
|
||||||
|
try {
|
||||||
|
const response = await fetch(url)
|
||||||
|
const arrayBuffer = await response.arrayBuffer()
|
||||||
|
const buffer = Buffer.from(arrayBuffer)
|
||||||
|
imgBase64 = buffer.toString('base64')
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
return false
|
||||||
|
}
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('knowledgeRequest', JSON.stringify({
|
formData.append('knowledgeRequest', JSON.stringify({
|
||||||
imageInfo: {
|
imageInfo: {},
|
||||||
url
|
|
||||||
},
|
|
||||||
knowledgeRequest: {
|
knowledgeRequest: {
|
||||||
invokedSkills: ['ImageById'],
|
invokedSkills: ['ImageById'],
|
||||||
subscriptionId: 'Bing.Chat.Multimodal',
|
subscriptionId: 'Bing.Chat.Multimodal',
|
||||||
invokedSkillsRequestData: { enableFaceBlur: true },
|
invokedSkillsRequestData: { enableFaceBlur: true },
|
||||||
convoData: { convoid: '', convotone: 'Creative' }
|
convoData: { convoid: conversationId, convotone: 'Creative' }
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
|
formData.append('imageBase64', imgBase64)
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
headers: {
|
headers: {
|
||||||
Referer: 'https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx'
|
Referer: 'https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue