Models¶
dj_chatbot.models.Conversation
¶
Bases: Model
A chat conversation grouping related messages exchanged with the agent.
Each conversation holds an ordered sequence of Message
records and is identified by a stable thread_id used to persist and resume state
across requests. Optionally, a conversation can be linked to a Django user.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Primary key. Auto-generated UUID. |
|
thread_id |
Stable identifier used to group messages and resume agent state across requests. |
|
user |
Optional owner of the conversation. |
|
title |
Human-readable title. Empty by default; can be set to summarize the conversation. |
|
created_at |
Timestamp when the conversation was first created. |
|
updated_at |
Timestamp of the last change. Used as the default ordering key. |
Source code in src/dj_chatbot/models.py
dj_chatbot.models.Message
¶
Bases: Model
A single message belonging to a Conversation.
Messages capture every turn in the exchange: user input, assistant replies,
system instructions, and tool calls. The role field identifies the author and
metadata can store structured provider-specific payloads (token usage, tool
arguments, etc.) without changing the schema.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Primary key. Auto-generated UUID. |
|
conversation |
The conversation this message belongs to. Cascades on delete. |
|
role |
Who authored the message — see |
|
content |
Plain-text content of the message. May be empty for tool-only turns. |
|
metadata |
Free-form JSON for provider-specific data (tool calls, token usage, etc.). |
|
created_at |
Timestamp when the message was stored. Used for chronological ordering. |