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

Method main

examples/legacy_2x/TextReRankTest.java:16–48  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

14 private static final String MODEL_NAME = System.getenv("MODEL_NAME");
15
16 public static void main(String[] args) {
17 try {
18 // Create TextReRank instance
19 TextReRank textReRank = new TextReRank();
20
21 // Create parameters
22 TextReRankParam param =
23 TextReRankParam.builder()
24 .model(MODEL_NAME)
25 .query("什么是文本排序模型")
26 .documents(
27 Arrays.asList(
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 11

callMethod · 0.95
toJsonMethod · 0.95
instructMethod · 0.80
returnDocumentsMethod · 0.80
topNMethod · 0.80
documentsMethod · 0.80
buildMethod · 0.65
queryMethod · 0.45
modelMethod · 0.45
builderMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected