-
The following code is a Team I created. When the concurrency is high, the team cannot be stopped and is always in the running state and cannot be reset. How to solve it ? # Create agents for different functions
class AutoGenProcessor:
def __init__(self):
# Initialize memory
# Create chat response agent
self.grammar_agent = AssistantAgent(
"grammar_agent",
model_client=openai_client,
system_message="You are an American English proofreading assistant",
model_client_stream=True,
)
self.critic_agent = AssistantAgent(
name="critic",
model_client=openai_client,
system_message="You are an assistant for proofreading American English. You check the results to see if there are any omissions, inaccurate output format, incorrect classification, etc. If the results are all correct, you return an 'APPROVE' as the end.",
)
self.text_termination = TextMentionTermination("APPROVE")
self.external_termination = ExternalTermination()
self.max_msg_termination = MaxMessageTermination(max_messages=3)
self.team = RoundRobinGroupChat([self.grammar_agent, self.critic_agent], termination_condition=self.external_termination |self.max_msg_termination)
async def check_en(self,text:str):
try:
self.grammar_agent._system_messages[0].content="You are an American English proofreading assistant"
self.critic_agent._system_messages[0].content ="You are an assistant for proofreading American English. You check the results to see if there are any omissions, inaccurate output format, incorrect classification, etc. If the results are all correct, you return an 'APPROVE' as the end."
if self.team._is_running:
self.team.external_termination = ExternalTermination()|self.max_msg_termination
self.external_termination.set()
await asyncio.sleep(0.5)
await self.team.reset()
prompt="xxxxxxx"
result = await self.team.run(task=prompt)
grammar_content = ""
...... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
How many teams are you running? Also, what's your network latency looks like? And most importantly how busy is your model endpoint-- has it been rate throttled? External termination is for graceful stop. If you don't care about keeping a consistent state, just cancel using the cancellation token? |
Beta Was this translation helpful? Give feedback.
You can use
reset()
on the team to clear the history -- however, this is not good for concurrency. As you may have multiple concurrent sessions.I suggest creating new team for each new user session. You can preload the team with existing state from previous sessions.