Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ public enum EmbeddingModel {
/**
* DIMENSION: 1024
*/
Embedding_2("Embedding-2");
Embedding_2("Embedding-2"),
/**
* DIMENSION: 2048
*/
Embedding_3("Embedding-3");

public final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

import org.springframework.ai.embedding.EmbeddingRequest;
import org.springframework.ai.embedding.EmbeddingResponse;
import org.springframework.ai.zhipuai.ZhiPuAiEmbeddingModel;
import org.springframework.ai.zhipuai.ZhiPuAiEmbeddingOptions;
import org.springframework.ai.zhipuai.ZhiPuAiTestConfiguration;
import org.springframework.ai.zhipuai.api.ZhiPuAiApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

Expand Down Expand Up @@ -53,6 +56,25 @@ void defaultEmbedding() {
assertThat(this.embeddingModel.dimensions()).isEqualTo(1024);
}

@Test
void embedding3() {
assertThat(this.embeddingModel).isNotNull();

var options = ZhiPuAiEmbeddingOptions.builder()
.withModel(ZhiPuAiApi.EmbeddingModel.Embedding_3.getValue())
.build();

EmbeddingRequest embeddingRequest = new EmbeddingRequest(List.of("Here comes the sun"), options);
EmbeddingResponse embeddingResponse = this.embeddingModel.call(embeddingRequest);

assertThat(embeddingResponse.getResults()).hasSize(1);

assertThat(embeddingResponse.getResults().get(0)).isNotNull();
assertThat(embeddingResponse.getResults().get(0).getOutput()).hasSize(2048);

// assertThat(this.embeddingModel.dimensions()).isEqualTo(2048);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good! It is weird that the embedding model dimensions is "-1". Do you know why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wb04307201 The ZhipuAiApi Embedding model is updated with Embedding-2 and Embedding-3. Since we haven't heard back on the test, I couldn't merge the PR earlier. Closing this PR for now. Please create a new PR with the updated test if you prefer. Thanks!

}

@Test
void batchEmbedding() {
assertThat(this.embeddingModel).isNotNull();
Expand Down