-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathagentstudio_deployments.py
More file actions
34 lines (26 loc) · 1.03 KB
/
Copy pathagentstudio_deployments.py
File metadata and controls
34 lines (26 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# -*- coding: utf-8 -*-
"""Create and run a Managed Agent deployment.
Set DASHSCOPE_API_KEY and DASHSCOPE_WORKSPACE before running this sample.
"""
from dashscope.agentstudio import Client, user_message
def main() -> None:
with Client() as client:
deployment = client.deployments.create(
name="daily-summary",
description="Generate a daily summary",
agent={"id": "agent_xxx"},
schedule={
"type": "cron",
"expression": "0 9 * * 1-5",
"timezone": "Asia/Shanghai",
},
initial_events=[user_message("Summarize yesterday's orders")],
metadata={"biz": "summary"},
)
print("deployment:", deployment.id, deployment.status)
run = client.deployments.run(deployment.id)
print("run:", run.id, run.status)
for item in client.deployments.list_runs(deployment.id, limit=20):
print(item.id, item.trigger_source, item.status)
if __name__ == "__main__":
main()