Compare commits
3 Commits
b6ad54f40a
...
2111a47411
Author | SHA1 | Date | |
---|---|---|---|
2111a47411 | |||
11c1332757 | |||
aaf4adcf06 |
@ -1,6 +1,7 @@
|
||||
DATABASE_URL="file:../dev.db" # SQLite database relative to the ./prisma path
|
||||
PLEROMA_INSTANCE_URL="https://instance.tld" # Pleroma instance full URL including scheme
|
||||
PLEROMA_INSTANCE_DOMAIN="instance.tld" # used if you want to only want to respond to people from a particular instance
|
||||
PLEROMA_ACCOUNT_ID="" # obtained from /api/v1/accounts/{nickname} - used so we don't spam mentions when not directly addressed
|
||||
ONLY_WHITELIST="true" # change to "false" if you want to accept prompts from any and all domains - *** USE WITH CAUTION ***
|
||||
WHITELISTED_DOMAINS="" # comma separated list of domains you want to allow the bot to accept prompts from (i.e. poa.st,nicecrew.digital,detroitriotcity.com,decayable.ink)
|
||||
OLLAMA_URL="http://localhost:11434" # OLLAMA connection URL
|
||||
|
@ -8,8 +8,6 @@
|
||||
6. Run `npx prisma migrate dev --name init`
|
||||
7. To start, run `npm run start`
|
||||
|
||||
I recommend using `screen` to run this in the background until a `systemd` service can be created. I just haven't bothered to do it yet.
|
||||
|
||||
### Database Migrations
|
||||
|
||||
If you add stuff to the schema, follow the [Prisma development workflow](https://www.prisma.io/docs/orm/prisma-migrate/workflows/development-and-production). This will apply the new schema to the database and generate a new Prisma client with type safety.
|
||||
|
17
src/main.ts
17
src/main.ts
@ -42,6 +42,7 @@ export const envConfig = {
|
||||
adHocPostInterval: process.env.RANDOM_POST_INTERVAL
|
||||
? parseInt(process.env.RANDOM_POST_INTERVAL)
|
||||
: 3600000,
|
||||
botAccountId: process.env.PLEROMA_ACCOUNT_ID,
|
||||
};
|
||||
|
||||
const ollamaConfig: OllamaConfigOptions = {
|
||||
@ -58,13 +59,23 @@ const ollamaConfig: OllamaConfigOptions = {
|
||||
const generateOllamaRequest = async (
|
||||
notification: Notification
|
||||
): Promise<OllamaResponse | undefined> => {
|
||||
const { whitelistOnly, ollamaModel, ollamaSystemPrompt, ollamaUrl } =
|
||||
envConfig;
|
||||
const {
|
||||
whitelistOnly,
|
||||
ollamaModel,
|
||||
ollamaSystemPrompt,
|
||||
ollamaUrl,
|
||||
botAccountId,
|
||||
} = envConfig;
|
||||
try {
|
||||
console.log(trimInputData(notification.status.content));
|
||||
if (
|
||||
// striptags(notification.status.content).includes("!prompt") &&
|
||||
!notification.status.account.bot && // sanity check, sort of
|
||||
notification.type === "mention" // &&
|
||||
notification.type === "mention" &&
|
||||
(notification.status.in_reply_to_account_id === botAccountId ||
|
||||
notification.status.in_reply_to_account_id === null) &&
|
||||
trimInputData(notification.status.content).split(" ").includes("Lexi")
|
||||
// only reply to mentions when the bot is the direct recipient or when an @ is at the top level of a conversation chain, or when the AI is @ directly
|
||||
// notification.status.visibility !== "private" // for safety, let's only respond to public messages
|
||||
) {
|
||||
if (whitelistOnly && !isFromWhitelistedDomain(notification)) {
|
||||
|
14
systemd.service
Normal file
14
systemd.service
Normal file
@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=Pleroma Ollama Bot
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=USERNAME_HERE
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
ExecStart=/usr/bin/screen -L -DmS pleroma-ollama-bot /home/bot/.nvm/versions/node/v22.11.0/bin/npm run start
|
||||
WorkingDirectory=/path/to/directory
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user