Chat Flags (🧪Beta)
albert.collections.chat_flags.ChatFlagCollection
Manage flags on "Ask Albert" chat messages (🧪 Beta).
A chat flag (ChatFlag) is a marker set on a
single message turn in a conversation with Albert's AI assistant, used chiefly
to capture feedback and interaction state. A message can be flagged as
starred, downloaded, requested, or hallucinated (see
ChatFlagType). Flags reference a message by
its session, request, and sequence, the same coordinates used by
ChatMessageCollection.
This is an async collection accessed as client.chat_flags on an
AsyncAlbert client.
Beta Feature!
Please do not use in production or without explicit guidance from Albert. You might otherwise have a bad experience. This feature currently falls outside of the Albert support contract, but we'd love your feedback!
Example
from albert import AsyncAlbert
from albert.resources.chats import ChatFlagType
async with AsyncAlbert() as client:
await client.chat_flags.add(
session_id="<session id>",
source_request_id="<request id>",
sequence="000",
type=ChatFlagType.STARRED,
)
starred = await client.chat_flags.get_all(type=ChatFlagType.STARRED)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncAlbertSession
|
The authenticated Albert async session used for API calls. |
required |
Methods:
| Name | Description |
|---|---|
get_all |
List all flagged messages of a given flag type. |
get_by_message |
Get all flags set on a specific message. |
add |
Add a flag to a message. |
remove |
Remove a flag from a message. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AsyncAlbertSession
|
The authenticated Albert async session used for API calls. |
required |
Source code in src/albert/collections/chat_flags.py
get_all
get_all(*, type: ChatFlagType) -> list[ChatFlag]
List all flagged messages of a given type.
Returns flag records for the given
ChatFlagType across ALL sessions the
authenticated user can access (not a single session). Each record is a
pointer, not the full message body: parent_id (session id),
source_request_id, sequence, and an optional component_type.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
type
|
ChatFlagType
|
The flag type to filter by. |
required |
Returns:
| Type | Description |
|---|---|
list[ChatFlag]
|
Flagged messages matching the given type. |
Source code in src/albert/collections/chat_flags.py
get_by_message
get_by_message(
*,
session_id: str,
source_request_id: str,
sequence: str | None = None,
) -> ChatFlagsInMessage
Get all flags set on a specific message.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The ID of the parent |
required |
source_request_id
|
str
|
The request trace identifier of the message. |
required |
sequence
|
str | None
|
The zero-padded sequence of the message within the session
(e.g. |
None
|
Returns:
| Type | Description |
|---|---|
ChatFlagsInMessage
|
A summary of the flag types set on the message. |
Source code in src/albert/collections/chat_flags.py
add
add(
*,
session_id: str,
source_request_id: str,
sequence: str,
type: ChatFlagType,
component_type: ChatComponentType | None = None,
) -> ChatFlag
Add a flag to a message.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The ID of the parent |
required |
source_request_id
|
str
|
The request trace identifier of the message. |
required |
sequence
|
str
|
The zero-padded sequence of the message within the session
(e.g. |
required |
type
|
ChatFlagType
|
The flag type to add. |
required |
component_type
|
ChatComponentType | None
|
Narrow the flag to a single
|
None
|
Returns:
| Type | Description |
|---|---|
ChatFlag
|
The created flag. |
Source code in src/albert/collections/chat_flags.py
remove
remove(
*,
session_id: str,
source_request_id: str,
sequence: str,
type: ChatFlagType,
component_type: ChatComponentType | None = None,
) -> None
Remove a flag from a message.
Example
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session_id
|
str
|
The ID of the parent |
required |
source_request_id
|
str
|
The request trace identifier of the message. |
required |
sequence
|
str
|
The zero-padded sequence of the message within the session
(e.g. |
required |
type
|
ChatFlagType
|
The flag type to remove. |
required |
component_type
|
ChatComponentType | None
|
Narrow the removal to a single
|
None
|
Returns:
| Type | Description |
|---|---|
None
|
|