- Update .gitignore to exclude database files, extensions, and .cursor directory - Enhance chat streaming API with safe enqueue and close functions to prevent errors - Integrate ConversationSidebar component into ClientHome for better UI - Add dependencies like better-sqlite3 and esbuild packages for database functionality This commit introduces database persistence for conversations, improves error handling in streaming responses, and adds a sidebar for managing chats, enhancing overall app robustness and user experience.
33 lines
1012 B
SQL
33 lines
1012 B
SQL
-- Schema inicial do banco de dados OllaHub
|
|
-- Conversas
|
|
CREATE TABLE conversations (
|
|
id TEXT PRIMARY KEY,
|
|
title TEXT,
|
|
model TEXT NOT NULL,
|
|
created_at INTEGER NOT NULL,
|
|
updated_at INTEGER NOT NULL
|
|
);
|
|
|
|
-- Mensagens
|
|
CREATE TABLE messages (
|
|
id TEXT PRIMARY KEY,
|
|
conversation_id TEXT NOT NULL,
|
|
role TEXT NOT NULL CHECK(role IN ('user', 'assistant', 'system')),
|
|
content TEXT NOT NULL,
|
|
timestamp INTEGER NOT NULL,
|
|
FOREIGN KEY (conversation_id) REFERENCES conversations(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Embeddings vetoriais (384 dimensões do Ollama)
|
|
CREATE TABLE embeddings (
|
|
id TEXT PRIMARY KEY,
|
|
message_id TEXT NOT NULL,
|
|
vector BLOB NOT NULL,
|
|
FOREIGN KEY (message_id) REFERENCES messages(id) ON DELETE CASCADE
|
|
);
|
|
|
|
-- Índices para performance
|
|
CREATE INDEX idx_messages_conversation ON messages(conversation_id, timestamp);
|
|
CREATE INDEX idx_conversations_updated ON conversations(updated_at DESC);
|
|
CREATE INDEX idx_embeddings_message ON embeddings(message_id);
|