Skip to content

Commit

Permalink
chore: bump version to 0.0.9 (#631)
Browse files Browse the repository at this point in the history
* chore: bump version to 0.0.9

* chore: bump version to 0.0.9
  • Loading branch information
Azure99 authored Jul 1, 2024
1 parent b88d2a0 commit ee9dc8d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
33 changes: 18 additions & 15 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

## 安装

> 使用千帆JavaSDK,需要Java版本>=8
> 使用千帆JavaSDK,需要Java版本>=8
### Maven

在pom.xml的dependencies中添加依赖
在pom.xml的dependencies中添加依赖

```xml
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
</dependency>
```

### Gradle

对于Kotlin DSL,在build.gradle.kts的dependencies中添加依赖
对于Kotlin DSL,在build.gradle.kts的dependencies中添加依赖

```kotlin
implementation("com.baidubce:qianfan:0.0.8")
implementation("com.baidubce:qianfan:0.0.9")
```

对于Groovy DSL,在build.gradle的dependencies中添加依赖
对于Groovy DSL,在build.gradle的dependencies中添加依赖

```groovy
implementation 'com.baidubce:qianfan:0.0.8'
implementation 'com.baidubce:qianfan:0.0.9'
```

> 我们提供了一些 [示例](./examples),可以帮助快速了解 SDK 的使用方法并完成常见功能。
Expand Down Expand Up @@ -60,7 +60,7 @@ export QIANFAN_AK=your_ak
export QIANFAN_SK=your_sk
```

也可以在代码中通过如下方式配置
也可以在代码中通过如下方式配置

```java
Qianfan qianfan = new Qianfan(Auth.TYPE_OAUTH, "your_ak", "your_sk");
Expand All @@ -82,7 +82,9 @@ ChatResponse response = new Qianfan().chatCompletion()
System.out.println(response.getResult());
```

也可以调用 `executeStream` 方法发起流式请求,会返回`Iterator<ChatResponse>`,即`ChatResponse`的迭代器,通过`hasNext`检查是否有新的消息片段,并通过`next`获取下一个消息片段。
也可以调用 `executeStream` 方法发起流式请求,会返回`StreamIterator<ChatResponse>`,即`ChatResponse`的迭代器,推荐使用`forEachRemaining`来迭代流式数据。

**注意**:在使用`hasNext`/`next`迭代数据时,如果希望提前停止迭代,**必须**显式调用`close`方法,否则可能导致**连接泄露**

示例如下:

Expand All @@ -107,15 +109,16 @@ CompletionResponse response = new Qianfan().completion()
System.out.println(response.getResult());
```

也可以调用 `executeStream` 方法实现流式返回
也可以调用 `executeStream` 方法实现流式返回

```java
Iterator<CompletionResponse> response = new Qianfan().completion()
try (StreamIterator<CompletionResponse> response = new Qianfan().completion()
.model("CodeLlama-7b-Instruct")
.prompt("hello")
.executeStream();
while (response.hasNext()) {
System.out.print(response.next().getResult());
.executeStream()) {
while (response.hasNext()) {
System.out.print(response.next().getResult());
}
}
```

Expand Down Expand Up @@ -193,4 +196,4 @@ PluginResponse response = new Qianfan().plugin()
.query("这个图片是什么")
.execute();
System.out.println(response.getResult());
```
```
2 changes: 1 addition & 1 deletion java/example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.0.7</version>
<version>0.0.9</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.baidubce</groupId>
<artifactId>qianfan</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
<packaging>jar</packaging>

<name>qianfan</name>
Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/com/baidubce/qianfan/QianfanClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.baidubce.qianfan.util.http.*;

class QianfanClient {
private static final String SDK_VERSION = "0.0.8";
private static final String SDK_VERSION = "0.0.9";
private static final String QIANFAN_URL_TEMPLATE = "%s/rpc/2.0/ai_custom/v1/wenxinworkshop%s";
private static final String EXTRA_PARAM_REQUEST_SOURCE = "request_source";
private static final String REQUEST_SOURCE_PREFIX = "qianfan_java_sdk_v";
Expand Down

0 comments on commit ee9dc8d

Please sign in to comment.