roboto.ai.agent_session.feedback#

Module Contents#

class roboto.ai.agent_session.feedback.AdminUpdateFeedbackRequest(/, **data)#

Bases: pydantic.BaseModel

Triage fields editable by Roboto admins.

Fields omitted from the request (NotSet) are left unchanged. Fields explicitly set to None clear the column back to NULL. Fields set to a value overwrite the column.

Setting resolved to True additionally stamps resolved_at and resolved_by server-side; setting it back to False clears them.

Parameters:

data (Any)

admin_label: str | None | roboto.sentinels.NotSetType#
admin_note: str | None | roboto.sentinels.NotSetType#
model_config#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

resolved: bool | roboto.sentinels.NotSetType#
class roboto.ai.agent_session.feedback.FeedbackCategory#

Bases: roboto.compat.StrEnum

Taxonomy of feedback categories.

Which categories are valid depends on sentiment (see category_is_valid_for_sentiment()). OTHER is always permitted; when OTHER is among the selected categories, notes is required.

CORRECT = 'correct'#
FORMATTING = 'formatting'#
GOOD_TOOL_USE = 'good_tool_use'#
HELPFUL = 'helpful'#
INCOMPLETE = 'incomplete'#
INCORRECT = 'incorrect'#
OTHER = 'other'#
REFUSED_VALID_REQUEST = 'refused_valid_request'#
SLOW = 'slow'#
TOOL_FAILURE = 'tool_failure'#
UNSAFE = 'unsafe'#
class roboto.ai.agent_session.feedback.FeedbackSentiment#

Bases: roboto.compat.StrEnum

Overall rating direction for a piece of AI-chat feedback.

NEGATIVE = 'negative'#
POSITIVE = 'positive'#
roboto.ai.agent_session.feedback.NEGATIVE_CATEGORIES: frozenset[FeedbackCategory]#
roboto.ai.agent_session.feedback.POSITIVE_CATEGORIES: frozenset[FeedbackCategory]#
class roboto.ai.agent_session.feedback.SubmitFeedbackRequest(/, **data)#

Bases: pydantic.BaseModel

Request body for submitting feedback on an assistant message.

One row per (session, message, user); resubmitting replaces the previous sentiment/categories/notes rather than adding a new row.

Parameters:

data (Any)

categories: list[FeedbackCategory] = None#

duplicates are dropped and the persisted order is enum-value sort, not request order.

Type:

Categories describing what was good or bad. Semantically a set

notes: str | None = None#

Free-text notes. Whitespace-only input is normalised to None before persistence. Required when FeedbackCategory.OTHER is selected.

sentiment: FeedbackSentiment#

Overall rating direction.

class roboto.ai.agent_session.feedback.UserFeedbackRecord(/, **data)#

Bases: pydantic.BaseModel

Customer-facing projection of AgentFeedbackRecord.

Excludes every admin-only column (admin_label, admin_note, resolved, resolved_by, resolved_at) so routes that serve an end user never return internal triage state. Use this as the return type of any non-admin endpoint that surfaces feedback, including the response to the submitter’s own submit call.

The admin endpoints continue to return AgentFeedbackRecord directly.

Parameters:

data (Any)

categories: list[FeedbackCategory] = None#

Categories describing the feedback. May be empty.

created: datetime.datetime#

When this feedback was first submitted.

created_by: str#

User id of the submitter.

feedback_id: str#

Unique identifier for this feedback entry.

classmethod from_admin_record(record)#

Project an AgentFeedbackRecord down to the user-facing shape.

Use at the boundary of any non-admin route that materialises a full admin record from persistence — the projection guarantees no admin triage column accidentally escapes to a customer response.

The projection is driven by cls.model_fields rather than a hand list of columns: a new submitter-controlled column added to both records flows through automatically, and a new admin-only column on AgentFeedbackRecord is silently dropped here (which is what we want for privacy). The matching test asserts the admin-only field set has not drifted unexpectedly.

Parameters:

record (AgentFeedbackRecord)

Return type:

UserFeedbackRecord

message_sequence_num: int#

Zero-indexed position of the assistant message within the session.

modified: datetime.datetime#

When the submitter last updated this feedback.

modified_by: str#

User id of the submitter’s last edit.

notes: str | None = None#

Free-text notes from the submitter, if any.

org_id: str#

Org the session belonged to at the time of submission.

sentiment: FeedbackSentiment#

Overall rating direction.

session_id: str#

Session the feedback was submitted against.

roboto.ai.agent_session.feedback.category_is_valid_for_sentiment(category, sentiment)#

Report whether category is a permitted choice under sentiment.

FeedbackCategory.OTHER is always permitted.

Parameters:
Return type:

bool