| 21 | import java.util.Date; |
| 22 | |
| 23 | public class AssistantSimple { |
| 24 | public static void assistantUsage() throws ApiException, NoApiKeyException, InputRequiredException, InvalidateParameter, InterruptedException { |
| 25 | Assistants assistants = new Assistants(); |
| 26 | // build assistant parameters |
| 27 | AssistantParam param = AssistantParam.builder() |
| 28 | // 此处以qwen-max为例,可按需更换模型名称。模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models |
| 29 | .model("qwen-max") |
| 30 | .name("intelligent guide") |
| 31 | .description("a smart guide") |
| 32 | .instructions("You are a helpful assistant.") |
| 33 | .tool(ToolQuarkSearch.builder().build()) |
| 34 | .topP(0.8f) |
| 35 | .topK(8) |
| 36 | .temperature(0.8f) |
| 37 | .maxTokens(2048) |
| 38 | .build(); |
| 39 | // Log before creating assistant with millisecond precision |
| 40 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); |
| 41 | long startTime = System.currentTimeMillis(); |
| 42 | System.out.println(sdf.format(new Date(startTime)) + |
| 43 | " - Starting assistant creation"); |
| 44 | Assistant assistant = assistants.create(param); |
| 45 | |
| 46 | // Log after creating assistant with duration |
| 47 | long endTime = System.currentTimeMillis(); |
| 48 | System.out.println(sdf.format(new Date(endTime)) + |
| 49 | " - Assistant creation completed, duration: " + |
| 50 | (endTime - startTime) + "ms"); |
| 51 | System.out.println(assistant); |
| 52 | |
| 53 | // sleep for 1 second |
| 54 | |
| 55 | // Log before creating assistant with millisecond precision |
| 56 | startTime = System.currentTimeMillis(); |
| 57 | System.out.println(sdf.format(new Date(startTime)) + |
| 58 | " - Starting assistant creation"); |
| 59 | |
| 60 | assistant = assistants.create(param); |
| 61 | |
| 62 | // Log after creating assistant with duration |
| 63 | endTime = System.currentTimeMillis(); |
| 64 | System.out.println(sdf.format(new Date(endTime)) + |
| 65 | " - Assistant creation completed, duration: " + |
| 66 | (endTime - startTime) + "ms"); |
| 67 | System.out.println(assistant); |
| 68 | |
| 69 | |
| 70 | // update assistant parameters |
| 71 | // param = AssistantParam.builder() |
| 72 | // // 此处以qwen-max为例,可按需更换模型名称。模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models |
| 73 | // .model("qwen-plus") |
| 74 | // .name("intelligent guide") |
| 75 | // .description("a smart guide") |
| 76 | // .instructions("You are a helpful assistant.") |
| 77 | // .topP(0.7) |
| 78 | // .topK(9) |
| 79 | // .temperature(0.7) |
| 80 | // .maxTokens(1024) |
nothing calls this directly
no outgoing calls
no test coverage detected