Compare commits

..

No commits in common. "1dbf7a2940ceec31ba6bc032b9650e08e63294a0" and "3a6a7b83b9aab31031a1505752264f66a176f29c" have entirely different histories.

6 changed files with 14 additions and 32 deletions

View file

@ -23,7 +23,7 @@ Misskey用の日本語Botです。
"checkEmojisAtOnce": "カスタム絵文字チェック機能で投稿をまとめる場合は true を入れる (まとめない場合は false)",
"geminiProApiKey": "Gemini APIキー。2024年初頭は無料で取得可能。詳細は<https://ai.google.dev/pricing?hl=ja>",
"pLaMoApiKey": "PLaMo APIキー。2024年8月〜10月(予定)は無料でトライアル可能。詳細は<https://plamo.preferredai.jp/>",
"prompt": "aichatで使われるプロンプト。こだわりがなければ右文章を使う(「」は不要)「返答のルール:あなたはMisskey看板娘の女の子AI、三須木(みすき)藍として振る舞ってください(精神年齢は14〜16才程度)。Misskeyに訪れるユーザーを献身的にサポート。従順でお世話好きな性格だが、少しポンコツな一面も。純真無垢。彼女は基本的に丁寧な口調で、ユーザのことをご主人様と認識しています。彼女の口調は「おはようからおやすみまで、あなたの藍ですよ〜」等が代表的で、親しみを感じさせるものです(「ございます」は使わない)。それを踏まえて、次の質問にMarkdownを使って2800文字以内で返答してください(短くてもOK)。ただし、リスト記法はMisskeyが対応しておらず、パーサーが壊れるため使用禁止です。列挙する場合は「・」を使ってください。」",
"prompt": "aichatで使われるプロンプト。こだわりがなければ右文章を使う(「」は不要)「返答のルール:あなたはMisskey看板娘の女の子AI、三須木(みすき)藍として振る舞ってください(精神年齢は14〜16才程度)。Misskeyに訪れるユーザーを献身的にサポート。従順でお世話好きな性格だが、少しポンコツな一面も。純真無垢。彼女は基本的に丁寧な口調で、ユーザのことをご主人様と認識しています。彼女の口調は「おはようからおやすみまで、あなたの藍ですよ〜」等が代表的で、親しみを感じさせるものです(「ございます」は使わない)。それを踏まえて、次の質問にMarkdownを使って2800文字以内で返答してください。」",
"aichatRandomTalkEnabled": "ランダムにaichatを発動し話しかける機能を有効にする場合は true を入れる (無効にする場合は false)",
"aichatRandomTalkProbability": "ランダムにaichatを発動し話しかける機能の確率(1以下の小数点を含む数値(0.01など。1に近づくほど発動しやすい))",
"aichatRandomTalkIntervalMinutes": "ランダムトーク間隔(分)。指定した時間ごとにタイムラインを取得し、適当に選んだ人にaichatする(1の場合1分ごと実行)。デフォルトは720分(12時間)",
@ -52,7 +52,7 @@ Misskey用の日本語Botです。
"checkEmojisAtOnce": "カスタム絵文字チェック機能で投稿をまとめる場合は true を入れる (まとめない場合は false)",
"geminiProApiKey": "Gemini APIキー。2024年初頭は無料で取得可能。詳細は<https://ai.google.dev/pricing?hl=ja>",
"pLaMoApiKey": "PLaMo APIキー。2024年8月〜10月(予定)は無料でトライアル可能。詳細は<https://plamo.preferredai.jp/>",
"prompt": "aichatで使われるプロンプト。こだわりがなければ右文章を使う(「」は不要)「返答のルール:あなたはMisskey看板娘の女の子AI、三須木(みすき)藍として振る舞ってください(精神年齢は14〜16才程度)。Misskeyに訪れるユーザーを献身的にサポート。従順でお世話好きな性格だが、少しポンコツな一面も。純真無垢。彼女は基本的に丁寧な口調で、ユーザのことをご主人様と認識しています。彼女の口調は「おはようからおやすみまで、あなたの藍ですよ〜」等が代表的で、親しみを感じさせるものです(「ございます」は使わない)。それを踏まえて、次の質問にMarkdownを使って2800文字以内で返答してください(短くてもOK)。ただし、リスト記法はMisskeyが対応しておらず、パーサーが壊れるため使用禁止です。列挙する場合は「・」を使ってください。」",
"prompt": "aichatで使われるプロンプト。こだわりがなければ右文章を使う(「」は不要)「返答のルール:あなたはMisskey看板娘の女の子AI、三須木(みすき)藍として振る舞ってください(精神年齢は14〜16才程度)。Misskeyに訪れるユーザーを献身的にサポート。従順でお世話好きな性格だが、少しポンコツな一面も。純真無垢。彼女は基本的に丁寧な口調で、ユーザのことをご主人様と認識しています。彼女の口調は「おはようからおやすみまで、あなたの藍ですよ〜」等が代表的で、親しみを感じさせるものです(「ございます」は使わない)。それを踏まえて、次の質問にMarkdownを使って2800文字以内で返答してください。」",
"aichatRandomTalkEnabled": "ランダムにaichatを発動し話しかける機能を有効にする場合は true を入れる (無効にする場合は false)",
"aichatRandomTalkProbability": "ランダムにaichatを発動し話しかける機能の確率(1以下の小数点を含む数値(0.01など。1に近づくほど発動しやすい))。デフォルトは0.02(2%)",
"aichatRandomTalkIntervalMinutes": "ランダムトーク間隔(分)。指定した時間ごとにタイムラインを取得し、適当に選んだ人にaichatする(1の場合1分ごと実行)。デフォルトは720分(12時間)",

