| 10 | |
| 11 | public final class TextEmbeddingUsage { |
| 12 | public static void basicCall() throws ApiException, NoApiKeyException{ |
| 13 | TextEmbeddingParam param = TextEmbeddingParam |
| 14 | .builder() |
| 15 | .model(TextEmbedding.Models.TEXT_EMBEDDING_V3) |
| 16 | .dimension(128) |
| 17 | .outputType(TextEmbeddingParam.OutputType.DENSE) |
| 18 | .instruct("Given a web search query, retrieve relevant passages that answer the query") |
| 19 | .texts(Arrays.asList("风急天高猿啸哀", "渚清沙白鸟飞回", "无边落木萧萧下", "不尽长江滚滚来")).build(); |
| 20 | TextEmbedding textEmbedding = new TextEmbedding(); |
| 21 | TextEmbeddingResult result = textEmbedding.call(param); |
| 22 | System.out.println(JsonUtils.gson.toJson(result)); |
| 23 | } |
| 24 | |
| 25 | public static void callWithCallback() throws ApiException, NoApiKeyException, InterruptedException{ |
| 26 | TextEmbeddingParam param = TextEmbeddingParam |