Something went wrong. Try again.
the coolest token pot ever
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243-- name: CreateStream :oneINSERT INTO streams ( id, conversation_id, user_id, assistant_message_id, idempotency_key, model, status, started_at) VALUES (?, ?, ?, ?, ?, ?, 'pending', ?)RETURNING *;
-- name: GetStreamByIdempotencyKey :oneSELECT * FROM streams WHERE user_id = ? AND idempotency_key = ?;
-- name: GetStream :oneSELECT * FROM streams WHERE id = ?;
-- name: SetStreamStatus :execUPDATE streams SET status = ?, finished_at = ?, error_code = ?, error_message = ?WHERE id = ?;
-- name: CountActiveStreamsForUser :oneSELECT COUNT(*) FROM streamsWHERE user_id = ? AND status IN ('pending', 'running');
-- name: AppendStreamChunk :execINSERT INTO stream_chunks (stream_id, seq, event, data, created_at)VALUES (?, ?, ?, ?, ?);
-- name: ListStreamChunksAfter :manySELECT seq, event, data, created_atFROM stream_chunksWHERE stream_id = ? AND seq > ?ORDER BY seq ASC;
-- name: MaxStreamChunkSeq :oneSELECT COALESCE(MAX(seq), 0) FROM stream_chunks WHERE stream_id = ?;
-- name: GetRunningStreamForConversation :one-- Returns the most-recently-started stream for a conversation that is-- currently running. Used by handleConversationEvents to bootstrap-- observers who connect after the stream has already started.SELECT * FROM streamsWHERE conversation_id = ? AND status = 'running'ORDER BY started_at DESCLIMIT 1;