mirror of
https://github.com/matrixgpt/matrix-chatgpt-bot.git
synced 2024-10-01 01:25:41 -04:00
add CHATGPT_IGNORE_MEDIA
This commit is contained in:
parent
3af7b88825
commit
d72b0ba772
@ -8,6 +8,8 @@ CHATGPT_CONTEXT=thread
|
|||||||
#CHATGPT_MODEL=text-chat-davinci-002-20221122
|
#CHATGPT_MODEL=text-chat-davinci-002-20221122
|
||||||
# (Optional) Explicitly set the prefix sent to model at the beginning of a conversation
|
# (Optional) Explicitly set the prefix sent to model at the beginning of a conversation
|
||||||
#CHATGPT_PROMPT_PREFIX=Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.
|
#CHATGPT_PROMPT_PREFIX=Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.
|
||||||
|
# (Optional) Set to true if ChatGPT should ignore any attachments which are not text
|
||||||
|
#CHATGPT_IGNORE_MEDIA=false
|
||||||
|
|
||||||
# Set data store settings
|
# Set data store settings
|
||||||
KEYV_BACKEND=file
|
KEYV_BACKEND=file
|
||||||
|
@ -31,6 +31,7 @@ export const {
|
|||||||
CHATGPT_TIMEOUT,
|
CHATGPT_TIMEOUT,
|
||||||
CHATGPT_MODEL,
|
CHATGPT_MODEL,
|
||||||
CHATGPT_PROMPT_PREFIX,
|
CHATGPT_PROMPT_PREFIX,
|
||||||
|
CHATGPT_IGNORE_MEDIA,
|
||||||
} = parseEnv(process.env, {
|
} = parseEnv(process.env, {
|
||||||
DATA_PATH: { schema: z.string().default("./storage"), description: "Set to /storage/ if using docker, ./storage if running without" },
|
DATA_PATH: { schema: z.string().default("./storage"), description: "Set to /storage/ if using docker, ./storage if running without" },
|
||||||
KEYV_BACKEND: { schema: z.enum(["file", "other"]).default("file"),description: "Set the Keyv backend to 'file' or 'other' if other set KEYV_URL" },
|
KEYV_BACKEND: { schema: z.enum(["file", "other"]).default("file"),description: "Set the Keyv backend to 'file' or 'other' if other set KEYV_URL" },
|
||||||
@ -59,4 +60,5 @@ export const {
|
|||||||
CHATGPT_CONTEXT: { schema: z.enum(["thread", "room", "both"]).default("thread"), description: "Set the ChatGPT conversation context to 'thread', 'room' or 'both'" },
|
CHATGPT_CONTEXT: { schema: z.enum(["thread", "room", "both"]).default("thread"), description: "Set the ChatGPT conversation context to 'thread', 'room' or 'both'" },
|
||||||
CHATGPT_MODEL: { schema: z.string().default("text-chat-davinci-002-20221122"), description: "The model for the ChatGPT-API to use" },
|
CHATGPT_MODEL: { schema: z.string().default("text-chat-davinci-002-20221122"), description: "The model for the ChatGPT-API to use" },
|
||||||
CHATGPT_PROMPT_PREFIX: { schema: z.string().default('Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'), description: "Instructions to feed to ChatGPT on startup"},
|
CHATGPT_PROMPT_PREFIX: { schema: z.string().default('Instructions:\nYou are ChatGPT, a large language model trained by OpenAI.'), description: "Instructions to feed to ChatGPT on startup"},
|
||||||
|
CHATGPT_IGNORE_MEDIA: { schema: z.boolean().default(false), description: "Wether or not the bot should react to non-text messages"},
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import ChatGPTClient from '@waylaidwanderer/chatgpt-api';
|
import ChatGPTClient from '@waylaidwanderer/chatgpt-api';
|
||||||
import { LogService, MatrixClient, UserID } from "matrix-bot-sdk";
|
import { LogService, MatrixClient, UserID } from "matrix-bot-sdk";
|
||||||
import { CHATGPT_CONTEXT, CHATGPT_TIMEOUT, MATRIX_DEFAULT_PREFIX_REPLY, MATRIX_DEFAULT_PREFIX, MATRIX_BLACKLIST, MATRIX_WHITELIST, MATRIX_RICH_TEXT, MATRIX_PREFIX_DM, MATRIX_THREADS } from "./env.js";
|
import { CHATGPT_CONTEXT, CHATGPT_TIMEOUT, MATRIX_DEFAULT_PREFIX_REPLY, MATRIX_DEFAULT_PREFIX, MATRIX_BLACKLIST, MATRIX_WHITELIST, MATRIX_RICH_TEXT, MATRIX_PREFIX_DM, MATRIX_THREADS, CHATGPT_IGNORE_MEDIA } from "./env.js";
|
||||||
import { RelatesTo, MessageEvent, StoredConversation, StoredConversationConfig } from "./interfaces.js";
|
import { RelatesTo, MessageEvent, StoredConversation, StoredConversationConfig } from "./interfaces.js";
|
||||||
import { sendChatGPTMessage, sendError, sendReply } from "./utils.js";
|
import { sendChatGPTMessage, sendError, sendReply } from "./utils.js";
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ export default class CommandHandler {
|
|||||||
if (MATRIX_WHITELIST && !MATRIX_WHITELIST.split(" ").find(w => event.sender.endsWith(w))) return true; // Ignore if not on whitelist if set
|
if (MATRIX_WHITELIST && !MATRIX_WHITELIST.split(" ").find(w => event.sender.endsWith(w))) return true; // Ignore if not on whitelist if set
|
||||||
if (Date.now() - event.origin_server_ts > 10000) return true; // Ignore old messages
|
if (Date.now() - event.origin_server_ts > 10000) return true; // Ignore old messages
|
||||||
if (event.content["m.relates_to"]?.["rel_type"] === "m.replace") return true; // Ignore edits
|
if (event.content["m.relates_to"]?.["rel_type"] === "m.replace") return true; // Ignore edits
|
||||||
if (event.content.msgtype !== "m.text") return true; // Ignore everything which is not text
|
if (CHATGPT_IGNORE_MEDIA && event.content.msgtype !== "m.text") return true; // Ignore everything which is not text
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user