mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
Backend portion of experimental `AgenticChat` feature: - Adds database tables for chats and chat messages - Adds functionality to stream messages from LLM providers using `kylecarbs/aisdk-go` - Adds API routes with relevant functionality (list, create, update chats, insert chat message) - Adds experiment `codersdk.AgenticChat` --------- Co-authored-by: Kyle Carberry <kyle@carberry.com>
18 lines
634 B
SQL
18 lines
634 B
SQL
CREATE TABLE IF NOT EXISTS chats (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
owner_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
title TEXT NOT NULL
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS chat_messages (
|
|
-- BIGSERIAL is auto-incrementing so we know the exact order of messages.
|
|
id BIGSERIAL PRIMARY KEY,
|
|
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
model TEXT NOT NULL,
|
|
provider TEXT NOT NULL,
|
|
content JSONB NOT NULL
|
|
);
|