Spaces:
Sleeping
Sleeping
File size: 4,674 Bytes
c72674e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | -- BYTE AI - SUPABASE SCHEMA SETUP (2026)
-- Run this in your Supabase SQL Editor to fix PGRST205 errors.
-- 1. Enable pgvector extension for Semantic Memory
create extension if not exists vector;
-- 2. Tables for Core Configuration and Persona
create table if not exists public.channels_config (
channel_id text primary key,
temperature float,
top_p float,
agent_paused boolean default false,
is_active boolean default true,
updated_at timestamptz default now()
);
create table if not exists public.persona_profiles (
channel_id text primary key,
base_identity jsonb default '{}'::jsonb,
tonality_engine jsonb default '{}'::jsonb,
behavioral_constraints jsonb default '{}'::jsonb,
model_routing jsonb default '{}'::jsonb,
updated_at timestamptz default now()
);
create table if not exists public.channel_identity (
channel_id text primary key,
persona_name text,
tone text,
emote_vocab text[],
lore text,
updated_at timestamptz default now()
);
create table if not exists public.agent_notes (
channel_id text primary key,
notes text,
updated_at timestamptz default now()
);
-- 3. Tables for Observability and History
create table if not exists public.observability_rollups (
id uuid primary key default gen_random_uuid(),
captured_at timestamptz default now(),
snapshot jsonb not null
);
create table if not exists public.observability_channel_history (
id bigint generated always as identity primary key,
channel_id text not null,
captured_at timestamptz default now(),
snapshot jsonb not null
);
create table if not exists public.channel_state (
channel_id text primary key,
vibe text,
observability jsonb default '{}'::jsonb,
last_reply text,
updated_at timestamptz default now()
);
create table if not exists public.channel_history (
id bigint generated always as identity primary key,
channel_id text not null,
author text not null,
message text not null,
ts timestamptz default now()
);
-- 4. Tables for Specialized Features (Clips, Webhooks, Memory)
create table if not exists public.post_stream_reports (
id bigint generated always as identity primary key,
channel_id text not null,
report jsonb not null,
generated_at timestamptz default now(),
trigger text
);
create table if not exists public.revenue_conversions (
id bigint generated always as identity primary key,
channel_id text not null,
conversion jsonb not null,
timestamp timestamptz default now()
);
create table if not exists public.outbound_webhooks (
id uuid primary key default gen_random_uuid(),
channel_id text not null,
url text not null,
secret text,
event_types text[] default '{}',
is_active boolean default true,
created_at timestamptz default now(),
updated_at timestamptz default now()
);
create table if not exists public.outbound_webhook_deliveries (
id uuid primary key default gen_random_uuid(),
webhook_id uuid not null,
channel_id text not null,
event_type text not null,
status_code int,
success boolean,
latency_ms int,
timestamp timestamptz default now()
);
-- 5. Semantic Memory with pgvector
create table if not exists public.semantic_memory_entries (
entry_id uuid primary key default gen_random_uuid(),
channel_id text not null,
memory_type text not null,
content text not null,
tags text[] default '{}',
context jsonb default '{}'::jsonb,
embedding vector(1536), -- Standard OpenAI/Kimi embedding size
created_at timestamptz default now(),
updated_at timestamptz default now()
);
-- 6. RPC Functions for Semantic Search
create or replace function public.semantic_memory_search_pgvector(
p_channel_id text,
p_query_embedding vector(1536),
p_limit int,
p_search_limit int
) returns table (
entry_id uuid,
memory_type text,
content text,
tags text[],
context jsonb,
embedding vector(1536),
created_at timestamptz,
updated_at timestamptz,
similarity float
) language plpgsql as $$
begin
return query
select
s.entry_id,
s.memory_type,
s.content,
s.tags,
s.context,
s.embedding,
s.created_at,
s.updated_at,
1 - (s.embedding <=> p_query_embedding) as similarity
from public.semantic_memory_entries s
where s.channel_id = p_channel_id
order by similarity desc
limit p_limit;
end;
$$;
-- Enable Realtime for observability (optional but recommended)
alter publication supabase_realtime add table public.observability_channel_history;
|