mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 上下文、文件、ocr等进一步适配shamrock
This commit is contained in:
parent
46328a9716
commit
247f3e15d0
4 changed files with 70 additions and 33 deletions
31
apps/chat.js
31
apps/chat.js
|
|
@ -797,7 +797,7 @@ export class chatgpt extends plugin {
|
|||
* #chatgpt
|
||||
*/
|
||||
async chatgpt (e) {
|
||||
let msg = Version.isTrss ? e.msg : e.raw_message
|
||||
let msg = (Version.isTrss || e.adapter === 'shamrock') ? e.msg : e.raw_message
|
||||
let prompt
|
||||
if (this.toggleMode === 'at') {
|
||||
if (!msg || e.msg?.startsWith('#')) {
|
||||
|
|
@ -1669,7 +1669,11 @@ export class chatgpt extends plugin {
|
|||
let toSummaryFileContent
|
||||
try {
|
||||
if (e.source) {
|
||||
let msgs = e.isGroup ? await e.group.getChatHistory(e.source.seq, 1) : await e.friend.getChatHistory(e.source.time, 1)
|
||||
let seq = e.isGroup ? e.source.seq : e.source.time
|
||||
if (e.adapter === 'shamrock') {
|
||||
seq = e.source.message_id
|
||||
}
|
||||
let msgs = e.isGroup ? await e.group.getChatHistory(seq, 1) : await e.friend.getChatHistory(seq, 1)
|
||||
let sourceMsg = msgs[0]
|
||||
let fileMsgElem = sourceMsg.message.find(msg => msg.type === 'file')
|
||||
if (fileMsgElem) {
|
||||
|
|
@ -2127,6 +2131,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
}
|
||||
default: {
|
||||
// openai api
|
||||
let completionParams = {}
|
||||
if (Config.model) {
|
||||
completionParams.model = Config.model
|
||||
|
|
@ -2317,27 +2322,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
}
|
||||
}
|
||||
let img = []
|
||||
if (e.source) {
|
||||
// 优先从回复找图
|
||||
let reply
|
||||
if (e.isGroup) {
|
||||
reply = (await e.group.getChatHistory(e.source.seq, 1)).pop()?.message
|
||||
} else {
|
||||
reply = (await e.friend.getChatHistory(e.source.time, 1)).pop()?.message
|
||||
}
|
||||
if (reply) {
|
||||
for (let val of reply) {
|
||||
if (val.type === 'image') {
|
||||
console.log(val)
|
||||
img.push(val.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.img) {
|
||||
img.push(...e.img)
|
||||
}
|
||||
let img = await getImg(e)
|
||||
if (img.length > 0 && Config.extraUrl) {
|
||||
tools.push(new ImageCaptionTool())
|
||||
tools.push(new ProcessPictureTool())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue