This commit is contained in:
2026-04-07 04:23:48 +09:00
parent f2c3243140
commit 468cc0847b
6 changed files with 22 additions and 104 deletions

View File

@@ -2,7 +2,7 @@ import { parseArgs } from "node:util";
import { Stream } from "misskey-js";
import type { Note } from "misskey-js/entities.js";
import type { ChatHistoryItem, LLamaChatPromptOptions } from "node-llama-cpp";
import { LlmSession, createGrammar, getModel, parseResponse } from "./lib/llm";
import { createGrammar, getModel, LlmSession, parseResponse } from "./lib/llm";
import {
expandReplyTree,
getNotes,
@@ -118,11 +118,16 @@ async function processPostJob() {
async function processReplyJob(job: Extract<Job, { type: "reply" }>) {
const history: ChatHistoryItem[] = job.history.map((n) => {
const type = n.userId === me.id ? ("model" as const) : ("user" as const);
if (n.userId === me.id) {
return {
type: "model",
response: [formatNote(n)],
} as const;
}
return {
type,
type: "user",
text: formatNote(n),
} as ChatHistoryItem;
} as const;
});
const text = await (async () => {
await using session = new LlmSession(model, replyJobPrompt, history);
@@ -221,10 +226,6 @@ function initializeStream() {
await misskey.request("following/create", { userId: e.id });
}
});
channel.on("unfollow", async (e) => {
await misskey.request("following/delete", { userId: e.id });
});
}
/** pop from the job queue and run it */