|
21 | 21 | import org.junit.jupiter.api.Test;
|
22 | 22 | import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
|
23 | 23 |
|
| 24 | +import org.springframework.ai.embedding.EmbeddingRequest; |
24 | 25 | import org.springframework.ai.embedding.EmbeddingResponse;
|
25 | 26 | import org.springframework.ai.zhipuai.ZhiPuAiEmbeddingModel;
|
| 27 | +import org.springframework.ai.zhipuai.ZhiPuAiEmbeddingOptions; |
26 | 28 | import org.springframework.ai.zhipuai.ZhiPuAiTestConfiguration;
|
| 29 | +import org.springframework.ai.zhipuai.api.ZhiPuAiApi; |
27 | 30 | import org.springframework.beans.factory.annotation.Autowired;
|
28 | 31 | import org.springframework.boot.test.context.SpringBootTest;
|
29 | 32 |
|
@@ -53,6 +56,31 @@ void defaultEmbedding() {
|
53 | 56 | assertThat(this.embeddingModel.dimensions()).isEqualTo(1024);
|
54 | 57 | }
|
55 | 58 |
|
| 59 | + @Test |
| 60 | + void embeddingV3WithDefault() { |
| 61 | + EmbeddingResponse embeddingResponse = this.embeddingModel.call(new EmbeddingRequest(List.of("Hello World"), |
| 62 | + ZhiPuAiEmbeddingOptions.builder().model(ZhiPuAiApi.EmbeddingModel.Embedding_3.getValue()).build())); |
| 63 | + |
| 64 | + assertThat(embeddingResponse.getResults()).hasSize(1); |
| 65 | + |
| 66 | + assertThat(embeddingResponse.getResults().get(0)).isNotNull(); |
| 67 | + assertThat(embeddingResponse.getResults().get(0).getOutput()).hasSize(2048); |
| 68 | + } |
| 69 | + |
| 70 | + @Test |
| 71 | + void embeddingV3WithCustomDimension() { |
| 72 | + EmbeddingResponse embeddingResponse = this.embeddingModel.call(new EmbeddingRequest(List.of("Hello World"), |
| 73 | + ZhiPuAiEmbeddingOptions.builder() |
| 74 | + .model(ZhiPuAiApi.EmbeddingModel.Embedding_3.getValue()) |
| 75 | + .dimensions(512) |
| 76 | + .build())); |
| 77 | + |
| 78 | + assertThat(embeddingResponse.getResults()).hasSize(1); |
| 79 | + |
| 80 | + assertThat(embeddingResponse.getResults().get(0)).isNotNull(); |
| 81 | + assertThat(embeddingResponse.getResults().get(0).getOutput()).hasSize(512); |
| 82 | + } |
| 83 | + |
56 | 84 | @Test
|
57 | 85 | void batchEmbedding() {
|
58 | 86 | assertThat(this.embeddingModel).isNotNull();
|
|
0 commit comments