MCPcopy Create free account
hub / github.com/dashscope/dashscope-sdk-java / AgentStudioDeployments

Class AgentStudioDeployments

samples/AgentStudioDeployments.java:16–52  ·  view source on GitHub ↗

Managed Agent deployment example. Set DASHSCOPE_API_KEY and DASHSCOPE_WORKSPACE before running.

Source from the content-addressed store, hash-verified

14 * <p>Set DASHSCOPE_API_KEY and DASHSCOPE_WORKSPACE before running.
15 */
16public class AgentStudioDeployments {
17
18 public static void main(String[] args) {
19 try (AgentStudioClient client = new AgentStudioClient()) {
20 Deployment deployment =
21 client
22 .deployments()
23 .create(
24 DeploymentCreateParam.builder()
25 .name("daily-summary")
26 .description("Generate a daily summary")
27 .agent(DeploymentAgentParam.builder().id("agent_xxx").build())
28 .schedule(
29 DeploymentScheduleParam.builder()
30 .type(DeploymentScheduleParam.TYPE_CRON)
31 .expression("0 9 * * 1-5")
32 .timezone("Asia/Shanghai")
33 .build())
34 .initialEvents(
35 Collections.singletonList(
36 ClientEvents.userMessage("Summarize yesterday's orders")))
37 .metadata(Collections.singletonMap("biz", "summary"))
38 .build());
39 System.out.printf("deployment: %s %s%n", deployment.getId(), deployment.getStatus());
40
41 DeploymentRun run = client.deployments().run(deployment.getId());
42 System.out.printf("run: %s %s%n", run.getId(), run.getStatus());
43
44 for (DeploymentRun item :
45 client
46 .deployments()
47 .listRuns(deployment.getId(), DeploymentRunListParam.builder().limit(20).build())) {
48 System.out.printf("%s %s %s%n", item.getId(), item.getTriggerSource(), item.getStatus());
49 }
50 }
51 }
52}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected