fix zhipu issue

This commit is contained in:
robin
2023-11-01 14:54:22 +08:00
parent 9e9e99b39b
commit f3b45f0505
5 changed files with 11 additions and 11 deletions

View File

@ -58,8 +58,8 @@ public class ZhipuChatAIClient {
public static void refresh() {
String apiKey = "";
String apiHost = "";
String model = "";
String apiHost = "https://open.bigmodel.cn/api/paas/v3/model-api/";
String model = "chatglm_turbo";
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
Config apiHostConfig = configService.find(ZHIPU_HOST).getData();
if (apiHostConfig != null && StringUtils.isNotBlank(apiHostConfig.getContent())) {

View File

@ -211,7 +211,7 @@ public class ZhipuChatAIStreamClient {
.build();
//创建事件
EventSource eventSource = factory.newEventSource(request, eventSourceListener);
log.info("finish invoking fast chat ai");
log.info("finish invoking zhipu chat ai");
} catch (Exception e) {
log.error("fast chat ai error", e);
eventSourceListener.onFailure(null, e, null);

View File

@ -60,10 +60,12 @@ public class ZhipuChatAIEventSourceListener extends EventSourceListener {
}
ZhipuChatCompletions chatCompletions = mapper.readValue(data, ZhipuChatCompletions.class);
String text = "";
for (FastChatMessage message : chatCompletions.getBody().getChoices()) {
if (message != null && message.getContent() != null) {
text = message.getContent();
String text = chatCompletions.getData();
if (Objects.isNull(text)) {
for (FastChatMessage message : chatCompletions.getBody().getChoices()) {
if (message != null && message.getContent() != null) {
text = message.getContent();
}
}
}

View File

@ -14,6 +14,8 @@ public class ZhipuChatCompletions {
private int statusCode;
private String data;
/*
* The collection of completions choices associated with this completions response.
* Generally, `n` choices are generated per provided prompt with a default value of 1.

View File

@ -16,10 +16,6 @@ import java.util.List;
@Data
public final class ZhipuChatCompletionsOptions {
// path variables
@JsonProperty(value = "")
private String invokeMethod = "sse-invoke";
@JsonProperty(value = "request_id")
private String requestId;