SQLite¶
SQLite DB is the database used by the agents and tools. It is used to store the conversations and context messages.
Initialize SQLite¶
Create a new SQLite database and tables.
SQLite Interface¶
director.db.sqlite.db.SQLiteDB
¶
Bases: BaseDB
Parameters:
Name | Type | Description | Default |
---|---|---|---|
db_path |
str
|
Path to the SQLite database file. |
'director.db'
|
Source code in backend/director/db/sqlite/db.py
create_session
¶
create_session(
session_id,
video_id,
collection_id,
created_at=None,
updated_at=None,
metadata={},
**kwargs
)
Create a new session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
video_id |
str
|
ID of the video associated with the session. |
required |
collection_id |
str
|
ID of the collection associated with the session. |
required |
created_at |
int
|
Timestamp when the session was created. |
None
|
updated_at |
int
|
Timestamp when the session was last updated. |
None
|
metadata |
dict
|
Additional metadata for the session. |
{}
|
Source code in backend/director/db/sqlite/db.py
get_session
¶
Get a session by session_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
Returns:
Type | Description |
---|---|
dict
|
Session data as a dictionary. |
Source code in backend/director/db/sqlite/db.py
get_sessions
¶
Get all sessions.
Returns:
Type | Description |
---|---|
list
|
List of all sessions. |
Source code in backend/director/db/sqlite/db.py
add_or_update_msg_to_conv
¶
add_or_update_msg_to_conv(
session_id,
conv_id,
msg_id,
msg_type,
agents,
actions,
content,
status=None,
created_at=None,
updated_at=None,
metadata={},
**kwargs
)
Add a new message (input or output) to the conversation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
conv_id |
str
|
Unique conversation ID. |
required |
msg_id |
str
|
Unique message ID. |
required |
msg_type |
str
|
Type of message (input or output). |
required |
agents |
list
|
List of agents involved in the conversation. |
required |
actions |
list
|
List of actions taken by the agents. |
required |
content |
list
|
List of message content. |
required |
status |
str
|
Status of the message. |
None
|
created_at |
int
|
Timestamp when the message was created. |
None
|
updated_at |
int
|
Timestamp when the message was last updated. |
None
|
metadata |
dict
|
Additional metadata for the message. |
{}
|
Source code in backend/director/db/sqlite/db.py
get_context_messages
¶
Get context messages for a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
Returns:
Type | Description |
---|---|
list
|
List of context messages. |
Source code in backend/director/db/sqlite/db.py
add_or_update_context_msg
¶
add_or_update_context_msg(
session_id,
context_messages,
created_at=None,
updated_at=None,
metadata={},
**kwargs
)
Update context messages for a session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
context_messages |
List
|
List of context messages. |
required |
created_at |
int
|
Timestamp when the context messages were created. |
None
|
updated_at |
int
|
Timestamp when the context messages were last updated. |
None
|
metadata |
dict
|
Additional metadata for the context messages. |
{}
|
Source code in backend/director/db/sqlite/db.py
delete_conversation
¶
Delete all conversations for a given session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if conversations were deleted, False otherwise. |
Source code in backend/director/db/sqlite/db.py
delete_context
¶
Delete context messages for a given session.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if context messages were deleted, False otherwise. |
Source code in backend/director/db/sqlite/db.py
delete_session
¶
Delete a session and all its associated data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session_id |
str
|
Unique session ID. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the session was deleted, False otherwise. |
Source code in backend/director/db/sqlite/db.py
health_check
¶
Check if the SQLite database is healthy and the necessary tables exist. If not, create them.