-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2eaef05
commit 49ba26d
Showing
28 changed files
with
156 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.baidubce.qianfan; | ||
|
||
import com.baidubce.qianfan.core.StreamIterator; | ||
import com.baidubce.qianfan.model.BaseRequest; | ||
import com.baidubce.qianfan.model.BaseResponse; | ||
import com.baidubce.qianfan.model.console.ConsoleRequest; | ||
import com.baidubce.qianfan.model.console.ConsoleResponse; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
abstract public class QianfanBase { | ||
protected QianfanClient client; | ||
|
||
protected QianfanBase() {} | ||
|
||
public <T extends BaseResponse<T>, U extends BaseRequest<U>> T request(BaseRequest<U> request, Class<T> responseClass) { | ||
return client.request(request, responseClass); | ||
} | ||
|
||
public <T extends BaseResponse<T>, U extends BaseRequest<U>> StreamIterator<T> requestStream(BaseRequest<U> request, Class<T> responseClass) { | ||
return client.requestStream(request, responseClass); | ||
} | ||
|
||
public <T> ConsoleResponse<T> consoleRequest(ConsoleRequest request, Type type) { | ||
return client.consoleRequest(request, type); | ||
} | ||
|
||
public void setClient(QianfanClient client) { | ||
this.client = client; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.baidubce.qianfan; | ||
|
||
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; | ||
|
||
public class QianfanV2 extends QianfanBase { | ||
|
||
public QianfanV2() { | ||
this.client = new QianfanClient(); | ||
} | ||
|
||
public QianfanV2(String accessKey, String secretKey) { | ||
this.client = new QianfanClient(Auth.TYPE_V2, accessKey, secretKey); | ||
} | ||
|
||
public QianfanV2(QianfanClient client) { | ||
this.client = client; | ||
} | ||
|
||
public ChatV2Builder chatCompletion() { | ||
return new ChatV2Builder(this); | ||
} | ||
|
||
public V2Response chatCompletion(V2Request request) { | ||
return request(request, V2Response.class); | ||
} | ||
|
||
public StreamIterator<V2StreamResponse> chatCompletionStream(V2Request request) { | ||
request.setStream(true); | ||
return requestStream(request, V2StreamResponse.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
java/src/main/java/com/baidubce/qianfan/core/builder/MessageV2Builder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...idubce/qianfan/model/chat/V2/Message.java → ...idubce/qianfan/model/chat/v2/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...dubce/qianfan/model/chat/V2/ToolCall.java → ...dubce/qianfan/model/chat/v2/ToolCall.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...odel/chat/V2/other/BearTokenResponse.java → ...el/chat/v2/other/BearerTokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...anfan/model/chat/V2/request/Function.java → ...anfan/model/chat/v2/request/Function.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...e/qianfan/model/chat/V2/request/Tool.java → ...e/qianfan/model/chat/v2/request/Tool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...fan/model/chat/V2/request/ToolChoice.java → ...fan/model/chat/v2/request/ToolChoice.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...fan/model/chat/V2/request/ToolResult.java → ...fan/model/chat/v2/request/ToolResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.