feat(llm): 添加删除微调任务功能
- 在 AsyncFineTuningTaskService 中添加 deleteFinetuning 方法 - 在 FineTuningTaskHttpService 中实现 deletedFinetuning 方法 - 在 FineTuningTaskServiceImpl 中调用 deleteFinetuning 方法 - 在 LLMBackendProperties 中添加删除微调任务的 API 路径
This commit is contained in:
parent
544b4db400
commit
b426e158d0
@ -74,6 +74,7 @@ public class LLMBackendProperties {
|
||||
@NotNull(message = "停止微调任务 POST")
|
||||
private String stopFinetuning;
|
||||
|
||||
|
||||
private String finetuningLog;
|
||||
|
||||
private String finetuningDetail;
|
||||
|
@ -244,4 +244,15 @@ public class AsyncFineTuningTaskService {
|
||||
throw new RuntimeException("停止微调任务失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteFinetuning (FineTuningTaskDO fineTuningTaskDO) {
|
||||
ServerNameDO serverNameDO = getServerNameDO(fineTuningTaskDO);
|
||||
if (serverNameDO == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始调用HTTP服务删除微调任务,任务模型名称: {}", fineTuningTaskDO.getJobModelName());
|
||||
fineTuningTaskHttpService.deletedFinetuning(serverNameDO.getHost(), fineTuningTaskDO);
|
||||
log.info("HTTP服务调用成功,任务模型名称: {}", fineTuningTaskDO.getJobModelName());
|
||||
}
|
||||
}
|
||||
|
@ -394,6 +394,8 @@ public class FineTuningTaskServiceImpl implements FineTuningTaskService {
|
||||
asyncFineTuningTaskService.stopFinetuning(fineTuningTaskDO);
|
||||
log.info("异步调用模型服务完成,任务ID: {}", id);
|
||||
|
||||
log.info("开始异步调用模型服务,删除微调任务,任务ID: {},模型名称:{}", id,fineTuningTaskDO.getJobModelName());
|
||||
asyncFineTuningTaskService.deleteFinetuning(fineTuningTaskDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -168,4 +168,49 @@ public class FineTuningTaskHttpService {
|
||||
throw new RuntimeException("HTTP 请求发生未知异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void deletedFinetuning (String host, FineTuningTaskDO fineTuningTaskDO) {
|
||||
log.info(" ===== 删除微调任务 ===== stopFinetuning");
|
||||
|
||||
// 创建 OkHttpClient 实例
|
||||
log.info("创建 OkHttpClient 实例,设置超时时间为 2 分钟");
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(2, TimeUnit.MINUTES)
|
||||
.readTimeout(2, TimeUnit.MINUTES)
|
||||
.writeTimeout(2, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
// 1. 获取删除微调任务的URL
|
||||
String baseUrl = host + llmBackendProperties.getStopFinetuning();
|
||||
log.info("获取删除微调任务的URL: {}", baseUrl);
|
||||
HttpUrl url = Objects.requireNonNull(HttpUrl.parse(baseUrl))
|
||||
.newBuilder()
|
||||
.addQueryParameter("fine_tuned_model", fineTuningTaskDO.getJobModelName())
|
||||
.build();
|
||||
|
||||
// 2. 构建请求体(空请求体)
|
||||
RequestBody requestBody = RequestBody.create("", MediaType.parse("application/json"));
|
||||
|
||||
// 3. 构建请求
|
||||
Request request = new Request.Builder()
|
||||
.url(url)
|
||||
.delete(requestBody)
|
||||
.addHeader("accept", "application/json")
|
||||
.build();
|
||||
|
||||
// 4. 发送请求
|
||||
log.info("开始发送HTTP DELETE请求,删除微调任务,任务模型名称: {}", fineTuningTaskDO.getJobModelName());
|
||||
try (Response response = client.newCall(request).execute()) {
|
||||
if (response.body()!=null) {
|
||||
String body = response.body().string();
|
||||
log.info("HTTP删除请求完成,响应内容: {}", body);
|
||||
} else {
|
||||
log.error("HTTP请求失败: " + "响应为空");
|
||||
throw new RuntimeException("HTTP请求失败: " + "响应为空");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("发送HTTP请求删除微调任务时发生异常,任务模型名称: {}", fineTuningTaskDO.getJobModelName(), e);
|
||||
throw new RuntimeException("HTTP请求失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user