mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +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
|
||||
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 = {
|
||||
source,
|
||||
optionsSets,
|
||||
|
|
@ -880,20 +880,31 @@ export default class SydneyAIClient {
|
|||
}
|
||||
}
|
||||
|
||||
async kblobImage (url) {
|
||||
async kblobImage (url, conversationId) {
|
||||
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()
|
||||
formData.append('knowledgeRequest', JSON.stringify({
|
||||
imageInfo: {
|
||||
url
|
||||
},
|
||||
imageInfo: {},
|
||||
knowledgeRequest: {
|
||||
invokedSkills: ['ImageById'],
|
||||
subscriptionId: 'Bing.Chat.Multimodal',
|
||||
invokedSkillsRequestData: { enableFaceBlur: true },
|
||||
convoData: { convoid: '', convotone: 'Creative' }
|
||||
convoData: { convoid: conversationId, convotone: 'Creative' }
|
||||
}
|
||||
}))
|
||||
formData.append('imageBase64', imgBase64)
|
||||
const fetchOptions = {
|
||||
headers: {
|
||||
Referer: 'https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue