You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When a user sends a message via an action button using cl.action_callback, the assistant's reply does not display the feedback options (like/dislike). However, when a user types a message manually, the feedback options appear as expected. It seems that the context is lost within the callback function, preventing the feedback options from being associated with the assistant's responses triggered by action buttons.
To Reproduce
Steps to reproduce the behavior:
Generate follow-up questions using action buttons in the assistant's message:
actions = []
followup_questions = ["Question 1", "Question 2", "Question 3"]
for fq in followup_questions:
actions.append(cl.Action(name="action_button", value=fq, label=fq))
await cl.Message(content="Suggestions for further analysis:", actions=actions).send()
Implement the on_action callback to handle the action button clicks:
Expected behavior
The assistant's reply to a message sent via an action button should display the feedback options (like/dislike), just as it does when a message is typed manually by the user.
Additional context
When printing the context inside the on_action function, certain context attributes like cl.context.current_step are missing or None:
print(f"Context in on_action : {cl.context.__dict__}")
Output :
{
'loop': <EventLoop running=True closed=False debug=False>,
'session': <chainlit.session.WebsocketSession object at 0x...>,
'active_steps': [],
'emitter': <chainlit.emitter.ChainlitEmitter object at 0x...>
}
It appears that the context is not fully established within the on_action callback, which might be causing the issue.
Chainlit Version: 1.2.0
Python Version: 3.9.10
Question: How can I properly establish or mimic the context within the on_action callback so that the assistant's replies include the feedback options when messages are sent via action buttons?
Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered:
Hey @Elienvalleau! I'm Dosu, here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this together!
The issue you're experiencing with feedback options not appearing for messages sent via action buttons is likely due to the context not being fully established within the on_action callback. Here are some steps and considerations to help resolve this:
Ensure Proper Context Initialization: The cl.context object should be properly initialized and populated during the execution of an action callback. This involves ensuring that the session and emitter are correctly set up. You might need to manually set or adjust the context within the on_action callback to mimic the context of a normal message processing flow.
Check Feedback Conditions: Feedback options are typically associated with messages when certain conditions are met, such as the message being of type "assistant_message" and having non-empty output. Ensure that these conditions are satisfied in your on_message function when sending the assistant's reply [1].
Use cl.user_session for State Management: Utilize cl.user_session to manage and maintain the state across different callbacks and actions. This can help ensure that the necessary context and session data are preserved when handling messages triggered by action buttons [2].
Debug Context Attributes: Since certain context attributes like cl.context.current_step are missing or None, you may need to explicitly set these attributes if they are required for feedback options to appear. Investigate how these attributes are set during normal message processing and replicate that setup in your callback.
Review Chainlit Version Changes: Since you're using Chainlit version 1.2.0, check if there have been any changes or updates in the feedback mechanism or context handling in recent versions that might affect your implementation.
By ensuring that the context is fully established and the necessary conditions for feedback are met, you should be able to resolve the issue with feedback options not appearing for messages sent via action buttons.
Describe the bug
When a user sends a message via an action button using
cl.action_callback
, the assistant's reply does not display the feedback options (like/dislike). However, when a user types a message manually, the feedback options appear as expected. It seems that the context is lost within the callback function, preventing the feedback options from being associated with the assistant's responses triggered by action buttons.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The assistant's reply to a message sent via an action button should display the feedback options (like/dislike), just as it does when a message is typed manually by the user.
Additional context
When printing the context inside the
on_action
function, certain context attributes likecl.context.current_step
are missing or None:print(f"Context in on_action : {cl.context.__dict__}")
Output :
It appears that the context is not fully established within the
on_action
callback, which might be causing the issue.Chainlit Version: 1.2.0
Python Version: 3.9.10
Question: How can I properly establish or mimic the context within the
on_action
callback so that the assistant's replies include the feedback options when messages are sent via action buttons?Any guidance or suggestions on how to resolve this issue would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered: