Package com.bytedesk.ai.zhipuai
Class ZhipuaiChatService
java.lang.Object
com.bytedesk.ai.zhipuai.ZhipuaiChatService
@Service
@ConditionalOnProperty(prefix="spring.ai.zhipuai.chat",
name="enabled",
havingValue="true",
matchIfMissing=false)
public class ZhipuaiChatService
extends Object
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription异步聊天chatWithVoice
(String message) 语音模型聊天 - 暂不支持,需要等待SDK更新chatWithWebSearch
(String message, String searchQuery) 带Web搜索的聊天createFineTuningJob
(String model, String trainingFile) 创建微调任务 - 暂不支持,需要等待SDK更新downloadFile
(String fileId, String outputPath) 下载文件内容 - 暂不支持,需要等待SDK更新functionCallingChat
(String message, String model, Double temperature, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) Function Calling 聊天(带自定义参数)functionCallingChat
(String message, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) Function Calling 聊天reactor.core.publisher.Flux<String>
functionCallingChatStream
(String message, String model, Double temperature, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) 流式 Function Calling 聊天(带自定义参数)reactor.core.publisher.Flux<String>
functionCallingChatStream
(String message, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) 流式 Function Calling 聊天generateCustomSpeech
(String text, String voiceText, File voiceData, String responseFormat) 自定义语音合成 - 暂不支持,需要等待SDK更新generateImage
(String prompt) 图像生成 - 暂不支持,需要等待SDK更新generateImage
(String prompt, String requestId) 图像生成(带请求ID)- 暂不支持,需要等待SDK更新generateSpeech
(String text, String voice, String responseFormat) 语音合成 - 暂不支持,需要等待SDK更新getEmbedding
(String text) 向量嵌入 - 暂不支持,需要等待SDK更新getEmbeddings
(List<String> texts) 批量向量嵌入 - 暂不支持,需要等待SDK更新private io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ChatMessageAccumulator>
mapStreamToAccumulator
(io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ModelData> flowable) 将流式响应转换为Accumulator,参考官方示例private String
pollAsyncResult
(String taskId) 轮询异步结果查询文件列表 - 暂不支持,需要等待SDK更新queryFineTuningJob
(String jobId) 查询微调任务 - 暂不支持,需要等待SDK更新角色扮演聊天void
测试流式响应功能 用于调试流式响应问题uploadFile
(String filePath, String purpose) 文件上传 - 暂不支持,需要等待SDK更新
-
Field Details
-
client
@Autowired @Qualifier("zhipuaiChatClient") private com.zhipu.oapi.ClientV4 client -
zhipuaiChatConfig
-
-
Constructor Details
-
ZhipuaiChatService
public ZhipuaiChatService()
-
-
Method Details
-
rolePlayChat
public String rolePlayChat(String message, String userInfo, String botInfo, String botName, String userName) 角色扮演聊天 -
functionCallingChat
public String functionCallingChat(String message, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) Function Calling 聊天 -
functionCallingChat
public String functionCallingChat(String message, String model, Double temperature, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) Function Calling 聊天(带自定义参数) -
functionCallingChatStream
public reactor.core.publisher.Flux<String> functionCallingChatStream(String message, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) 流式 Function Calling 聊天 -
functionCallingChatStream
public reactor.core.publisher.Flux<String> functionCallingChatStream(String message, String model, Double temperature, List<com.zhipu.oapi.service.v4.model.ChatFunction> functions) 流式 Function Calling 聊天(带自定义参数) -
generateImage
图像生成 - 暂不支持,需要等待SDK更新 -
generateImage
图像生成(带请求ID)- 暂不支持,需要等待SDK更新 -
getEmbedding
向量嵌入 - 暂不支持,需要等待SDK更新 -
getEmbeddings
批量向量嵌入 - 暂不支持,需要等待SDK更新 -
generateSpeech
语音合成 - 暂不支持,需要等待SDK更新 -
generateCustomSpeech
public File generateCustomSpeech(String text, String voiceText, File voiceData, String responseFormat) 自定义语音合成 - 暂不支持,需要等待SDK更新 -
uploadFile
文件上传 - 暂不支持,需要等待SDK更新 -
queryFiles
查询文件列表 - 暂不支持,需要等待SDK更新 -
downloadFile
下载文件内容 - 暂不支持,需要等待SDK更新 -
createFineTuningJob
创建微调任务 - 暂不支持,需要等待SDK更新 -
queryFineTuningJob
查询微调任务 - 暂不支持,需要等待SDK更新 -
chatAsync
异步聊天 -
pollAsyncResult
轮询异步结果 -
chatWithWebSearch
带Web搜索的聊天 -
chatWithVoice
语音模型聊天 - 暂不支持,需要等待SDK更新 -
mapStreamToAccumulator
private io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ChatMessageAccumulator> mapStreamToAccumulator(io.reactivex.Flowable<com.zhipu.oapi.service.v4.model.ModelData> flowable) 将流式响应转换为Accumulator,参考官方示例 -
testStreamResponse
public void testStreamResponse()测试流式响应功能 用于调试流式响应问题
-