Rag application call sample @throws NoApiKeyException Can not find api key @throws ApiException The request failed, possibly due to a network or data error. @throws InputRequiredException Missing inputs.
()
| 37 | * @throws InputRequiredException Missing inputs. |
| 38 | */ |
| 39 | public static void ragCall() |
| 40 | throws ApiException, NoApiKeyException, InputRequiredException { |
| 41 | ApplicationParam param = ApplicationParam.builder() |
| 42 | .appId(APP_ID) |
| 43 | .prompt("API接口说明中, TopP参数改如何传递?") |
| 44 | .topP(0.2) |
| 45 | .build(); |
| 46 | |
| 47 | Application application = new Application(); |
| 48 | ApplicationResult result = application.call(param); |
| 49 | |
| 50 | System.out.printf("requestId: %s, text: %s, finishReason: %s\n", |
| 51 | result.getRequestId(), result.getOutput().getText(), result.getOutput().getFinishReason()); |
| 52 | |
| 53 | if (result.getUsage() != null && result.getUsage().getModels() != null) { |
| 54 | for (ApplicationUsage.ModelUsage usage : result.getUsage().getModels()) { |
| 55 | System.out.printf("modelId: %s, inputTokens: %d, outputTokens: %d\n", |
| 56 | usage.getModelId(), usage.getInputTokens(), usage.getOutputTokens()); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Rag application call with tags sample |