I don't remember

This commit is contained in:
2025-08-02 22:19:13 +00:00
parent c3d4f1b1ff
commit 0c7c176bae
3 changed files with 45 additions and 13 deletions

1
.gitignore vendored
View File

@ -4,5 +4,6 @@ node_modules
*.log *.log
*.db *.db
/dist /dist
screenlog*
/generated/prisma /generated/prisma

View File

@ -1,9 +1,11 @@
import { import {
OllamaRequest,
OllamaResponse,
NewStatusBody, NewStatusBody,
Notification, Notification,
OllamaConfigOptions, OllamaConfigOptions,
// OllamaChatRequest,
// OllamaChatResponse,
OllamaRequest,
OllamaResponse,
} from "../types.js"; } from "../types.js";
import striptags from "striptags"; import striptags from "striptags";
import { PrismaClient } from "../generated/prisma/client.js"; import { PrismaClient } from "../generated/prisma/client.js";
@ -31,9 +33,7 @@ export const envConfig = {
? process.env.WHITELISTED_DOMAINS.split(",") ? process.env.WHITELISTED_DOMAINS.split(",")
: [process.env.PLEROMA_INSTANCE_DOMAIN], : [process.env.PLEROMA_INSTANCE_DOMAIN],
ollamaUrl: process.env.OLLAMA_URL || "", ollamaUrl: process.env.OLLAMA_URL || "",
ollamaSystemPrompt: ollamaSystemPrompt: process.env.OLLAMA_SYSTEM_PROMPT,
process.env.OLLAMA_SYSTEM_PROMPT ||
"You are a helpful AI assistant. Answer all questions concisely.",
ollamaModel: process.env.OLLAMA_MODEL || "", ollamaModel: process.env.OLLAMA_MODEL || "",
fetchInterval: process.env.FETCH_INTERVAL fetchInterval: process.env.FETCH_INTERVAL
? parseInt(process.env.FETCH_INTERVAL) ? parseInt(process.env.FETCH_INTERVAL)
@ -42,9 +42,10 @@ export const envConfig = {
}; };
const ollamaConfig: OllamaConfigOptions = { const ollamaConfig: OllamaConfigOptions = {
temperature: 1.4, temperature: 0.2,
top_k: 100, top_p: 0.9,
top_p: 0.8, top_k: 30,
num_ctx: 2048,
}; };
// this could be helpful // this could be helpful
@ -73,12 +74,10 @@ const generateOllamaRequest = async (
await storeUserData(notification); await storeUserData(notification);
const ollamaRequestBody: OllamaRequest = { const ollamaRequestBody: OllamaRequest = {
model: ollamaModel, model: ollamaModel,
prompt: trimInputData(notification.status.content),
system: ollamaSystemPrompt, system: ollamaSystemPrompt,
prompt: `[INST] @${
notification.status.account.fqn
} says: ${trimInputData(notification.status.content)} [/INST]`,
stream: false, stream: false,
options: ollamaConfig, // options: ollamaConfig,
}; };
const response = await fetch(`${ollamaUrl}/api/generate`, { const response = await fetch(`${ollamaUrl}/api/generate`, {
method: "POST", method: "POST",
@ -173,4 +172,5 @@ console.log(
ollamaConfig ollamaConfig
)}` )}`
); );
console.log(`System prompt: ${envConfig.ollamaSystemPrompt}`);
await beginFetchCycle(); await beginFetchCycle();

33
types.d.ts vendored
View File

@ -36,7 +36,7 @@ export interface OllamaRequest {
/** /**
* Whatever system prompt you'd like to add to the model to make it more unique, or force it to respond a certain way. * Whatever system prompt you'd like to add to the model to make it more unique, or force it to respond a certain way.
*/ */
system: string; system?: string;
/** /**
* Whether to stream responses from the API, or have it sent all as one payload. * Whether to stream responses from the API, or have it sent all as one payload.
*/ */
@ -47,6 +47,37 @@ export interface OllamaRequest {
options?: OllamaConfigOptions; options?: OllamaConfigOptions;
} }
export interface OllamaChatRequest {
model: string;
messages: OllamaMessages[];
stream?: boolean = false;
options?: OllamaConfigOptions;
}
export interface OllamaChatResponse {
model: string;
created_at: string;
message: OllamaChatResponseMessage;
done_reason: "string";
done: boolean;
total_duration: number;
load_duration: number;
prompt_eval_count: number;
prompt_eval_duration: number;
eval_count: number;
eval_duration: number;
}
interface OllamaChatResponseMessage {
role: "assistant";
content: string;
}
interface OllamaMessages {
role: "system" | "user";
content: string;
}
export interface OllamaResponse { export interface OllamaResponse {
model: string; model: string;
created_at: Date | string; created_at: Date | string;