Commit eb129f4a authored by linpeiqin's avatar linpeiqin

增加模型切换的接口

parent 36837233
......@@ -47,5 +47,13 @@ public class PythonConfig {
*/
private String pythonWebsocketUri;
/**
* python 输出控制地址
*/
private String controllerAddress;
/**
* 对话基础地址
*/
private String chatAddress;
}
......@@ -66,7 +66,7 @@ public class KnowledgeManageController {
String requestBody = "{\n" + " \"knowledge_base_name\": \"" + knowledgeManage.getKnowledgeName() + "\",\n" + " \"vector_store_type\": \"faiss\",\n" + " \"embed_model\": \"m3e-base\"\n" + "}";
try {
String result = proxyPythonService.predictPost(knowledgeConfig.getKnowledgeInterface() + knowledgeConfig.getCreate(), requestBody);
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
......@@ -172,7 +172,7 @@ public class KnowledgeManageController {
String result = null;
try {
result = this.proxyPythonService.predictPost(this.knowledgeConfig.getKnowledgeInterface() + knowledgeConfig.getDeleteDocs(), requestBody);
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
......@@ -200,7 +200,7 @@ public class KnowledgeManageController {
String result = null;
try {
result = this.proxyPythonService.predictPost(this.knowledgeConfig.getKnowledgeInterface() + knowledgeConfig.getUpdateDocs(), requestBody);
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
......@@ -228,7 +228,7 @@ public class KnowledgeManageController {
String result = null;
try {
result = this.proxyPythonService.predictPostForFile(this.knowledgeConfig.getKnowledgeInterface() + knowledgeConfig.getUploadDocs(), requestBody);
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
......@@ -265,7 +265,7 @@ public class KnowledgeManageController {
private ResponseResult<String> doDeleteByName(String knowledgeName) {
try {
String result = this.proxyPythonService.predictPost(this.knowledgeConfig.getKnowledgeInterface() + this.knowledgeConfig.getDelete(), "\"" + knowledgeName + "\"");
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
......@@ -298,7 +298,7 @@ public class KnowledgeManageController {
List<KnowledgeManage> reKnowledgeManageList = new ArrayList<>();
try {
String result = this.proxyPythonService.predictGet(this.knowledgeConfig.getKnowledgeInterface() + this.knowledgeConfig.getList(), "");
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
JSONArray jsonArray = jo.getJSONArray("data");
if (code != null && code == 200) {
......@@ -329,7 +329,7 @@ public class KnowledgeManageController {
List<KnowledgeManage> reKnowledgeManageList = new ArrayList<>();
try {
String result = this.proxyPythonService.predictGet(this.knowledgeConfig.getKnowledgeInterface() + this.knowledgeConfig.getList(), "");
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
JSONArray jsonArray = jo.getJSONArray("data");
if (code != null && code == 200) {
......@@ -377,7 +377,7 @@ public class KnowledgeManageController {
} catch (IOException e) {
throw new RuntimeException(e);
}
JSONObject jo = (JSONObject) JSON.parse(result);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
JSONArray jsonArray = jo.getJSONArray("data");
......
......@@ -108,6 +108,8 @@ public class ModelManageController {
return ResponseResult.success(ModelManage.INSTANCE.fromModelList(modelManageList));
}
/**
* 删除模型管理数据。
*
......
package com.yice.webadmin.app.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.page.PageMethod;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yice.common.core.annotation.MyRequestBody;
......@@ -10,15 +12,18 @@ import com.yice.common.core.util.MyModelUtil;
import com.yice.common.core.util.MyPageUtil;
import com.yice.common.log.annotation.OperationLog;
import com.yice.common.log.model.constant.SysOperationLogType;
import com.yice.webadmin.app.config.PythonConfig;
import com.yice.webadmin.app.dto.ModelVersionDto;
import com.yice.webadmin.app.model.ModelVersion;
import com.yice.webadmin.app.service.ModelVersionService;
import com.yice.webadmin.app.service.ProxyPythonService;
import com.yice.webadmin.app.vo.ModelVersionVo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.util.List;
/**
......@@ -35,6 +40,10 @@ public class ModelVersionController {
@Autowired
private ModelVersionService modelVersionService;
@Autowired
private PythonConfig pythonConfig;
@Autowired
private ProxyPythonService proxyPythonService;
/**
* 新增模型版本数据。
......@@ -106,6 +115,32 @@ public class ModelVersionController {
return this.doDelete(versionId);
}
/**
* 列出符合过滤条件的模型管理列表。
*
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/change")
public ResponseResult<String> change(@MyRequestBody Long versionId) throws IOException {
ModelVersion modelVersion = this.modelVersionService.getById(versionId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("new_model_name",modelVersion.getVersionName());
jsonObject.put("new_model_path",modelVersion.getModelUrl());
jsonObject.put("controller_address",pythonConfig.getControllerAddress());
String url = this.pythonConfig.getChatAddress() + "llm_model/change";
String requestBody = jsonObject.toJSONString();
String result = proxyPythonService.predictPost(url,requestBody);
JSONObject jo = JSON.parseObject(result);
Integer code = jo.getIntValue("code");
String msg = jo.getString("msg");
String data = jo.getString("data");
if (code != null && code == 200) {
return ResponseResult.success(msg);
} else {
return ResponseResult.create(ErrorCodeEnum.SERVER_INTERNAL_ERROR, msg, data);
}
}
/**
* 列出符合过滤条件的模型版本列表。
*
......
......@@ -77,6 +77,10 @@ python:
factoryInterface: http://192.168.0.36:7860/run/predict
#python websocket 服务地址
pythonWebsocketUri: ws://192.168.0.36:7860/queue/join
#输出控制地址
controllerAddress: http://0.0.0.0:20001
#对话基础路径
chatAddress: http://192.168.0.36:7861/
knowledge:
#知识库通用接口地址
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment