Skip to content

Commit

Permalink
Add title argument to SetSuggestedPrompts arguments (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch authored Oct 28, 2024
1 parent 888a11f commit 131f8e1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, Union
from typing import List, Dict, Union, Optional

from slack_sdk.web.async_client import AsyncWebClient
from slack_sdk.web.async_slack_response import AsyncSlackResponse
Expand All @@ -19,7 +19,11 @@ def __init__(
self.channel_id = channel_id
self.thread_ts = thread_ts

async def __call__(self, prompts: List[Union[str, Dict[str, str]]]) -> AsyncSlackResponse:
async def __call__(
self,
prompts: List[Union[str, Dict[str, str]]],
title: Optional[str] = None,
) -> AsyncSlackResponse:
prompts_arg: List[Dict[str, str]] = []
for prompt in prompts:
if isinstance(prompt, str):
Expand All @@ -31,4 +35,5 @@ async def __call__(self, prompts: List[Union[str, Dict[str, str]]]) -> AsyncSlac
channel_id=self.channel_id,
thread_ts=self.thread_ts,
prompts=prompts_arg,
title=title,
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict, Union
from typing import List, Dict, Union, Optional

from slack_sdk import WebClient
from slack_sdk.web import SlackResponse
Expand All @@ -19,7 +19,11 @@ def __init__(
self.channel_id = channel_id
self.thread_ts = thread_ts

def __call__(self, prompts: List[Union[str, Dict[str, str]]]) -> SlackResponse:
def __call__(
self,
prompts: List[Union[str, Dict[str, str]]],
title: Optional[str] = None,
) -> SlackResponse:
prompts_arg: List[Dict[str, str]] = []
for prompt in prompts:
if isinstance(prompt, str):
Expand All @@ -31,4 +35,5 @@ def __call__(self, prompts: List[Union[str, Dict[str, str]]]) -> SlackResponse:
channel_id=self.channel_id,
thread_ts=self.thread_ts,
prompts=prompts_arg,
title=title,
)
3 changes: 3 additions & 0 deletions tests/scenario_tests/test_events_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def start_thread(say: Say, set_suggested_prompts: SetSuggestedPrompts, context:
assert context.thread_ts == "1726133698.626339"
say("Hi, how can I help you today?")
set_suggested_prompts(prompts=[{"title": "What does SLACK stand for?", "message": "What does SLACK stand for?"}])
set_suggested_prompts(
prompts=[{"title": "What does SLACK stand for?", "message": "What does SLACK stand for?"}], title="foo"
)
state["called"] = True

@assistant.thread_context_changed
Expand Down
4 changes: 4 additions & 0 deletions tests/scenario_tests_async/test_events_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ async def start_thread(say: AsyncSay, set_suggested_prompts: AsyncSetSuggestedPr
await set_suggested_prompts(
prompts=[{"title": "What does SLACK stand for?", "message": "What does SLACK stand for?"}]
)
await set_suggested_prompts(
prompts=[{"title": "What does SLACK stand for?", "message": "What does SLACK stand for?"}],
title="foo",
)
state["called"] = True

@assistant.thread_context_changed
Expand Down

0 comments on commit 131f8e1

Please sign in to comment.