Compare commits
4 Commits
tyler
...
ee367a0d9a
| Author | SHA1 | Date | |
|---|---|---|---|
| ee367a0d9a | |||
| e696343a73 | |||
| 88a0710c55 | |||
| 75fa4cea8b |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
node_modules
|
node_modules
|
||||||
# Keep environment variables out of version control
|
# Keep environment variables out of version control
|
||||||
.env
|
.env*
|
||||||
*.log
|
*.log
|
||||||
*.db
|
*.db
|
||||||
/dist
|
/dist
|
||||||
|
|||||||
28
src/main.ts
28
src/main.ts
@ -9,7 +9,7 @@ import {
|
|||||||
// import striptags from "striptags";
|
// import striptags from "striptags";
|
||||||
import { PrismaClient } from "../generated/prisma/client.js";
|
import { PrismaClient } from "../generated/prisma/client.js";
|
||||||
import {
|
import {
|
||||||
getInstanceEmojis,
|
// getInstanceEmojis,
|
||||||
deleteNotification,
|
deleteNotification,
|
||||||
getNotifications,
|
getNotifications,
|
||||||
getStatusContext,
|
getStatusContext,
|
||||||
@ -20,7 +20,7 @@ import {
|
|||||||
alreadyRespondedTo,
|
alreadyRespondedTo,
|
||||||
recordPendingResponse,
|
recordPendingResponse,
|
||||||
// trimInputData,
|
// trimInputData,
|
||||||
selectRandomEmoji,
|
// selectRandomEmoji,
|
||||||
shouldContinue,
|
shouldContinue,
|
||||||
} from "./util.js";
|
} from "./util.js";
|
||||||
|
|
||||||
@ -48,10 +48,10 @@ export const envConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ollamaConfig: OllamaConfigOptions = {
|
const ollamaConfig: OllamaConfigOptions = {
|
||||||
temperature: 0.6,
|
temperature: 0.9,
|
||||||
top_p: 0.85,
|
top_p: 0.85,
|
||||||
top_k: 40,
|
top_k: 60,
|
||||||
num_ctx: 8192,
|
num_ctx: 16384, // maximum context window for Llama 3.1
|
||||||
repeat_penalty: 1.1,
|
repeat_penalty: 1.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ const generateOllamaRequest = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Simplified user message (remove [/INST] as it's not needed for Llama 3)
|
// Simplified user message (remove [/INST] as it's not needed for Llama 3)
|
||||||
const userMessage = `${notification.status.account.fqn} says: ${notification.status.pleroma.content["text/plain"]}`;
|
const userMessage = `${notification.status.account.fqn} says to you: \"${notification.status.pleroma.content["text/plain"]}\".`;
|
||||||
|
|
||||||
let systemContent = ollamaSystemPrompt;
|
let systemContent = ollamaSystemPrompt;
|
||||||
if (replyWithContext) {
|
if (replyWithContext) {
|
||||||
@ -105,13 +105,13 @@ const generateOllamaRequest = async (
|
|||||||
systemContent = `${ollamaSystemPrompt}\n\nPrevious conversation context:\n${conversationHistory
|
systemContent = `${ollamaSystemPrompt}\n\nPrevious conversation context:\n${conversationHistory
|
||||||
.map(
|
.map(
|
||||||
(post) =>
|
(post) =>
|
||||||
`${post.account_fqn} (to ${post.mentions.join(", ")}): ${
|
`${post.account_fqn} (said to ${post.mentions.join(", ")}): ${
|
||||||
post.plaintext_content
|
post.plaintext_content
|
||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
.join(
|
.join(
|
||||||
"\n"
|
"\n"
|
||||||
)}\nReply as if you are a party to the conversation. If '@nice-ai' is mentioned, respond directly. Prefix usernames with '@' when addressing them.`;
|
)}\nReply to the user who addressed you (you are Lexi, also known as nice-ai or nice-ai@nicecrew.digital). Examine the context of the entire conversation and make references to topics or information where appropriate. Prefix usernames with '@' when addressing them. Assume if there is no domain in the username, the domain is @nicecrew.digital (for example @matty would be @matty@nicecrew.digital)`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to chat request format (messages array auto-handles Llama 3 template)
|
// Switch to chat request format (messages array auto-handles Llama 3 template)
|
||||||
@ -145,16 +145,16 @@ const postReplyToStatus = async (
|
|||||||
ollamaResponseBody: OllamaChatResponse
|
ollamaResponseBody: OllamaChatResponse
|
||||||
) => {
|
) => {
|
||||||
const { pleromaInstanceUrl, bearerToken } = envConfig;
|
const { pleromaInstanceUrl, bearerToken } = envConfig;
|
||||||
const emojiList = await getInstanceEmojis();
|
// const emojiList = await getInstanceEmojis();
|
||||||
let randomEmoji;
|
// let randomEmoji;
|
||||||
if (emojiList) {
|
// if (emojiList) {
|
||||||
randomEmoji = selectRandomEmoji(emojiList);
|
// randomEmoji = selectRandomEmoji(emojiList);
|
||||||
}
|
// }
|
||||||
try {
|
try {
|
||||||
let mentions: string[];
|
let mentions: string[];
|
||||||
const statusBody: NewStatusBody = {
|
const statusBody: NewStatusBody = {
|
||||||
content_type: "text/markdown",
|
content_type: "text/markdown",
|
||||||
status: `${ollamaResponseBody.message.content} :${randomEmoji}:`,
|
status: `${ollamaResponseBody.message.content}`,
|
||||||
in_reply_to_id: notification.status.id,
|
in_reply_to_id: notification.status.id,
|
||||||
};
|
};
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -8,7 +8,7 @@ Type=simple
|
|||||||
User=bot
|
User=bot
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
ExecStart=/usr/bin/screen -L -DmS pleroma-ollama-bot /home/bot/.nvm/versions/node/v22.11.0/bin/npm run start
|
ExecStart=/home/bot/.nvm/versions/node/v22.11.0/bin/npm run start
|
||||||
WorkingDirectory=/path/to/directory
|
WorkingDirectory=/path/to/directory
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user