Class ZhipuaiChatService
java.lang.Object
com.bytedesk.ai.provider.vendors.zhipuai.ZhipuaiChatService
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean
@Service
@ConditionalOnProperty(name="spring.ai.zhipuai.chat.enabled",
havingValue="true")
public class ZhipuaiChatService
extends Object
implements org.springframework.beans.factory.DisposableBean
https://open.bigmodel.cn/dev/api#sdk_install
https://github.com/MetaGLM/zhipuai-sdk-java-v4
https://docs.spring.io/spring-ai/reference/api/chat/zhipuai-chat.html
https://open.bigmodel.cn/dev/api/normal-model/glm-4
https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-zhipuai/src/main/java/org/springframework/ai/zhipuai/api/ZhiPuAiApi.java
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IMessageSendService
private final MessageRestService
private final org.modelmapper.ModelMapper
private final String
private final String
private final String
private final SpringAIVectorService
private final SpringAIZhipuaiConfig
private final ThreadRestService
private final UidUtils
private final com.zhipu.oapi.ClientV4
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
generateFaqPairsAsync
(String chunk) void
generateFaqPairsSync
(String chunk) void
getSseAnswer
(String uid, String sid, String question, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) sse调用static io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ChatMessageAccumulator>
mapStreamToAccumulator
(io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ModelData> flowable) void
sendWsKbAutoReply
(String query, String kbUid, MessageProtobuf messageProtobuf) void
sendWsKbMessage
(String query, RobotEntity robot, MessageProtobuf messageProtobuf) void
sendWsMessage
(String query, RobotLlm robotLlm, MessageProtobuf messageProtobuf) websocket 发送消息 LLM 聊天
-
Field Details
-
springAiZhipuaiConfig
-
zhipuaiClient
private final com.zhipu.oapi.ClientV4 zhipuaiClient -
uidUtils
-
threadService
-
modelMapper
private final org.modelmapper.ModelMapper modelMapper -
messageService
-
springAIVectorService
-
messageSendService
-
PROMPT_BLUEPRINT
- See Also:
-
PROMPT_TEMPLATE
- See Also:
-
PROMPT_QA_TEMPLATE
- See Also:
-
-
Constructor Details
-
ZhipuaiChatService
public ZhipuaiChatService()
-
-
Method Details
-
sendWsKbMessage
-
sendWsKbAutoReply
-
generateFaqPairsAsync
-
generateFaqPairsSync
-
getSseAnswer
public void getSseAnswer(String uid, String sid, String question, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) sse调用 -
sendWsMessage
websocket 发送消息 LLM 聊天 -
mapStreamToAccumulator
public static io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ChatMessageAccumulator> mapStreamToAccumulator(io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ModelData> flowable) -
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-