mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-03 15:06:11 +00:00
chore: 删除ruoyi-modules-api模块
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
package org.ruoyi.system.utils;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.MultipartBody;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.ruoyi.common.core.utils.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.rmi.ServerException;
|
||||
|
||||
/***
|
||||
* 千问上传文件工具类
|
||||
*/
|
||||
public class QwenFileUploadUtils {
|
||||
|
||||
// 上传本地文件
|
||||
public static String uploadFile(File file, String apiHost, String apiKey) throws IOException {
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
|
||||
// 构建 multipart/form-data 请求体(千问要求的格式)
|
||||
RequestBody requestBody = new MultipartBody.Builder()
|
||||
.setType(MultipartBody.FORM)
|
||||
.addFormDataPart("file", file.getName(), // 参数名必须为 file
|
||||
RequestBody.create(MediaType.parse("application/octet-stream"), file))
|
||||
.addFormDataPart("purpose", "file-extract") // 必须为 file-extract,文档解析专用
|
||||
.build();
|
||||
|
||||
// 构建请求(必须为 POST 方法)
|
||||
Request request = new Request.Builder()
|
||||
.url(apiHost)
|
||||
.post(requestBody)
|
||||
.addHeader("Authorization", apiKey) // 认证头格式正确
|
||||
.build();
|
||||
|
||||
// 发送请求并解析 fileId
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (!response.isSuccessful()) {
|
||||
throw new ServerException("上传失败:" + response.code() + " " + response.message());
|
||||
}
|
||||
// 解析响应体,获取 fileId
|
||||
String responseBody = response.body().string();
|
||||
if (StringUtils.isEmpty(responseBody)){
|
||||
throw new ServerException("上传失败:响应体为空");
|
||||
}
|
||||
JSONObject jsonObject = JSONObject.parseObject(responseBody);
|
||||
return jsonObject.getString("id"); // 千问返回的 fileId
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package org.ruoyi.workflow.workflow.node.humanFeedBack;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.ruoyi.workflow.entity.WorkflowComponent;
|
||||
import org.ruoyi.workflow.entity.WorkflowNode;
|
||||
import org.ruoyi.workflow.workflow.NodeProcessResult;
|
||||
import org.ruoyi.workflow.workflow.WfNodeState;
|
||||
import org.ruoyi.workflow.workflow.WfState;
|
||||
import org.ruoyi.workflow.workflow.data.NodeIOData;
|
||||
import org.ruoyi.workflow.workflow.node.AbstractWfNode;
|
||||
|
||||
import static org.ruoyi.workflow.cosntant.AdiConstant.WorkflowConstant.*;
|
||||
|
||||
/**
|
||||
* 人机交互节点实现类
|
||||
*/
|
||||
@Slf4j
|
||||
public class HumanFeedbackNode extends AbstractWfNode {
|
||||
|
||||
public HumanFeedbackNode(WorkflowComponent component, WorkflowNode nodeDefinition, WfState wfState, WfNodeState nodeState) {
|
||||
super(component, nodeDefinition, wfState, nodeState);
|
||||
}
|
||||
|
||||
// 人机交互节点的处理逻辑
|
||||
@Override
|
||||
public NodeProcessResult onProcess() {
|
||||
log.info("Processing HumanFeedback node: {}", node.getTitle());
|
||||
// 从状态中获取用户输入数据
|
||||
Object humanFeedbackState = state.data().get(HUMAN_FEEDBACK_KEY);
|
||||
if (null != humanFeedbackState) {
|
||||
String userInput = humanFeedbackState.toString();
|
||||
if (StringUtils.isNotBlank(userInput)) {
|
||||
// 用户已提供输入,将用户输入添加到节点输入和输出中
|
||||
NodeIOData feedbackData = NodeIOData.createByText("output", "default", userInput);
|
||||
// 添加到输入列表,这样当前节点处理时可以使用
|
||||
state.getInputs().add(feedbackData);
|
||||
// 添加到输出列表,这样后续节点可以使用
|
||||
state.getOutputs().add(feedbackData);
|
||||
// 设置为成功状态
|
||||
state.setProcessStatus(NODE_PROCESS_STATUS_SUCCESS);
|
||||
log.info("Human feedback processed for node: {}, content: {}", node.getTitle(), userInput);
|
||||
} else {
|
||||
// 用户输入为空,设置等待状态
|
||||
state.setProcessStatus(NODE_PROCESS_STATUS_DOING);
|
||||
log.info("Human feedback is empty for node: {}", node.getTitle());
|
||||
}
|
||||
} else {
|
||||
// 没有用户输入,这可能是正常情况(等待用户输入)
|
||||
// 但为了确保流程可以继续,我们仍然标记为成功
|
||||
state.setProcessStatus(NODE_PROCESS_STATUS_SUCCESS);
|
||||
log.info("No human feedback found for node: {}, continuing workflow", node.getTitle());
|
||||
}
|
||||
return new NodeProcessResult();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user