mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-07-30 19:22:58 +08:00
fix zhipu issue
This commit is contained in:
@ -58,8 +58,8 @@ public class ZhipuChatAIClient {
|
|||||||
|
|
||||||
public static void refresh() {
|
public static void refresh() {
|
||||||
String apiKey = "";
|
String apiKey = "";
|
||||||
String apiHost = "";
|
String apiHost = "https://open.bigmodel.cn/api/paas/v3/model-api/";
|
||||||
String model = "";
|
String model = "chatglm_turbo";
|
||||||
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
|
ConfigService configService = ApplicationContextUtil.getBean(ConfigService.class);
|
||||||
Config apiHostConfig = configService.find(ZHIPU_HOST).getData();
|
Config apiHostConfig = configService.find(ZHIPU_HOST).getData();
|
||||||
if (apiHostConfig != null && StringUtils.isNotBlank(apiHostConfig.getContent())) {
|
if (apiHostConfig != null && StringUtils.isNotBlank(apiHostConfig.getContent())) {
|
||||||
|
@ -211,7 +211,7 @@ public class ZhipuChatAIStreamClient {
|
|||||||
.build();
|
.build();
|
||||||
//创建事件
|
//创建事件
|
||||||
EventSource eventSource = factory.newEventSource(request, eventSourceListener);
|
EventSource eventSource = factory.newEventSource(request, eventSourceListener);
|
||||||
log.info("finish invoking fast chat ai");
|
log.info("finish invoking zhipu chat ai");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("fast chat ai error", e);
|
log.error("fast chat ai error", e);
|
||||||
eventSourceListener.onFailure(null, e, null);
|
eventSourceListener.onFailure(null, e, null);
|
||||||
|
@ -60,12 +60,14 @@ public class ZhipuChatAIEventSourceListener extends EventSourceListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ZhipuChatCompletions chatCompletions = mapper.readValue(data, ZhipuChatCompletions.class);
|
ZhipuChatCompletions chatCompletions = mapper.readValue(data, ZhipuChatCompletions.class);
|
||||||
String text = "";
|
String text = chatCompletions.getData();
|
||||||
|
if (Objects.isNull(text)) {
|
||||||
for (FastChatMessage message : chatCompletions.getBody().getChoices()) {
|
for (FastChatMessage message : chatCompletions.getBody().getChoices()) {
|
||||||
if (message != null && message.getContent() != null) {
|
if (message != null && message.getContent() != null) {
|
||||||
text = message.getContent();
|
text = message.getContent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Message message = new Message();
|
Message message = new Message();
|
||||||
message.setContent(text);
|
message.setContent(text);
|
||||||
|
@ -14,6 +14,8 @@ public class ZhipuChatCompletions {
|
|||||||
|
|
||||||
private int statusCode;
|
private int statusCode;
|
||||||
|
|
||||||
|
private String data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The collection of completions choices associated with this completions response.
|
* The collection of completions choices associated with this completions response.
|
||||||
* Generally, `n` choices are generated per provided prompt with a default value of 1.
|
* Generally, `n` choices are generated per provided prompt with a default value of 1.
|
||||||
|
@ -16,10 +16,6 @@ import java.util.List;
|
|||||||
@Data
|
@Data
|
||||||
public final class ZhipuChatCompletionsOptions {
|
public final class ZhipuChatCompletionsOptions {
|
||||||
|
|
||||||
// path variables
|
|
||||||
@JsonProperty(value = "")
|
|
||||||
private String invokeMethod = "sse-invoke";
|
|
||||||
|
|
||||||
@JsonProperty(value = "request_id")
|
@JsonProperty(value = "request_id")
|
||||||
private String requestId;
|
private String requestId;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user