Human in loop integration with autogen multiagents

I am trying to integrate the AutoGen Agents chatbot using the approach described in this article: Creating a Streamlit User Interface for AutoGen Agents | by Dr. Ernesto Lee | Medium.

the autogent userproxy code is look like this

class TrackableUserProxyAgent(UserProxyAgent):

def get_human_input(self, message):
    # Your custom function to handle human input
    print("Human input required:", message)
    
    user_query=""
    # Initialize the modal
    #modal = Modal(key="Provide input", title=message["content"], padding=20, max_width=744)
    # Define the content of the modal
    st.session_state['modal_open'] = True
    while st.session_state['modal_open']:
        st.stop()     

    # Additional content outside the modal
    user_query = st.session_state['dialog_input']
    print("User input:", user_query)
    st.write("This is the main app content.")
    
    # Return the human input (for example, from a user interface or other source)

    return user_query

def _process_received_message(self, message, sender, silent):
    #display_debug_messages(sender.name, message)
    return super()._process_received_message(message, sender, silent)

 # Initialize session state if needed
    if 'dialog_input' not in st.session_state:
        st.session_state['dialog_input'] = ""
    if 'modal_open' not in st.session_state:
        st.session_state['modal_open'] = False
        
    # Show modal until input is received
    #if st.session_state['modal_open']:
    self.show_dialog_popup(message)
        
    # Process input after modal is closed
    user_query = st.session_state['dialog_input']
    print("Received input:", user_query)
    return user_query 

I have successfully implemented the interaction using the function def get_human_input(self, message):. However, whenever new answer is entered by user, the entire app refreshes, making it impossible to pass the input to the calling agents. I would appreciate any guidance on how to return the reply to the agents without refreshing the app

Have you find the solution?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.