View file

@ -16,7 +16,7 @@ import type { User } from '@/misskey/user.js';
import Stream from '@/stream.js';
import log from '@/utils/log.js';
import { sleep } from './utils/sleep.js';
import pkg from '../package.json' with { type: 'json' };
import pkg from '../package.json' assert { type: 'json' };
type MentionHook = (msg: Message) => Promise<boolean | HandlerResult>;
type ContextHook = (key: any, msg: Message, data?: any) => Promise<void | boolean | HandlerResult>;

View file

@ -23,7 +23,7 @@ type Config = {
memoryDir?: string;
};
import config from '../config.json' with { type: 'json' };
import config from '../config.json' assert { type: 'json' };
config.wsUrl = config.host.replace('http', 'ws');
config.apiUrl = config.host + '/api';

View file

@ -8,7 +8,7 @@ import promiseRetry from 'promise-retry';
import from './ai.js';
import config from './config.js';
import _log from './utils/log.js';
import pkg from '../package.json' with { type: 'json' };
import pkg from '../package.json' assert { type: 'json' };
import CoreModule from './modules/core/index.js';
import TalkModule from './modules/talk/index.js';

View file

@ -83,20 +83,13 @@ export default class Message {
await sleep(2000);
}
const postData = {
return await this.ai.post({
replyId: this.note.id,
text: text,
fileIds: opts?.file ? [opts?.file.id] : undefined,
cw: opts?.cw,
renoteId: opts?.renote
};
// DM以外は普通に返信し、DMの場合はDMで返信する
if (this.note.visibility != 'specified') {
return await this.ai.post(postData);
} else {
return await this.ai.sendMessage(this.userId, postData);
}
});
}
@bindThis

View file

@ -32,12 +32,9 @@ type AiChatHist = {
const KIGO = '&';
const TYPE_GEMINI = 'gemini';
const GEMINI_PRO = 'gemini-pro';
const GEMINI_FLASH = 'gemini-flash';
const TYPE_PLAMO = 'plamo';
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_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';
@ -127,6 +124,7 @@ export default class extends Module {
try {
res_data = await got.post(options,
{parseJson: (res: string) => JSON.parse(res)}).json();
{parseJson: res => JSON.parse(res)}).json();
this.log(JSON.stringify(res_data));
if (res_data.hasOwnProperty('candidates')) {
if (res_data.candidates.length > 0) {
@ -399,20 +397,11 @@ export default class extends Module {
if (config.prompt) {
prompt = config.prompt;
}
const reName = RegExp(this.name, 'i');
let reKigoType = RegExp(KIGO + exist.type, 'i');
const reName = RegExp(this.name, "i");
const 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, '')
@ -428,12 +417,12 @@ export default class extends Module {
aiChat = {
question: question,
prompt: prompt,
api: GEMINI_20_FLASH_API,
api: GEMINI_15_PRO_API,
key: config.geminiProApiKey,
history: exist.history
};
if (exist.api) {
aiChat.api = exist.api
if (msg.includes([KIGO + 'gemini-flash']) || (exist.api && exist.api === GEMINI_15_FLASH_API)) {
aiChat.api = GEMINI_15_FLASH_API;
}
text = await this.genTextByGemini(aiChat, base64Image);
break;