会話頻度を1/10に落とす・最新10件以上は覚えない

This commit is contained in:
Nebel 2024-07-04 15:43:39 +09:00
parent 5ae513c8c0
commit efc9f40f77
Signed by: nebel
GPG key ID: 79807D08C6EF6460

View file

@ -14,7 +14,8 @@ const system = `\
`; `;
const n = 3; const n = 10;
const model = "llama3-70b-8192";
const usage = `\ const usage = `\
https://dash.deno.com/playground/darazllm https://dash.deno.com/playground/darazllm
@ -23,6 +24,8 @@ https://dash.deno.com/playground/darazllm
@darazllm /bye @darazllm /bye
@darazllm /help @darazllm /help
使用する会話: 最新${n}
モデル: ${model}
: :
${system}`; ${system}`;
@ -32,7 +35,6 @@ import { Groq } from "npm:groq-sdk";
type Messages = Array<Groq.Chat.CompletionCreateParams.Message>; type Messages = Array<Groq.Chat.CompletionCreateParams.Message>;
const model = "llama3-70b-8192";
const groq = new Groq({ const groq = new Groq({
apiKey: GROQ_API_KEY, apiKey: GROQ_API_KEY,
timeout: 10_000, timeout: 10_000,
@ -79,7 +81,7 @@ app.message(async (c) => {
if (isMention || Math.floor(Math.random() * n) === 0) { if (isMention || Math.floor(Math.random() * n) === 0) {
try { try {
const res = await chat(messages); const res = await chat(messages.slice(-n));
if (!res) throw new Error("Empty response"); if (!res) throw new Error("Empty response");