Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lmp_server
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmp
lmp_server
Commits
eb129f4a
Commit
eb129f4a
authored
Dec 12, 2023
by
linpeiqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加模型切换的接口
parent
36837233
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
8 deletions
+57
-8
PythonConfig.java
.../main/java/com/yice/webadmin/app/config/PythonConfig.java
+8
-0
KnowledgeManageController.java
...ce/webadmin/app/controller/KnowledgeManageController.java
+8
-8
ModelManageController.java
...m/yice/webadmin/app/controller/ModelManageController.java
+2
-0
ModelVersionController.java
.../yice/webadmin/app/controller/ModelVersionController.java
+35
-0
application-dev.yml
application-webadmin/src/main/resources/application-dev.yml
+4
-0
No files found.
application-webadmin/src/main/java/com/yice/webadmin/app/config/PythonConfig.java
View file @
eb129f4a
...
...
@@ -47,5 +47,13 @@ public class PythonConfig {
*/
private
String
pythonWebsocketUri
;
/**
* python 输出控制地址
*/
private
String
controllerAddress
;
/**
* 对话基础地址
*/
private
String
chatAddress
;
}
application-webadmin/src/main/java/com/yice/webadmin/app/controller/KnowledgeManageController.java
View file @
eb129f4a
...
...
@@ -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"
);
...
...
application-webadmin/src/main/java/com/yice/webadmin/app/controller/ModelManageController.java
View file @
eb129f4a
...
...
@@ -108,6 +108,8 @@ public class ModelManageController {
return
ResponseResult
.
success
(
ModelManage
.
INSTANCE
.
fromModelList
(
modelManageList
));
}
/**
* 删除模型管理数据。
*
...
...
application-webadmin/src/main/java/com/yice/webadmin/app/controller/ModelVersionController.java
View file @
eb129f4a
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
);
}
}
/**
* 列出符合过滤条件的模型版本列表。
*
...
...
application-webadmin/src/main/resources/application-dev.yml
View file @
eb129f4a
...
...
@@ -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
:
#知识库通用接口地址
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment