Skip to content
Merged
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 @@ -25,7 +25,7 @@ class EmbeddingServiceTest {
embeddingService.create(
EmbeddingCreateParams.builder()
.input("The quick brown fox jumped over the lazy dog")
.model(EmbeddingModel.TEXT_EMBEDDING_ADA_002)
.model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)
.dimensions(1L)
.encodingFormat(EmbeddingCreateParams.EncodingFormat.FLOAT)
.user("user-1234")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.openai.example;

import com.openai.client.OpenAIClientAsync;
import com.openai.client.okhttp.OpenAIOkHttpClientAsync;
import com.openai.models.EmbeddingCreateParams;
import com.openai.models.EmbeddingModel;

public final class EmbeddingsAsyncExample {
private EmbeddingsAsyncExample() {}

public static void main(String[] args) {
// Configures using one of:
// - The `OPENAI_API_KEY` environment variable
// - The `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_KEY` environment variables
OpenAIClientAsync client = OpenAIOkHttpClientAsync.fromEnv();

EmbeddingCreateParams createParams = EmbeddingCreateParams.builder()
.input("The quick brown fox jumped over the lazy dog")
.model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)
.build();

client.embeddings().create(createParams).thenAccept(System.out::println).join();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.EmbeddingCreateParams;
import com.openai.models.EmbeddingModel;

public final class EmbeddingsExample {
private EmbeddingsExample() {}

public static void main(String[] args) {
// Configures using one of:
// - The `OPENAI_API_KEY` environment variable
// - The `AZURE_OPENAI_ENDPOINT` and `AZURE_OPENAI_KEY` environment variables
OpenAIClient client = OpenAIOkHttpClient.fromEnv();

EmbeddingCreateParams createParams = EmbeddingCreateParams.builder()
.input("The quick brown fox jumped over the lazy dog")
.model(EmbeddingModel.TEXT_EMBEDDING_3_SMALL)
.build();

System.out.println(client.embeddings().create(createParams));
}
}