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

Method main

samples/TextReRankTest.java:17–48  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

15 private static final String MODEL_NAME = System.getenv("MODEL_NAME");
16
17 public static void main(String[] args) {
18 try {
19 // Create TextReRank instance
20 TextReRank textReRank = new TextReRank();
21
22 // Create parameters
23 TextReRankParam param = TextReRankParam.builder()
24 .model(MODEL_NAME)
25 .query("什么是文本排序模型")
26 .documents(Arrays.asList(
27 "文本排序模型广泛用于搜索引擎和推荐系统中,它们根据文本相关性对候选文本进行排序",
28 "量子计算是计算科学的一个前沿领域",
29 "预训练语言模型的发展给文本排序模型带来了新的进展"
30 ))
31 .topN(10)
32 .returnDocuments(true)
33 .instruct("Retrieval document that can answer users query.")
34 .build();
35
36 // Call the API
37 TextReRankResult result = textReRank.call(param);
38
39 System.out.println("Rerank Result:");
40 System.out.println(JsonUtils.toJson(result));
41 } catch (NoApiKeyException e) {
42 System.err.println("API key not found: " + e.getMessage());
43 } catch (ApiException e) {
44 System.err.println("API call failed: " + e.getMessage());
45 } catch (InputRequiredException e) {
46 throw new RuntimeException(e);
47 }
48 }
49}

Callers

nothing calls this directly

Calls 6

callMethod · 0.95
toJsonMethod · 0.95
builderMethod · 0.80
getMessageMethod · 0.80
buildMethod · 0.65
modelMethod · 0.45

Tested by

no test coverage detected