Closed RovoMe closed 1 month ago
Hi, @RovoMe! Thanks for submitting your question! 🙌
If I understand your question correctly, it looks like it might be similar to what is described here. The course of action they recommend is:
force slack to rebuild the ui element (in this case the text input field) by giving it a new block id when calling views_update().
I hope this helps! Let me know if you have further questions.
Ok, I got this now working with this following modification:
if prompt is not None:
rand_str: str = "".join(choice(ascii_lowercase) for i in range(12))
print(f"prompt in modal: {prompt} - new block_id: {rand_str}")
block: dict = ret["blocks"][2]
block.update({
"block_id": rand_str
})
element: dict = block["element"]
element.update({
"initial_value": prompt
})
else:
default_prompt = "You are a helpful assistant for ..."
print(f"Using default prompt: {default_prompt}")
element: dict = ret["blocks"][2]["element"]
element.update({
"initial_value": default_prompt
})
Still feels odd to add a random block_id
on each selection change when the same block_id
works on chaning the prompt selection when no initial value was set in the initial view.
👋 It looks like this issue has been open for 30 days with no activity. We'll mark this as stale for now, and wait 10 days for an update or for further comment before closing this issue out. If you think this issue needs to be prioritized, please comment to get the thread going again! Maintainers also review issues marked as stale on a regular basis and comment or adjust status if the issue needs to be reprioritized.
As this issue has been inactive for more than one month, we will be closing it. Thank you to all the participants! If you would like to raise a related issue, please create a new issue which includes your specific details and references this issue number.
For a project to integrate some AI models via Slack as GUI basically we came up with a modal view where users can configure the parameters for an initial conversation with a particular LLM / service:
The second input selection should allow a user to load some predefined prompts into the prompt input text area. In order to achieve that we have defined a block action listener for the second input selection like this:
On selecting one of the options in the promt choice the respective prompt input text area is successfully updated. However, when the currently commented out part is enabled again and the default value written to the input box, the
views_update(...)
method receives the correct modal view representation though the view in Slack never updates to the value of the selected option. With the block commented out though, the values update perfectly.As this issue sound familiar in a way to the this one here I also made sure that the hash is set to the one of the previous view before doing an update. The log for the case when the commented code is enabled again looks like this, which looks like the view should be updated with the specified value:
However, the
prompt_input
field remains at "You are a helpful assistant for ..." no matter what I select. If I omit the default prompt setting, values update successfully in theprompt_input
when I change a value in the prompt selection.As Python is not my main language, chances are that I'm doing something compeltely wrong here. But I'm still wondering why in the case where no
initial_value
is available before the request hits the block action handler for the prompt selection selecting a value in the respective prompt selection drop down updates the input field perfectly and in the case an initial value was set beforehand it does not. I also checked for any particular errors returned, butresponse["ok"]
returnsTrue
in all cases.