Browse Source

add:大模型,向量配置,开放接口鉴权,兼容hzinfo-auth和blade-auth

zhongwei
luyie 3 months ago
parent
commit
9589a86906
  1. 15
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/controller/VectorParamController.java
  2. 5
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/VectorParamService.java
  3. 22
      hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/maintenance/service/impl/VectorParamServiceImpl.java

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

@ -17,6 +17,7 @@ import org.springblade.core.tool.utils.Func;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -76,8 +77,10 @@ public class VectorParamController {
@GetMapping("/getUrlResponse")
@ApiOperation(value = "通过url获取向量参数数据")
@ApiOperationSupport(order = 7)
public R getUrlResponse(@RequestParam String url, @RequestHeader("Blade-Auth") String token) {
return R.data(vectorParamService.getUrlResponse(url, token));
public R getUrlResponse(@RequestParam String url,
@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken,
@RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) {
return R.data(vectorParamService.getUrlResponse(url, bladeToken, hzinfoToken));
}
@GetMapping("/getTestData")
@ -91,4 +94,12 @@ public class VectorParamController {
data.put("data", "data");
return R.data(data);
}
@GetMapping("/getUrlResponseKeyList")
@ApiOperation(value = "获取url返回的key列表")
public R<List<String>> getUrlResponseKeyList(@RequestParam String url,
@RequestHeader(name = "Blade-Auth", value = "Blade-Auth", required = false) String bladeToken,
@RequestHeader(name = "Hzinfo-Auth", value = "Hzinfo-Auth", required = false) String hzinfoToken) {
return R.data(vectorParamService.getUrlResponseKeyList(url, bladeToken, hzinfoToken));
}
}

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

@ -3,6 +3,7 @@ package com.hnac.hzims.bigmodel.maintenance.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import java.util.List;
import java.util.Map;
/**
@ -13,5 +14,7 @@ import java.util.Map;
public interface VectorParamService extends IService<VectorParamEntity> {
String getAuthorization();
Map getUrlResponse(String url, String token);
Map getUrlResponse(String url, String bladeToken ,String hzinfoToken);
List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken);
}

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

@ -6,12 +6,15 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnac.hzims.bigmodel.maintenance.entity.VectorParamEntity;
import com.hnac.hzims.bigmodel.maintenance.mapper.VectorParamMapper;
import com.hnac.hzims.bigmodel.maintenance.service.VectorParamService;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.tool.jackson.JsonUtil;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
/**
@ -19,6 +22,7 @@ import java.util.Map;
* @Date: 2024/9/2 16:14
*/
@Service
@Slf4j
public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, VectorParamEntity> implements VectorParamService {
private static final String CLIENT_SIGN = "vector_param";
@ -29,13 +33,27 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
}
@Override
public Map getUrlResponse(String url, String token) {
public Map getUrlResponse(String url, String bladeToken, String hzinfoToken) {
HttpResponse response = HttpRequest.get(url)
.header("Authorization", getAuthorization())
.header("Blade-Auth", token).execute();
.header("Blade-Auth", bladeToken)
.header("Hzinfo-Auth", hzinfoToken).execute();
if (response.getStatus() == HttpServletResponse.SC_OK) {
return JsonUtil.toMap(response.body());
}
return null;
}
@Override
public List<String> getUrlResponseKeyList(String url, String bladeToken, String hzinfoToken) {
List<String> result = new ArrayList<>();
Map map = getUrlResponse(url, bladeToken, hzinfoToken);
Map<String, Object> data = ((Map<String, Object>) map.get("data"));
if (data != null) {
result.addAll(data.keySet());
} else {
result.addAll(map.keySet());
}
return result;
}
}

Loading…
Cancel
Save