Class SpringAICozeService
java.lang.Object
com.bytedesk.ai.service.BaseSpringAIService
com.bytedesk.ai.springai.providers.coze.SpringAICozeService
- All Implemented Interfaces:
SpringAIService
Coze AI服务类
使用 Coze OpenAPI SDK 实现聊天功能,继承自BaseSpringAIService
https://www.coze.cn/open/docs/developer_guides
github
https://github.com/coze-dev/coze-java
Coze Java SDK示例
https://github.com/coze-dev/coze-java/blob/main/example/src/main/java/example/chat/StreamChatExample.java
-
Field Summary
FieldsFields inherited from class com.bytedesk.ai.service.BaseSpringAIService
applicationEventPublisher, chunkElasticService, chunkVectorService, faqElasticService, faqVectorService, knowledgeBaseSearchHelper, messagePersistCache, messagePersistenceHelper, messageRestService, messageSendService, promptHelper, robotMessageCache, robotRestService, sseMessageHelper, textElasticService, textVectorService, threadRestService, uidUtils, webpageElasticService, webpageVectorService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate com.coze.openapi.client.chat.CreateChatReqcreateChatRequest(RobotLlm llm, LlmProviderEntity provider, String message, String userID) 根据机器人配置创建聊天请求private com.coze.openapi.service.service.CozeAPI根据机器人配置创建动态的CozeAPI实例private StringextractTextFromPrompt(org.springframework.ai.chat.prompt.Prompt prompt) 从Prompt中提取文本内容protected voidprocessPromptSse(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, List<RobotContent.SourceReference> sourceReferences, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) protected StringprocessPromptSync(String message, RobotProtobuf robot) protected voidprocessPromptWebsocket(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply) Methods inherited from class com.bytedesk.ai.service.BaseSpringAIService
processSyncRequest, sendSseMessage, sendSyncMessage, sendWebsocketMessage
-
Field Details
-
llmProviderRestService
-
tokenUsageHelper
-
-
Constructor Details
-
SpringAICozeService
public SpringAICozeService()
-
-
Method Details
-
createDynamicCozeApi
根据机器人配置创建动态的CozeAPI实例- Parameters:
llm- 机器人LLM配置- Returns:
- 配置了特定参数的CozeAPI
-
createChatRequest
private com.coze.openapi.client.chat.CreateChatReq createChatRequest(RobotLlm llm, LlmProviderEntity provider, String message, String userID) 根据机器人配置创建聊天请求 -
extractTextFromPrompt
从Prompt中提取文本内容 -
processPromptWebsocket
protected void processPromptWebsocket(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply) - Specified by:
processPromptWebsocketin classBaseSpringAIService
-
processPromptSync
- Specified by:
processPromptSyncin classBaseSpringAIService
-
processPromptSse
protected void processPromptSse(org.springframework.ai.chat.prompt.Prompt prompt, RobotProtobuf robot, MessageProtobuf messageProtobufQuery, MessageProtobuf messageProtobufReply, List<RobotContent.SourceReference> sourceReferences, org.springframework.web.servlet.mvc.method.annotation.SseEmitter emitter) - Specified by:
processPromptSsein classBaseSpringAIService
-