Index

public.chatbot_conversation_messages

Description

The messages in a conversation between a student and a chatbot.

Columns

Name Type Default Nullable Children Parents Comment
conversation_id uuid false public.chatbot_conversations The conversation this message belongs to.
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
id uuid uuid_generate_v4() false public.chatbot_conversation_message_tool_calls public.chatbot_conversation_message_tool_outputs public.chatbot_conversation_messages_citations A unique, stable identifier for the record.
message varchar(131072) true The message content.
message_is_complete boolean false false Always true for messages from the user. The chatbot messages are streamed to the client, and this field is used to indicate whether that the stream is complete.
message_role message_role false The role of the message, is it from the user or the chatbot, or does it contain chatbot tool call output.
order_number integer false The order of the message in the conversation.
tool_output_id uuid true public.chatbot_conversation_message_tool_outputs If this message is a role “tool” message that contains tool output, this column is set. The corresponding row in chatbot_conversation_message_tool_outputs contains info about the tool call output.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.
used_tokens integer 0 false The number of tokens used to send or receive this message.

Constraints

Name Type Definition
chatbot_conversation_messages_conversation_id_fkey FOREIGN KEY FOREIGN KEY (conversation_id) REFERENCES chatbot_conversations(id)
chatbot_conversation_messages_conversation_id_not_null n NOT NULL conversation_id
chatbot_conversation_messages_conversation_id_order_number__key UNIQUE UNIQUE NULLS NOT DISTINCT (conversation_id, order_number, deleted_at)
chatbot_conversation_messages_created_at_not_null n NOT NULL created_at
chatbot_conversation_messages_id_not_null n NOT NULL id
chatbot_conversation_messages_message_is_complete_not_null n NOT NULL message_is_complete
chatbot_conversation_messages_message_role_not_null n NOT NULL message_role
chatbot_conversation_messages_order_number_not_null n NOT NULL order_number
chatbot_conversation_messages_pkey PRIMARY KEY PRIMARY KEY (id)
chatbot_conversation_messages_tool_output_id_fkey FOREIGN KEY FOREIGN KEY (tool_output_id) REFERENCES chatbot_conversation_message_tool_outputs(id)
chatbot_conversation_messages_updated_at_not_null n NOT NULL updated_at
chatbot_conversation_messages_used_tokens_not_null n NOT NULL used_tokens
is_tool_result_message CHECK CHECK ((((message_role <> ‘tool’::message_role) AND (tool_output_id IS NULL)) OR ((message_role = ‘tool’::message_role) AND (message IS NULL))))
is_user_message CHECK CHECK ((((message_role = ‘user’::message_role) AND (tool_output_id IS NULL) AND (message IS NOT NULL)) OR (message_role <> ‘user’::message_role)))

Indexes

Name Definition
chatbot_conversation_messages_conversation_id_order_number__key CREATE UNIQUE INDEX chatbot_conversation_messages_conversation_id_order_number__key ON public.chatbot_conversation_messages USING btree (conversation_id, order_number, deleted_at) NULLS NOT DISTINCT
chatbot_conversation_messages_pkey CREATE UNIQUE INDEX chatbot_conversation_messages_pkey ON public.chatbot_conversation_messages USING btree (id)

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.chatbot_conversation_messages FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls