From 4b9fd4acd09ebfb8b6c70d88dfbecdbec4426b09 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 07:06:57 +0530 Subject: [PATCH 1/6] adding thumbs up and thumbs down feedback via SDK --- databricks/sdk/service/dashboards.py | 97 +++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) diff --git a/databricks/sdk/service/dashboards.py b/databricks/sdk/service/dashboards.py index 44cb76800..060c9bb08 100755 --- a/databricks/sdk/service/dashboards.py +++ b/databricks/sdk/service/dashboards.py @@ -289,6 +289,12 @@ def from_dict(cls, d: Dict[str, Any]) -> DeleteSubscriptionResponse: return cls() +class FeedbackRating(Enum): + + THUMBS_UP = "THUMBS_UP" + THUMBS_DOWN = "THUMBS_DOWN" + + @dataclass class GenieAttachment: """Genie AI Response""" @@ -452,6 +458,59 @@ def from_dict(cls, d: Dict[str, Any]) -> GenieCreateConversationMessageRequest: ) +@dataclass +class GenieFeedbackRequest: + feedback_rating: FeedbackRating + """The feedback rating for the message.""" + + feedback_categories: Optional[List[str]] = None + """Optional list of feedback categories.""" + + def as_dict(self) -> dict: + """Serializes the GenieFeedbackRequest into a dictionary suitable for use as a JSON request body.""" + body = {} + if self.feedback_rating is not None: + body["feedback_rating"] = self.feedback_rating.value + if self.feedback_categories is not None: + body["feedback_categories"] = self.feedback_categories + return body + + def as_shallow_dict(self) -> dict: + """Serializes the GenieFeedbackRequest into a shallow dictionary of its immediate attributes.""" + body = {} + if self.feedback_rating is not None: + body["feedback_rating"] = self.feedback_rating + if self.feedback_categories is not None: + body["feedback_categories"] = self.feedback_categories + return body + + @classmethod + def from_dict(cls, d: Dict[str, Any]) -> GenieFeedbackRequest: + """Deserializes the GenieFeedbackRequest from a dictionary.""" + return cls( + feedback_rating=_enum(d, "feedback_rating", FeedbackRating), + feedback_categories=d.get("feedback_categories", None), + ) + + +@dataclass +class GenieFeedbackResponse: + def as_dict(self) -> dict: + """Serializes the GenieFeedbackResponse into a dictionary suitable for use as a JSON request body.""" + body = {} + return body + + def as_shallow_dict(self) -> dict: + """Serializes the GenieFeedbackResponse into a shallow dictionary of its immediate attributes.""" + body = {} + return body + + @classmethod + def from_dict(cls, d: Dict[str, Any]) -> GenieFeedbackResponse: + """Deserializes the GenieFeedbackResponse from a dictionary.""" + return cls() + + @dataclass class GenieGenerateDownloadFullQueryResultResponse: download_id: Optional[str] = None @@ -2109,6 +2168,42 @@ def start_conversation(self, space_id: str, content: str) -> Wait[GenieMessage]: def start_conversation_and_wait(self, space_id: str, content: str, timeout=timedelta(minutes=20)) -> GenieMessage: return self.start_conversation(content=content, space_id=space_id).result(timeout=timeout) + def submit_message_feedback( + self, space_id: str, conversation_id: str, message_id: str, feedback_rating: FeedbackRating, + feedback_categories: Optional[List[str]] = None + ) -> GenieFeedbackResponse: + """Submit feedback (thumbs up/down) for a Genie message. + + :param space_id: str + The ID associated with the Genie space. + :param conversation_id: str + The ID associated with the conversation. + :param message_id: str + The ID associated with the message. + :param feedback_rating: :class:`FeedbackRating` + The feedback rating (THUMBS_UP or THUMBS_DOWN). + :param feedback_categories: List[str] (optional) + Optional list of feedback categories. + + :returns: :class:`GenieFeedbackResponse` + """ + body = {} + if feedback_rating is not None: + body["feedback_rating"] = feedback_rating.value + if feedback_categories is not None: + body["feedback_categories"] = feedback_categories + headers = { + "Accept": "application/json", + "Content-Type": "application/json", + } + + res = self._api.do( + "POST", + f"/api/2.0/data-rooms/{space_id}/conversations/{conversation_id}/messages/{message_id}/feedback", + body=body, + headers=headers, + ) + return GenieFeedbackResponse.from_dict(res) class LakeviewAPI: """These APIs provide specific management operations for Lakeview dashboards. Generic resource management can @@ -2609,6 +2704,6 @@ def get_published_dashboard_token_info( } res = self._api.do( - "GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/tokeninfo", query=query, headers=headers + "GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/token-info", query=query, headers=headers ) return GetPublishedDashboardTokenInfoResponse.from_dict(res) From ec38b3078583b34ed7e5217d3a2d1fa80054c7b4 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 07:27:03 +0530 Subject: [PATCH 2/6] change back to og --- databricks/sdk/service/dashboards.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/databricks/sdk/service/dashboards.py b/databricks/sdk/service/dashboards.py index 060c9bb08..c72f6a07b 100755 --- a/databricks/sdk/service/dashboards.py +++ b/databricks/sdk/service/dashboards.py @@ -2704,6 +2704,6 @@ def get_published_dashboard_token_info( } res = self._api.do( - "GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/token-info", query=query, headers=headers + "GET", f"/api/2.0/lakeview/dashboards/{dashboard_id}/published/tokeninfo", query=query, headers=headers ) return GetPublishedDashboardTokenInfoResponse.from_dict(res) From a2a379c2ebe0b8b7c28d379ba276866f1b865f84 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 07:57:07 +0530 Subject: [PATCH 3/6] half baked comment TODO add annotation and custom response class --- databricks/sdk/service/dashboards.py | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/databricks/sdk/service/dashboards.py b/databricks/sdk/service/dashboards.py index c72f6a07b..77946b7c9 100755 --- a/databricks/sdk/service/dashboards.py +++ b/databricks/sdk/service/dashboards.py @@ -2205,6 +2205,40 @@ def submit_message_feedback( ) return GenieFeedbackResponse.from_dict(res) + def submit_comment( + self, space_id: str, conversation_id: str, message_id: str, content: str, comment_type: str + ) -> None: + """Submit a comment on a Genie message. + + :param space_id: str + The ID associated with the Genie space. + :param conversation_id: str + The ID associated with the conversation. + :param message_id: str + The ID associated with the message. + :param content: str + The content of the comment. + :param comment_type: str + The type of the comment (e.g., REQUEST_COMMENT, THUMBS_DOWN_COMMENT). + """ + body = { + "comment": { + "content": content, + "comment_type": comment_type + } + } + headers = { + "Content-Type": "application/json", + } + + self._api.do( + "POST", + f"/api/2.0/data-rooms/{space_id}/conversations/{conversation_id}/messages/{message_id}/comments", + body=body, + headers=headers, + ) + return True + class LakeviewAPI: """These APIs provide specific management operations for Lakeview dashboards. Generic resource management can be done with Workspace API (import, export, get-status, list, delete).""" From 755db36b3abedc82005fe27335d386495224f386 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 07:58:44 +0530 Subject: [PATCH 4/6] bool for now --- databricks/sdk/service/dashboards.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/databricks/sdk/service/dashboards.py b/databricks/sdk/service/dashboards.py index 77946b7c9..ac11657c6 100755 --- a/databricks/sdk/service/dashboards.py +++ b/databricks/sdk/service/dashboards.py @@ -2207,7 +2207,7 @@ def submit_message_feedback( def submit_comment( self, space_id: str, conversation_id: str, message_id: str, content: str, comment_type: str - ) -> None: + ) -> bool: """Submit a comment on a Genie message. :param space_id: str @@ -2220,6 +2220,8 @@ def submit_comment( The content of the comment. :param comment_type: str The type of the comment (e.g., REQUEST_COMMENT, THUMBS_DOWN_COMMENT). + + :returns: bool """ body = { "comment": { From 52a17719f6958d93ae36408eab98897142701f51 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 08:03:30 +0530 Subject: [PATCH 5/6] send for review --- databricks/sdk/service/dashboards.py | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/databricks/sdk/service/dashboards.py b/databricks/sdk/service/dashboards.py index ac11657c6..69914750a 100755 --- a/databricks/sdk/service/dashboards.py +++ b/databricks/sdk/service/dashboards.py @@ -2241,6 +2241,43 @@ def submit_comment( ) return True + def update_message_review_request( + self, space_id: str, conversation_id: str, message_id: str, review_request_status: str = "REQUESTED" + ) -> bool: + """Update message review request status. + + :param space_id: str + The ID associated with the Genie space. + :param conversation_id: str + The ID associated with the conversation. + :param message_id: str + The ID associated with the message. + :param review_request_status: str + The review request status (defaults to REQUESTED). + + :returns: bool + """ + body = { + "updated_message": { + "data_room_id": space_id, + "conversation_id": conversation_id, + "id": message_id, + "review_request_status": review_request_status + }, + "update_mask": ["REVIEW_REQUEST"] + } + headers = { + "Content-Type": "application/json", + } + + self._api.do( + "PATCH", + f"/api/2.0/data-rooms/{space_id}/conversations/{conversation_id}/messages/{message_id}", + body=body, + headers=headers, + ) + return True + class LakeviewAPI: """These APIs provide specific management operations for Lakeview dashboards. Generic resource management can be done with Workspace API (import, export, get-status, list, delete).""" From 24b5c88d293b6d30697163a7faa1261364b83487 Mon Sep 17 00:00:00 2001 From: pavel-chowdhury-maersk Date: Wed, 9 Jul 2025 08:30:57 +0530 Subject: [PATCH 6/6] updating changelog for genie feedback --- NEXT_CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEXT_CHANGELOG.md b/NEXT_CHANGELOG.md index 9bb0298b3..caf2017ce 100644 --- a/NEXT_CHANGELOG.md +++ b/NEXT_CHANGELOG.md @@ -11,6 +11,10 @@ ### Internal Changes ### API Changes +* Added `submit_message_feedback` method for `databricks.sdk.service.dashboards.GenieAPI`. +* Added `submit_comment` method for `databricks.sdk.service.dashboards.GenieAPI`. +* Added `update_message_review_request` method for `databricks.sdk.service.dashboards.GenieAPI`. +* Added `FeedbackRating` enum for `databricks.sdk.service.dashboards`. * Added `remote_disk_throughput` and `total_initial_remote_disk_size` fields for `databricks.sdk.service.compute.ClusterAttributes`. * Added `remote_disk_throughput` and `total_initial_remote_disk_size` fields for `databricks.sdk.service.compute.ClusterDetails`. * Added `remote_disk_throughput` and `total_initial_remote_disk_size` fields for `databricks.sdk.service.compute.ClusterSpec`.