mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: bot inbox (#77)
* feat: bot inbox * feat: unified header * fix: missing tool_call usage * feat: add group name in header
This commit is contained in:
@@ -121,6 +121,7 @@ CREATE TABLE IF NOT EXISTS bots (
|
||||
max_context_tokens INTEGER NOT NULL DEFAULT 0,
|
||||
language TEXT NOT NULL DEFAULT 'auto',
|
||||
allow_guest BOOLEAN NOT NULL DEFAULT false,
|
||||
max_inbox_items INTEGER NOT NULL DEFAULT 50,
|
||||
chat_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
|
||||
memory_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
|
||||
embedding_model_id UUID REFERENCES models(id) ON DELETE SET NULL,
|
||||
@@ -390,3 +391,17 @@ CREATE TABLE IF NOT EXISTS bot_history_message_assets (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_message_assets_message_id ON bot_history_message_assets(message_id);
|
||||
|
||||
-- bot_inbox: per-bot message inbox for non-mentioned group messages, emails, etc.
|
||||
CREATE TABLE IF NOT EXISTS bot_inbox (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
bot_id UUID NOT NULL REFERENCES bots(id) ON DELETE CASCADE,
|
||||
source TEXT NOT NULL DEFAULT '',
|
||||
content JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
read_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_unread ON bot_inbox(bot_id, created_at DESC) WHERE is_read = FALSE;
|
||||
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_created ON bot_inbox(bot_id, created_at DESC);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
-- 0011_add_inbox (down)
|
||||
-- Remove bot_inbox table and max_inbox_items column.
|
||||
|
||||
DROP INDEX IF EXISTS idx_bot_inbox_bot_created;
|
||||
DROP INDEX IF EXISTS idx_bot_inbox_bot_unread;
|
||||
DROP TABLE IF EXISTS bot_inbox;
|
||||
|
||||
ALTER TABLE bots DROP COLUMN IF EXISTS max_inbox_items;
|
||||
@@ -0,0 +1,17 @@
|
||||
-- 0011_add_inbox
|
||||
-- Add bot_inbox table and max_inbox_items setting to bots.
|
||||
|
||||
ALTER TABLE bots ADD COLUMN IF NOT EXISTS max_inbox_items INTEGER NOT NULL DEFAULT 50;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS bot_inbox (
|
||||
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
bot_id UUID NOT NULL REFERENCES bots(id) ON DELETE CASCADE,
|
||||
source TEXT NOT NULL DEFAULT '',
|
||||
content JSONB NOT NULL DEFAULT '{}'::jsonb,
|
||||
is_read BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
read_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_unread ON bot_inbox(bot_id, created_at DESC) WHERE is_read = FALSE;
|
||||
CREATE INDEX IF NOT EXISTS idx_bot_inbox_bot_created ON bot_inbox(bot_id, created_at DESC);
|
||||
Reference in New Issue
Block a user