aichat機能について修正(デフォルトをGemini API Flash 2.0 expに変更など)

- Gemini APIを基本Flash使用に変更
- Flashのバージョンを2.0 expに変更
- Flash, PRO指定時の不正な文章を修正
This commit is contained in:
tetsuya-ki 2025-01-05 17:58:30 +09:00
parent 59ac631527
commit fd76c424e8

View file

@ -32,9 +32,12 @@ type AiChatHist = {
const KIGO = '&';
const TYPE_GEMINI = 'gemini';
const GEMINI_PRO = 'gemini-pro';
const GEMINI_FLASH = 'gemini-flash';
const TYPE_PLAMO = 'plamo';
const GEMINI_15_FLASH_API = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent';
const GEMINI_20_FLASH_API = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent';
// const GEMINI_15_FLASH_API = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent';
const GEMINI_15_PRO_API = 'https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro:generateContent';
const PLAMO_API = 'https://platform.preferredai.jp/api/completion/v1/chat/completions';
@ -397,11 +400,20 @@ export default class extends Module {
if (config.prompt) {
prompt = config.prompt;
}
const reName = RegExp(this.name, "i");
const reKigoType = RegExp(KIGO + exist.type, "i");
const reName = RegExp(this.name, 'i');
let reKigoType = RegExp(KIGO + exist.type, 'i');
const extractedText = msg.extractedText;
if (extractedText == undefined || extractedText.length == 0) return false;
// Gemini API用にAPIのURLと置き換え用タイプを変更
if (msg.includes([KIGO + GEMINI_FLASH])) {
exist.api = GEMINI_20_FLASH_API;
reKigoType = RegExp(KIGO + GEMINI_FLASH, 'i');
} else if (msg.includes([KIGO + GEMINI_PRO])) {
exist.api = GEMINI_15_PRO_API;
reKigoType = RegExp(KIGO + GEMINI_PRO, 'i');
}
const question = extractedText
.replace(reName, '')
.replace(reKigoType, '')
@ -417,12 +429,12 @@ export default class extends Module {
aiChat = {
question: question,
prompt: prompt,
api: GEMINI_15_PRO_API,
api: GEMINI_20_FLASH_API,
key: config.geminiProApiKey,
history: exist.history
};
if (msg.includes([KIGO + 'gemini-flash']) || (exist.api && exist.api === GEMINI_15_FLASH_API)) {
aiChat.api = GEMINI_15_FLASH_API;
if (exist.api) {
aiChat.api = exist.api
}
text = await this.genTextByGemini(aiChat, base64Image);
break;