🎨 兼容无返回值情况
This commit is contained in:
parent
c493412066
commit
29fe0d2343
6
pom.xml
6
pom.xml
@ -328,7 +328,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.theokanning.openai-gpt3-java</groupId>
|
<groupId>com.theokanning.openai-gpt3-java</groupId>
|
||||||
<artifactId>client</artifactId>
|
<artifactId>client</artifactId>
|
||||||
<version>0.14.0</version>
|
<version>0.15.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.squareup.retrofit2</groupId>
|
<groupId>com.squareup.retrofit2</groupId>
|
||||||
@ -439,7 +439,7 @@
|
|||||||
<profileActive>dev</profileActive>
|
<profileActive>dev</profileActive>
|
||||||
</properties>
|
</properties>
|
||||||
<activation>
|
<activation>
|
||||||
<activeByDefault>true</activeByDefault>
|
<activeByDefault>false</activeByDefault>
|
||||||
</activation>
|
</activation>
|
||||||
</profile>
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
@ -448,7 +448,7 @@
|
|||||||
<profileActive>prod</profileActive>
|
<profileActive>prod</profileActive>
|
||||||
</properties>
|
</properties>
|
||||||
<activation>
|
<activation>
|
||||||
<activeByDefault>false</activeByDefault>
|
<activeByDefault>true</activeByDefault>
|
||||||
</activation>
|
</activation>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
@ -86,6 +86,9 @@ public class OpenAiController {
|
|||||||
.build();
|
.build();
|
||||||
service.streamChatCompletion(completionRequest).doOnError(Throwable::printStackTrace)
|
service.streamChatCompletion(completionRequest).doOnError(Throwable::printStackTrace)
|
||||||
.blockingForEach(chunk -> {
|
.blockingForEach(chunk -> {
|
||||||
|
if (chunk.getChoices().isEmpty() || chunk.getChoices().get(0).getMessage() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
String text = chunk.getChoices().get(0).getMessage().getContent();
|
String text = chunk.getChoices().get(0).getMessage().getContent();
|
||||||
if (text == null) {
|
if (text == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user