修复问题
This commit is contained in:
@@ -26,7 +26,7 @@ public class DifyClient {
|
||||
private DifyProperties difyProperties;
|
||||
|
||||
/**
|
||||
* 调用 Dify 工作流流式 API
|
||||
* 调用 Dify 聊天流式 API
|
||||
*
|
||||
* @param apiKey Dify API Key
|
||||
* @param content 用户输入
|
||||
@@ -35,16 +35,17 @@ public class DifyClient {
|
||||
* @return 流式响应
|
||||
*/
|
||||
public Flux<DifyChatRespVO> chatStream(String apiKey, String content, String systemPrompt, String conversationId) {
|
||||
String apiUrl = difyProperties.getApiUrl() + "/v1/workflows/run";
|
||||
String apiUrl = difyProperties.getApiUrl() + "/v1/chat-messages";
|
||||
|
||||
// 构建请求体
|
||||
// 构建请求体 - 按照 Dify API 格式
|
||||
Map<String, Object> inputs = new HashMap<>();
|
||||
inputs.put("sysPrompt", systemPrompt);
|
||||
inputs.put("userInput", content);
|
||||
|
||||
Map<String, Object> requestBody = new HashMap<>();
|
||||
requestBody.put("inputs", inputs);
|
||||
requestBody.put("query", content);
|
||||
requestBody.put("response_mode", "streaming");
|
||||
requestBody.put("conversation_id", conversationId != null ? conversationId : "");
|
||||
requestBody.put("user", "user-" + System.currentTimeMillis());
|
||||
|
||||
AtomicReference<String> responseConversationId = new AtomicReference<>(conversationId);
|
||||
|
||||
Reference in New Issue
Block a user