GeezerVison is showing github.com — feat: add assistant.search.context method (#1667) · slackapi/python-slack-sdk@b935494
File treeExpand file treeCollapse file tree Open diff view settings tests/slack_sdk_async/web
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: slack_sdk/web/async_client.py +62Lines changed: 62 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: slack_sdk/web/client.py +62Lines changed: 62 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2748,6 +2748,68 @@ def tooling_tokens_rotate( | 2748 | 2748 | kwargs.update({"refresh_token": refresh_token}) | 2749 | 2749 | return self.api_call("tooling.tokens.rotate", params=kwargs) | 2750 | 2750 |
| | 2751 | + def assistant_search_context( | | 2752 | + self, | | 2753 | + *, | | 2754 | + query: str, | | 2755 | + action_token: Optional[str] = None, | | 2756 | + channel_types: Optional[Union[str, Sequence[str]]] = None, | | 2757 | + content_types: Optional[Union[str, Sequence[str]]] = None, | | 2758 | + include_bots: Optional[bool] = None, | | 2759 | + include_deleted_users: Optional[bool] = None, | | 2760 | + before: Optional[int] = None, | | 2761 | + after: Optional[int] = None, | | 2762 | + include_context_messages: Optional[bool] = None, | | 2763 | + context_channel_id: Optional[str] = None, | | 2764 | + cursor: Optional[str] = None, | | 2765 | + limit: Optional[int] = None, | | 2766 | + sort: Optional[str] = None, | | 2767 | + sort_dir: Optional[str] = None, | | 2768 | + include_message_blocks: Optional[bool] = None, | | 2769 | + highlight: Optional[bool] = None, | | 2770 | + term_clauses: Optional[Sequence[str]] = None, | | 2771 | + modifiers: Optional[str] = None, | | 2772 | + include_archived_channels: Optional[bool] = None, | | 2773 | + disable_semantic_search: Optional[bool] = None, | | 2774 | + **kwargs, | | 2775 | + ) -> SlackResponse: | | 2776 | + """Searches messages, files, channels and users across your Slack organization. | | 2777 | +
| | 2778 | + https://docs.slack.dev/reference/methods/assistant.search.context | | 2779 | + """ | | 2780 | + kwargs.update( | | 2781 | + { | | 2782 | + "query": query, | | 2783 | + "action_token": action_token, | | 2784 | + "include_bots": include_bots, | | 2785 | + "include_deleted_users": include_deleted_users, | | 2786 | + "before": before, | | 2787 | + "after": after, | | 2788 | + "include_context_messages": include_context_messages, | | 2789 | + "context_channel_id": context_channel_id, | | 2790 | + "cursor": cursor, | | 2791 | + "limit": limit, | | 2792 | + "sort": sort, | | 2793 | + "sort_dir": sort_dir, | | 2794 | + "include_message_blocks": include_message_blocks, | | 2795 | + "highlight": highlight, | | 2796 | + "modifiers": modifiers, | | 2797 | + "include_archived_channels": include_archived_channels, | | 2798 | + "disable_semantic_search": disable_semantic_search, | | 2799 | + } | | 2800 | + ) | | 2801 | + if isinstance(channel_types, (list, tuple)): | | 2802 | + kwargs.update({"channel_types": ",".join(channel_types)}) | | 2803 | + else: | | 2804 | + kwargs.update({"channel_types": channel_types}) | | 2805 | + if isinstance(content_types, (list, tuple)): | | 2806 | + kwargs.update({"content_types": ",".join(content_types)}) | | 2807 | + else: | | 2808 | + kwargs.update({"content_types": content_types}) | | 2809 | + if term_clauses is not None: | | 2810 | + kwargs.update({"term_clauses": json.dumps(term_clauses)}) | | 2811 | + return self.api_call("assistant.search.context", params=kwargs) | | 2812 | + | 2751 | 2813 | def assistant_threads_setStatus( | 2752 | 2814 | self, | 2753 | 2815 | *, | |
Collapse file Copy file name to clipboardExpand all lines: slack_sdk/web/legacy_client.py +62Lines changed: 62 additions & 0 deletions Collapse file Copy file name to clipboardExpand all lines: tests/slack_sdk_async/web/test_web_client_coverage.py +9-1Lines changed: 9 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,6 @@ def setUp(self): | 67 | 67 | # TODO: admin.audit.anomaly.allow.* / The endpoints requires a "session" token | 68 | 68 | "admin.audit.anomaly.allow.getItem", | 69 | 69 | "admin.audit.anomaly.allow.updateItem", | 70 | | - "assistant.search.context", # TODO: add this method in follow up PR | 71 | 70 | "conversations.requestSharedInvite.list", # TODO: add this method in follow up PR | 72 | 71 | ]: | 73 | 72 | continue | @@ -548,6 +547,15 @@ async def run_method(self, method_name, method, async_method): | 548 | 547 | elif method_name == "apps_user_connection_update": | 549 | 548 | self.api_methods_to_call.remove(method(user_id="U12345678", status="connected")["method"]) | 550 | 549 | await async_method(user_id="U12345678", status="connected") | | 550 | + elif method_name == "assistant_search_context": | | 551 | + self.api_methods_to_call.remove(method(query="What is project gizmo?")["method"]) | | 552 | + method( | | 553 | + query="What is the latest on project Gizmo?", | | 554 | + channel_types=["public_channel", "private_channel", "mpim", "im"], | | 555 | + content_types=["messages", "files", "channels"], | | 556 | + term_clauses=["project gizmo"], | | 557 | + ) | | 558 | + await async_method(query="What is project gizmo?") | 551 | 559 | elif method_name == "assistant_threads_setStatus": | 552 | 560 | self.api_methods_to_call.remove( | 553 | 561 | method(channel_id="D111", thread_ts="111.222", status="is typing...")["method"] | |
|