Browse Source

add:大模型,向量参数配置增加开放api访问部分内容

zhongwei
luyie 3 months ago
parent
commit
1fc1dabffd
  1. 33
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java
  2. 6
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java
  3. 4
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java
  4. 26
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java
  5. 17
      hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql

33
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java

@ -4,24 +4,30 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService; import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import com.hnac.hzinfo.api.annotation.ApiInterface;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/9/2 16:10 * @Date: 2024/9/2 16:10
*/ */
@RestController @RestController
@RequestMapping("/vector/") @RequestMapping("/vector")
@Api(value = "向量参数配置", tags = "向量参数配置") @Api(value = "向量参数配置", tags = "向量参数配置")
@AllArgsConstructor @AllArgsConstructor
@Slf4j
public class VectorParamController { public class VectorParamController {
private final VectorParamService vectorParamService; private final VectorParamService vectorParamService;
@ -60,5 +66,30 @@ public class VectorParamController {
return R.status(vectorParamService.updateById(req)); return R.status(vectorParamService.updateById(req));
} }
@GetMapping("/getAuthorization")
@ApiOperation(value = "获取向量参数配置授权信息")
@ApiOperationSupport(order = 6)
public R<String> getAuthorization() {
return R.data(vectorParamService.getAuthorization());
}
@GetMapping("/getUrlResponse")
@ApiOperation(value = "获取向量参数配置授权信息")
@ApiOperationSupport(order = 7)
public R getUrlResponse(@RequestParam String url, @RequestHeader("Blade-Auth") String token) {
log.info(token);
return R.data(vectorParamService.getUrlResponse(url, token));
}
@GetMapping("/getTestData")
@ApiOperation(value = "测试数据")
@ApiOperationSupport(order = 8)
@ApiInterface
public R getUrlByte() {
Map<String, String> data = new HashMap<>();
data.put("name", "测试数据");
data.put("url", "https://img.zcool.cn/community/01d9d85a8f9f2fa801206e0d0e0e9a.jpg@1280w_1l_2o_100sh.jpg");
data.put("data", "data");
return R.data(data);
}
} }

6
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/entity/VectorParamEntity.java

@ -1,5 +1,6 @@
package com.hnac.hzims.bigmodel.maintenance.entity; package com.hnac.hzims.bigmodel.maintenance.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -19,17 +20,22 @@ public class VectorParamEntity extends TenantEntity implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("参数名称") @ApiModelProperty("参数名称")
@TableField("NAME")
private String name; private String name;
@ApiModelProperty("url") @ApiModelProperty("url")
@TableField("URL")
private String url; private String url;
@ApiModelProperty("项目前缀") @ApiModelProperty("项目前缀")
@TableField("PROJECT_PREFIX")
private String projectPrefix; private String projectPrefix;
@ApiModelProperty("数据库表名") @ApiModelProperty("数据库表名")
@TableField("TABLE_NAME")
private String tableName; private String tableName;
@ApiModelProperty("向量键值对,json格式") @ApiModelProperty("向量键值对,json格式")
@TableField("ATTRIBUTE_MAP")
private String attributeMap; private String attributeMap;
} }

4
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java

@ -3,11 +3,15 @@ package com.hnac.hzims.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/09/02 15:11 * @Date: 2024/09/02 15:11
*/ */
public interface VectorParamService extends IService<VectorParamEntity> { public interface VectorParamService extends IService<VectorParamEntity> {
String getAuthorization();
Map getUrlResponse(String url, String token);
} }

26
hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

@ -1,15 +1,41 @@
package com.hnac.hzims.bigmodel.maintenance.service.impl; package com.hnac.hzims.bigmodel.maintenance.service.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity; import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.hzims.bigmodel.maintenance.mapper.VectorParamMapper; import com.hnac.hzims.bigmodel.maintenance.mapper.VectorParamMapper;
import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService; import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;
/** /**
* @Author: ypj * @Author: ypj
* @Date: 2024/9/2 16:14 * @Date: 2024/9/2 16:14
*/ */
@Service @Service
public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, VectorParamEntity> implements VectorParamService { public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, VectorParamEntity> implements VectorParamService {
private static final String CLIENT_SIGN = "vector_param";
@Override
public String getAuthorization() {
return "Basic " + Base64.getEncoder().encodeToString(CLIENT_SIGN.getBytes(StandardCharsets.UTF_8));
}
@Override
public Map getUrlResponse(String url, String token) {
HttpResponse response = HttpRequest.get(url)
.header("Authorization", getAuthorization())
.header("Blade-Auth", token).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
return JsonUtil.toMap(response.body());
}
return null;
}
} }

17
hzims-service/hzims-big-model/src/main/resources/db/2.0.2.sql

@ -0,0 +1,17 @@
CREATE TABLE `HZIMS_VECTOR_PARAM` (
`ID` bigint(20) NOT NULL COMMENT '主键ID',
`NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '名称',
`URL` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT 'URL',
`PROJECT_PREFIX` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '项目前缀',
`TABLE_NAME` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '数据库表名',
`ATTRIBUTE_MAP` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '向量键值对',
`TENANT_ID` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '租户ID',
`STATUS` tinyint(4) NULL DEFAULT NULL COMMENT '状态',
`CREATE_DEPT` bigint(20) NULL DEFAULT NULL COMMENT '创建单位',
`CREATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
`CREATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`UPDATE_USER` bigint(20) NULL DEFAULT NULL COMMENT '修改人',
`UPDATE_TIME` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
`IS_DELETED` tinyint(4) NOT NULL COMMENT '是否删除',
PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '向量键值对信息' ROW_FORMAT = Dynamic;
Loading…
Cancel
Save