Services
chat_history_from_id(message_history_id, session)
Retrieves a chat history from the database based on the given ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
message_history_id
|
str
|
The unique identifier of the chat history. |
required |
session
|
Session
|
The database session used to execute the query. |
required |
Returns:
Name | Type | Description |
---|---|---|
MessageHistoryDB |
MessageHistoryDB
|
The retrieved chat history object. If not found, a new instance is created. |
Raises:
Type | Description |
---|---|
NoResultFound
|
If no chat history is found, a new one is instantiated instead. |
Source code in api/chat/services.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
save_assistant_message_in_chat(content, chat)
Saves an assistant message in the chat history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The message content from the assistant. |
required |
chat
|
MessageHistoryDB
|
The chat history object where the message should be stored. |
required |
Source code in api/chat/services.py
50 51 52 53 54 55 56 57 58 59 60 |
|
save_user_message_in_chat(content, chat)
Saves a user message in the chat history.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The message content from the user. |
required |
chat
|
MessageHistoryDB
|
The chat history object where the message should be stored. |
required |
Source code in api/chat/services.py
37 38 39 40 41 42 43 44 45 46 47 |
|