Replies: 1 comment 1 reply
-
As long as the runtime is stored in your user session or in memory of the server, its state is persisted. You can also use
You can use For example: # In your FastAPI handler or ChainLit handler for user input
await runtime.publish_message(UserInputMessage(content=...), TopicId(user_agent_topic_type, "<user_session_id>") Your @type_subscription(user_agent_topic_type)
class UserAgent(RoutedAgent):
def __init__(self, description: str, group_chat_topic_type: str) -> None:
super().__init__(description=description)
self._group_chat_topic_type = group_chat_topic_type
@message_handler
async def handle_message(self, message: GroupChatMessage, ctx: MessageContext) -> None:
# When integrating with a frontend, this is where group chat message would be sent to the frontend.
pass
@message_handler
async def handle_request_to_speak(self, message: RequestToSpeak, ctx: MessageContext) -> None:
# Send a message to the UI to prompt the user to provide an input and returns
pass
@message_handler
async def handle_user_input(self, message: UserInputMessage, ctx: MessageContext) -> None:
# Publish the message content to the group chat.
await self.publish_message(GroupChatMessage(content="...", source="..."), DefaultTopicId(self._group_chat_topic_type)) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am running Autogen on python application, and I am calling the agent via a Rest API.
I want the Agent to pause when user intervention is needed (here I intend to use UserAgent as the stop condition). However, I encountered a problem. After the user inputs a new question(via Rest API), how can I get the Agent to resume from where it left off? (Is it possible to maintain the runtime state and continue execution from there?)
Beta Was this translation helpful? Give feedback.
All reactions