File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
models/spring-ai-zhipuai/src
main/java/org/springframework/ai/zhipuai/api
test/java/org/springframework/ai/zhipuai/embedding Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -299,7 +299,11 @@ public enum EmbeddingModel {
299299 /**
300300 * DIMENSION: 1024
301301 */
302- Embedding_2 ("Embedding-2" );
302+ Embedding_2 ("Embedding-2" ),
303+ /**
304+ * DIMENSION: 2048
305+ */
306+ Embedding_3 ("Embedding-3" );
303307
304308 public final String value ;
305309
Original file line number Diff line number Diff line change 2121import org .junit .jupiter .api .Test ;
2222import org .junit .jupiter .api .condition .EnabledIfEnvironmentVariable ;
2323
24+ import org .springframework .ai .embedding .EmbeddingRequest ;
2425import org .springframework .ai .embedding .EmbeddingResponse ;
2526import org .springframework .ai .zhipuai .ZhiPuAiEmbeddingModel ;
27+ import org .springframework .ai .zhipuai .ZhiPuAiEmbeddingOptions ;
2628import org .springframework .ai .zhipuai .ZhiPuAiTestConfiguration ;
29+ import org .springframework .ai .zhipuai .api .ZhiPuAiApi ;
2730import org .springframework .beans .factory .annotation .Autowired ;
2831import org .springframework .boot .test .context .SpringBootTest ;
2932
@@ -53,6 +56,25 @@ void defaultEmbedding() {
5356 assertThat (this .embeddingModel .dimensions ()).isEqualTo (1024 );
5457 }
5558
59+ @ Test
60+ void embedding3 () {
61+ assertThat (this .embeddingModel ).isNotNull ();
62+
63+ var options = ZhiPuAiEmbeddingOptions .builder ()
64+ .withModel (ZhiPuAiApi .EmbeddingModel .Embedding_3 .getValue ())
65+ .build ();
66+
67+ EmbeddingRequest embeddingRequest = new EmbeddingRequest (List .of ("Here comes the sun" ), options );
68+ EmbeddingResponse embeddingResponse = this .embeddingModel .call (embeddingRequest );
69+
70+ assertThat (embeddingResponse .getResults ()).hasSize (1 );
71+
72+ assertThat (embeddingResponse .getResults ().get (0 )).isNotNull ();
73+ assertThat (embeddingResponse .getResults ().get (0 ).getOutput ()).hasSize (2048 );
74+
75+ // assertThat(this.embeddingModel.dimensions()).isEqualTo(2048);
76+ }
77+
5678 @ Test
5779 void batchEmbedding () {
5880 assertThat (this .embeddingModel ).isNotNull ();
You can’t perform that action at this time.
0 commit comments