Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature (ZhiPuAi): Support for Embedding-3 Model #1640

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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);
}

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