🦄 refactor: 保留OCR结果

This commit is contained in:
RrOrange 2023-04-11 20:59:52 +08:00
parent 9cbc3f72ed
commit 7385898f97

View File

@ -163,16 +163,16 @@ export class tools extends plugin {
const ocrRst = await Bot.imageOcr(`${defaultPath}/temp.jpg`); const ocrRst = await Bot.imageOcr(`${defaultPath}/temp.jpg`);
const wordList = ocrRst.wordslist; const wordList = ocrRst.wordslist;
// OCR结果 // OCR结果
let prompt = wordList.map(item => item.words).join(" "); let OCRInfo = wordList.map(item => item.words).join(" ");
if (this.openaiAccessToken) { if (this.openaiAccessToken) {
// 构造输入 // 构造输入
const func = preMsg.msg.replace("#ocr", "").trim(); const func = preMsg.msg.replace("#ocr", "").trim();
prompt = PROMPT_MAP[func] + prompt; const prompt = PROMPT_MAP[func] + OCRInfo;
// 得到结果 // 得到结果
const response = await this.chatGptClient.sendMessage(prompt); const response = await this.chatGptClient.sendMessage(prompt);
prompt = response.response; OCRInfo = `${OCRInfo}\n-----------------\n${response.response}`;
} }
curMsg.reply(prompt); curMsg.reply(OCRInfo);
}); });
} catch (err) { } catch (err) {
curMsg.reply(" ❌OCR失败或者存在多账号竞争回答问题"); curMsg.reply(" ❌OCR失败或者存在多账号竞争回答问题");