GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add assistant.search.context method (#1667) · slackapi/python-slack-sdk@b935494

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • slack_sdk/web
    • async_client.py
    • client.py
    • legacy_client.py
  • tests/slack_sdk_async/web
    • test_web_client_coverage.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎slack_sdk/web/async_client.py‎

Copy file name to clipboardExpand all lines: slack_sdk/web/async_client.py
+62Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎slack_sdk/web/client.py‎

Copy file name to clipboardExpand all lines: slack_sdk/web/client.py
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,68 @@ def tooling_tokens_rotate(
27482748
kwargs.update({"refresh_token": refresh_token})
27492749
return self.api_call("tooling.tokens.rotate", params=kwargs)
27502750

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+
27512813
def assistant_threads_setStatus(
27522814
self,
27532815
*,
Collapse file

‎slack_sdk/web/legacy_client.py‎

Copy file name to clipboardExpand all lines: slack_sdk/web/legacy_client.py
+62Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎tests/slack_sdk_async/web/test_web_client_coverage.py‎

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 numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def setUp(self):
6767
# TODO: admin.audit.anomaly.allow.* / The endpoints requires a "session" token
6868
"admin.audit.anomaly.allow.getItem",
6969
"admin.audit.anomaly.allow.updateItem",
70-
"assistant.search.context", # TODO: add this method in follow up PR
7170
"conversations.requestSharedInvite.list", # TODO: add this method in follow up PR
7271
]:
7372
continue
@@ -548,6 +547,15 @@ async def run_method(self, method_name, method, async_method):
548547
elif method_name == "apps_user_connection_update":
549548
self.api_methods_to_call.remove(method(user_id="U12345678", status="connected")["method"])
550549
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?")
551559
elif method_name == "assistant_threads_setStatus":
552560
self.api_methods_to_call.remove(
553561
method(channel_id="D111", thread_ts="111.222", status="is typing...")["method"]

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.