Refactor QianFan model option builder methods

- Deprecate the builder methods with the prefix `with` and add the new methods
 - Update docs and references
This commit is contained in:
Ilayaperumal Gopinathan
2024-12-17 01:38:04 +00:00
committed by Mark Pollack
parent 071b897951
commit 18bc0cff25
16 changed files with 205 additions and 59 deletions

View File

@@ -124,8 +124,8 @@ ChatResponse response = chatClient.call(
new Prompt(
"Generate the names of 5 famous pirates.",
QianFanChatOptions.builder()
.withModel(QianFanApi.ChatModel.ERNIE_Speed_8K.getValue())
.withTemperature(0.5)
.model(QianFanApi.ChatModel.ERNIE_Speed_8K.getValue())
.temperature(0.5)
.build()
));
----
@@ -208,9 +208,9 @@ Next, create a `QianFanChatModel` and use it for text generations:
var qianFanApi = new QianFanApi(System.getenv("QIANFAN_API_KEY"), System.getenv("QIANFAN_SECRET_KEY"));
var chatClient = new QianFanChatModel(this.qianFanApi, QianFanChatOptions.builder()
.withModel(QianFanApi.ChatModel.ERNIE_Speed_8K.getValue())
.withTemperature(0.4)
.withMaxTokens(200)
.model(QianFanApi.ChatModel.ERNIE_Speed_8K.getValue())
.temperature(0.4)
.maxTokens(200)
.build());
ChatResponse response = this.chatClient.call(

View File

@@ -120,7 +120,7 @@ For example to override the default model name for a specific request:
EmbeddingResponse embeddingResponse = embeddingClient.call(
new EmbeddingRequest(List.of("Hello World", "World is big and salvation is near"),
QianFanEmbeddingOptions.builder()
.withModel("Different-Embedding-Model-Deployment-Name")
.model("Different-Embedding-Model-Deployment-Name")
.build()));
----
@@ -188,10 +188,9 @@ Next, create an `QianFanEmbeddingModel` instance and use it to compute the simil
----
var qianFanApi = new QianFanApi(System.getenv("MINIMAX_API_KEY"), System.getenv("QIANFAN_SECRET_KEY"));
var embeddingClient = new QianFanEmbeddingModel(qianFanApi)
.withDefaultOptions(QianFanChatOptions.build()
.withModel("bge_large_en")
.build());
var embeddingClient = new QianFanEmbeddingModel(api, MetadataMode.EMBED, QianFanEmbeddingOptions.builder()
.model("bge_large_en")
.build());
EmbeddingResponse embeddingResponse = this.embeddingClient
.embedForResponse(List.of("Hello World", "World is big and salvation is near"));

View File

@@ -110,9 +110,9 @@ For example to override the QianFan specific options such as quality and the num
ImageResponse response = qianFanImageModel.call(
new ImagePrompt("A light cream colored mini golden doodle",
QianFanImageOptions.builder()
.withN(4)
.withHeight(1024)
.withWidth(1024).build())
.N(4)
.height(1024)
.width(1024).build())
);
----