Refactor (9)
This commit is contained in:
12
index.ts
12
index.ts
@@ -2,7 +2,13 @@ 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 {
|
||||
LlmSession,
|
||||
createBias,
|
||||
createGrammar,
|
||||
getModel,
|
||||
parseResponse,
|
||||
} from "./lib/llm";
|
||||
import {
|
||||
expandReplyTree,
|
||||
getNotes,
|
||||
@@ -30,9 +36,11 @@ const modelName =
|
||||
console.log(`* loading model '${modelName}'`);
|
||||
const model = await getModel(modelName);
|
||||
const grammar = await createGrammar("あるびのちゃん");
|
||||
const bias = createBias(model);
|
||||
const baseChatPromptOptions = {
|
||||
grammar,
|
||||
maxTokens: 256,
|
||||
tokenBias: bias,
|
||||
} as const satisfies LLamaChatPromptOptions;
|
||||
|
||||
const getSystemPrompt = (
|
||||
@@ -58,7 +66,7 @@ async function rephrase(text: string) {
|
||||
await using rephraseSession = new LlmSession(
|
||||
model,
|
||||
getSystemPrompt(
|
||||
"user が与えたテキストを『ですます調』(丁寧な文体)で言い換えたものを、そのまま出力してください。",
|
||||
"ユーザが与えたテキストを「~です」「~ます」調(丁寧な文体)で言い換えたものを、そのまま出力してください。",
|
||||
),
|
||||
);
|
||||
await rephraseSession.init();
|
||||
|
||||
Reference in New Issue
Block a user