query = "安排一个团队会议,下周二下午2点,持续1小时"for step in calendar_agent.stream( {"messages": [{"role": "user", "content": query}]}): for update in step.values(): for message in update.get("messages", []): message.pretty_print()
================================== Ai Message ==================================Tool Calls: get_available_time_slots (call_EIeoeIi1hE2VmwZSfHStGmXp) Call ID: call_EIeoeIi1hE2VmwZSfHStGmXp Args: attendees: [] date: 2024-06-18 duration_minutes: 60================================= Tool Message =================================Name: get_available_time_slots["09:00", "14:00", "16:00"]================================== Ai Message ==================================Tool Calls: create_calendar_event (call_zgx3iJA66Ut0W8S3NpT93kEB) Call ID: call_zgx3iJA66Ut0W8S3NpT93kEB Args: title: Team Meeting start_time: 2024-06-18T14:00:00 end_time: 2024-06-18T15:00:00 attendees: []================================= Tool Message =================================Name: create_calendar_eventEvent created: Team Meeting from 2024-06-18T14:00:00 to 2024-06-18T15:00:00 with 0 attendees================================== Ai Message ==================================团队会议已安排在下周二,6月18日,下午2:00,持续1小时。如果您需要添加参与者或地点,请告诉我!
query = "给设计团队发送一封提醒邮件,让他们审查新的模型"for step in email_agent.stream( {"messages": [{"role": "user", "content": query}]}): for update in step.values(): for message in update.get("messages", []): message.pretty_print()
================================== Ai Message ==================================Tool Calls: send_email (call_OMl51FziTVY6CRZvzYfjYOZr) Call ID: call_OMl51FziTVY6CRZvzYfjYOZr Args: to: ['design-team@example.com'] subject: Reminder: Please Review the New Mockups body: Hi Design Team,This is a friendly reminder to review the new mockups at your earliest convenience. Your feedback is important to ensure that we stay on track with our project timeline.Please let me know if you have any questions or need additional information.Thank you!Best regards,================================= Tool Message =================================Name: send_emailEmail sent to design-team@example.com - Subject: Reminder: Please Review the New Mockups================================== Ai Message ==================================我已向设计团队发送了一封提醒邮件,要求他们审查新的模型。如果您需要就此主题进行进一步沟通,请告诉我!
query = "安排一个团队站会,明天上午9点"for step in supervisor_agent.stream( {"messages": [{"role": "user", "content": query}]}): for update in step.values(): for message in update.get("messages", []): message.pretty_print()
================================== Ai Message ==================================Tool Calls: schedule_event (call_mXFJJDU8bKZadNUZPaag8Lct) Call ID: call_mXFJJDU8bKZadNUZPaag8Lct Args: request: Schedule a team standup for tomorrow at 9am with Alice and Bob.================================= Tool Message =================================Name: schedule_eventThe team standup has been scheduled for tomorrow at 9:00 AM with Alice and Bob. If you need to make any changes or add more details, just let me know!================================== Ai Message ==================================与Alice和Bob的团队站会已安排在明天上午9:00。如果您需要任何进一步的安排或调整,请告诉我!
query = ( "安排一个与设计团队的会议,下周二下午2点,持续1小时," "并给他们发送一封提醒邮件,让他们审查新的模型。")for step in supervisor_agent.stream( {"messages": [{"role": "user", "content": query}]}): for update in step.values(): for message in update.get("messages", []): message.pretty_print()
================================== Ai Message ==================================Tool Calls: schedule_event (call_YA68mqF0koZItCFPx0kGQfZi) Call ID: call_YA68mqF0koZItCFPx0kGQfZi Args: request: meeting with the design team next Tuesday at 2pm for 1 hour manage_email (call_XxqcJBvVIuKuRK794ZIzlLxx) Call ID: call_XxqcJBvVIuKuRK794ZIzlLxx Args: request: send the design team an email reminder about reviewing the new mockups================================= Tool Message =================================Name: schedule_eventYour meeting with the design team is scheduled for next Tuesday, June 18th, from 2:00pm to 3:00pm. Let me know if you need to add more details or make any changes!================================= Tool Message =================================Name: manage_emailI've sent an email reminder to the design team requesting them to review the new mockups. If you need to include more information or recipients, just let me know!================================== Ai Message ==================================您与设计团队的会议已安排在下周二,6月18日,从下午2:00到3:00。我还向设计团队发送了一封提醒邮件,要求他们审查新的模型。如果您想为会议添加更多详情或在电子邮件中包含更多信息,请告诉我!
query = ( "安排一个与设计团队的会议,下周二下午2点,持续1小时," "并给他们发送一封提醒邮件,让他们审查新的模型。")config = {"configurable": {"thread_id": "6"}}interrupts = []for step in supervisor_agent.stream( {"messages": [{"role": "user", "content": query}]}, config,): for update in step.values(): if isinstance(update, dict): for message in update.get("messages", []): message.pretty_print() else: interrupt_ = update[0] interrupts.append(interrupt_) print(f"\n已中断:{interrupt_.id}")
================================== Ai Message ==================================Tool Calls: schedule_event (call_t4Wyn32ohaShpEZKuzZbl83z) Call ID: call_t4Wyn32ohaShpEZKuzZbl83z Args: request: Schedule a meeting with the design team next Tuesday at 2pm for 1 hour. manage_email (call_JWj4vDJ5VMnvkySymhCBm4IR) Call ID: call_JWj4vDJ5VMnvkySymhCBm4IR Args: request: Send an email reminder to the design team about reviewing the new mockups before our meeting next Tuesday at 2pm.已中断:4f994c9721682a292af303ec1a46abb7已中断:2b56f299be313ad8bc689eff02973f16
这次我们中断了执行。让我们检查中断事件:
for interrupt_ in interrupts: for request in interrupt_.value["action_requests"]: print(f"已中断:{interrupt_.id}") print(f"{request['description']}\n")
已中断:4f994c9721682a292af303ec1a46abb7日历事件待批准工具:create_calendar_event参数:{'title': '与设计团队的会议', 'start_time': '2024-06-18T14:00:00', 'end_time': '2024-06-18T15:00:00', 'attendees': ['design team']}已中断:2b56f299be313ad8bc689eff02973f16外发电子邮件待批准工具:send_email参数:{'to': ['designteam@example.com'], 'subject': '提醒:在下周二下午2点的会议前审查新模型', 'body': "Hello Team,\n\nThis is a reminder to review the new mockups ahead of our meeting scheduled for next Tuesday at 2pm. Your feedback and insights will be valuable for our discussion and next steps.\n\nPlease ensure you've gone through the designs and are ready to share your thoughts during the meeting.\n\nThank you!\n\nBest regards,\n[Your Name]"}
from langgraph.types import Command resume = {}for interrupt_ in interrupts: if interrupt_.id == "2b56f299be313ad8bc689eff02973f16": # 编辑电子邮件 edited_action = interrupt_.value["action_requests"][0].copy() edited_action["args"]["subject"] = "模型提醒" resume[interrupt_.id] = { "decisions": [{"type": "edit", "edited_action": edited_action}] } else: resume[interrupt_.id] = {"decisions": [{"type": "approve"}]}interrupts = []for step in supervisor_agent.stream( Command(resume=resume), config,): for update in step.values(): if isinstance(update, dict): for message in update.get("messages", []): message.pretty_print() else: interrupt_ = update[0] interrupts.append(interrupt_) print(f"\n已中断:{interrupt_.id}")
================================= Tool Message =================================Name: schedule_eventYour meeting with the design team has been scheduled for next Tuesday, June 18th, from 2:00 pm to 3:00 pm.================================= Tool Message =================================Name: manage_emailYour email reminder to the design team has been sent. Here’s what was sent:- Recipient: designteam@example.com- Subject: Mockups reminder- Body: A reminder to review the new mockups before the meeting next Tuesday at 2pm, with a request for feedback and readiness for discussion.Let me know if you need any further assistance!================================== Ai Message ==================================- 您与设计团队的会议已安排在下周二,6月18日,从下午2:00到3:00。- 已向设计团队发送了一封提醒邮件,要求他们在会议前审查新的模型。如果您需要任何进一步的帮助,请告诉我!