Skip to content

Commit

Permalink
更改包命名
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobiichi-Origami committed Nov 28, 2024
1 parent 49ba26d commit d009b8a
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
16 changes: 8 additions & 8 deletions java/src/main/java/com/baidubce/qianfan/QianfanV2.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.baidubce.qianfan.core.StreamIterator;
import com.baidubce.qianfan.core.auth.Auth;
import com.baidubce.qianfan.core.builder.ChatV2Builder;
import com.baidubce.qianfan.model.chat.v2.request.V2Request;
import com.baidubce.qianfan.model.chat.v2.response.V2Response;
import com.baidubce.qianfan.model.chat.v2.response.V2StreamResponse;
import com.baidubce.qianfan.model.chat.v2.request.RequestV2;
import com.baidubce.qianfan.model.chat.v2.response.ResponseV2;
import com.baidubce.qianfan.model.chat.v2.response.StreamResponseV2;

public class QianfanV2 extends QianfanBase {

Expand All @@ -17,20 +17,20 @@ public QianfanV2(String accessKey, String secretKey) {
this.client = new QianfanClient(Auth.TYPE_V2, accessKey, secretKey);
}

public QianfanV2(QianfanClient client) {
QianfanV2(QianfanClient client) {
this.client = client;
}

public ChatV2Builder chatCompletion() {
return new ChatV2Builder(this);
}

public V2Response chatCompletion(V2Request request) {
return request(request, V2Response.class);
public ResponseV2 chatCompletion(RequestV2 request) {
return request(request, ResponseV2.class);
}

public StreamIterator<V2StreamResponse> chatCompletionStream(V2Request request) {
public StreamIterator<StreamResponseV2> chatCompletionStream(RequestV2 request) {
request.setStream(true);
return requestStream(request, V2StreamResponse.class);
return requestStream(request, StreamResponseV2.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import com.baidubce.qianfan.QianfanV2;
import com.baidubce.qianfan.model.chat.v2.*;
import com.baidubce.qianfan.model.chat.v2.request.V2Request;
import com.baidubce.qianfan.model.chat.v2.request.RequestV2;
import com.baidubce.qianfan.model.chat.v2.request.Tool;
import com.baidubce.qianfan.model.chat.v2.request.ToolResult;
import com.baidubce.qianfan.model.chat.v2.response.V2Response;
import com.baidubce.qianfan.model.chat.v2.response.ResponseV2;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -164,9 +164,9 @@ public ChatV2Builder appId(String appId) {
return this;
}

public V2Request build() {
public RequestV2 build() {
List<Message> messages = messageBuilder.build();
return new V2Request()
return new RequestV2()
.setModel(getModel())
.setMessages(messages)
.setAppId(appId)
Expand All @@ -185,7 +185,7 @@ public V2Request build() {
.setParallelToolCalls(parallelToolCalls);
}

public V2Response execute() {
public ResponseV2 execute() {
return super.getQianfanV2().chatCompletion(build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.baidubce.qianfan.model.chat.v2.Message;
import com.baidubce.qianfan.model.chat.v2.ToolCall;
import com.baidubce.qianfan.model.chat.v2.request.ToolResult;
import com.baidubce.qianfan.model.constant.V2.ChatRole;
import com.baidubce.qianfan.model.constant.v2.ChatRole;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.Map;

public class V2Request extends BaseRequest<V2Request> {
public class RequestV2 extends BaseRequest<RequestV2> {
private List<Message> messages;

private String appId;
Expand Down Expand Up @@ -49,7 +49,7 @@ public List<Message> getMessages() {
return messages;
}

public V2Request setMessages(List<Message> messages) {
public RequestV2 setMessages(List<Message> messages) {
this.messages = messages;
return this;
}
Expand All @@ -58,7 +58,7 @@ public String getAppId() {
return appId;
}

public V2Request setAppId(String appId) {
public RequestV2 setAppId(String appId) {
this.appId = appId;
if (appId != null) {
this.getHeaders().put("appid", appId);
Expand All @@ -70,7 +70,7 @@ public boolean isStream() {
return stream;
}

public V2Request setStream(boolean stream) {
public RequestV2 setStream(boolean stream) {
this.stream = stream;
return this;
}
Expand All @@ -79,7 +79,7 @@ public Map<String, Object> getStreamOptions() {
return streamOptions;
}

public V2Request setStreamOptions(Map<String, Object> streamOptions) {
public RequestV2 setStreamOptions(Map<String, Object> streamOptions) {
this.streamOptions = streamOptions;
return this;
}
Expand All @@ -88,7 +88,7 @@ public Double getTemperature() {
return temperature;
}

public V2Request setTemperature(Double temperature) {
public RequestV2 setTemperature(Double temperature) {
this.temperature = temperature;
return this;
}
Expand All @@ -97,7 +97,7 @@ public Double getTopP() {
return topP;
}

public V2Request setTopP(Double topP) {
public RequestV2 setTopP(Double topP) {
this.topP = topP;
return this;
}
Expand All @@ -106,7 +106,7 @@ public Double getPenaltyScore() {
return penaltyScore;
}

public V2Request setPenaltyScore(Double penaltyScore) {
public RequestV2 setPenaltyScore(Double penaltyScore) {
this.penaltyScore = penaltyScore;
return this;
}
Expand All @@ -115,7 +115,7 @@ public Integer getMaxCompletionTokens() {
return maxCompletionTokens;
}

public V2Request setMaxCompletionTokens(Integer maxCompletionTokens) {
public RequestV2 setMaxCompletionTokens(Integer maxCompletionTokens) {
this.maxCompletionTokens = maxCompletionTokens;
return this;
}
Expand All @@ -124,7 +124,7 @@ public Integer getSeed() {
return seed;
}

public V2Request setSeed(Integer seed) {
public RequestV2 setSeed(Integer seed) {
this.seed = seed;
return this;
}
Expand All @@ -133,7 +133,7 @@ public List<String> getStop() {
return stop;
}

public V2Request setStop(List<String> stop) {
public RequestV2 setStop(List<String> stop) {
this.stop = stop;
return this;
}
Expand All @@ -142,7 +142,7 @@ public String getUser() {
return user;
}

public V2Request setUser(String user) {
public RequestV2 setUser(String user) {
this.user = user;
return this;
}
Expand All @@ -151,7 +151,7 @@ public Double getFrequencyPenalty() {
return frequencyPenalty;
}

public V2Request setFrequencyPenalty(Double frequencyPenalty) {
public RequestV2 setFrequencyPenalty(Double frequencyPenalty) {
this.frequencyPenalty = frequencyPenalty;
return this;
}
Expand All @@ -160,7 +160,7 @@ public Double getPresencePenalty() {
return presencePenalty;
}

public V2Request setPresencePenalty(Double presencePenalty) {
public RequestV2 setPresencePenalty(Double presencePenalty) {
this.presencePenalty = presencePenalty;
return this;
}
Expand All @@ -169,7 +169,7 @@ public List<Tool> getTools() {
return tools;
}

public V2Request setTools(List<Tool> tools) {
public RequestV2 setTools(List<Tool> tools) {
this.tools = tools;
return this;
}
Expand All @@ -178,7 +178,7 @@ public Object getToolChoice() {
return toolChoice;
}

public V2Request setToolChoice(Object toolChoice) {
public RequestV2 setToolChoice(Object toolChoice) {
this.toolChoice = toolChoice;
return this;
}
Expand All @@ -187,7 +187,7 @@ public Boolean getParallelToolCalls() {
return parallelToolCalls;
}

public V2Request setParallelToolCalls(Boolean parallelToolCalls) {
public RequestV2 setParallelToolCalls(Boolean parallelToolCalls) {
this.parallelToolCalls = parallelToolCalls;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.baidubce.qianfan.model.BaseResponse;
import com.baidubce.qianfan.model.chat.ChatUsage;

public abstract class V2BaseResponse<T extends V2BaseResponse<T>> extends BaseResponse<T> {
public abstract class BaseResponseV2<T extends BaseResponseV2<T>> extends BaseResponse<T> {
private String model;

private ChatUsage usage;
Expand All @@ -12,7 +12,7 @@ public String getModel() {
return model;
}

public V2BaseResponse<T> setModel(String model) {
public BaseResponseV2<T> setModel(String model) {
this.model = model;
return this;
}
Expand All @@ -21,7 +21,7 @@ public ChatUsage getUsage() {
return usage;
}

public V2BaseResponse<T> setUsage(ChatUsage usage) {
public BaseResponseV2<T> setUsage(ChatUsage usage) {
this.usage = usage;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.List;

public class V2Response extends V2BaseResponse<V2Response> {
public class ResponseV2 extends BaseResponseV2<ResponseV2> {
private List<Choice> choices;

public List<Choice> getChoices() {
return this.choices;
}

public V2Response setChoices(List<Choice> choices) {
public ResponseV2 setChoices(List<Choice> choices) {
this.choices = choices;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import java.util.List;

public class V2StreamResponse extends V2BaseResponse<V2StreamResponse> {
public class StreamResponseV2 extends BaseResponseV2<StreamResponseV2> {
private List<StreamChoice> choices;

public List<StreamChoice> getChoices() {
return choices;
}

public V2StreamResponse setChoices(List<StreamChoice> choices) {
public StreamResponseV2 setChoices(List<StreamChoice> choices) {
this.choices = choices;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.baidubce.qianfan.model.constant.V2;
package com.baidubce.qianfan.model.constant.v2;

public class ChatRole {
public static final String USER = "user";
Expand Down

0 comments on commit d009b8a

Please sign in to comment.