TASK:mixi;
This commit is contained in:
@@ -570,17 +570,17 @@ public class PythonService {
|
||||
|
||||
public JSONObject getAIRecommend(AIRecommendDTO aiRecommendDTO) {
|
||||
//限流校验
|
||||
AccessLimitUtils.validate("similarityMatch", 20);
|
||||
// AccessLimitUtils.validate("similarityMatch", 20);
|
||||
OkHttpClient client = new OkHttpClient().newBuilder()
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.connectTimeout(300, TimeUnit.SECONDS)
|
||||
.pingInterval(5, TimeUnit.SECONDS)//websocket轮训间隔(单位:秒)
|
||||
.readTimeout(300, TimeUnit.SECONDS)//读取超时(单位:秒)
|
||||
.writeTimeout(300, TimeUnit.SECONDS)//写入超时(单位:秒)
|
||||
.build();
|
||||
MediaType mediaType = MediaType.parse("application/json");
|
||||
Map<String, Object> content = Maps.newHashMap();
|
||||
content.put("input_message", "recommend three outfits");
|
||||
content.put("user_id", "user456");
|
||||
content.put("input_message", "recommend four outfits");
|
||||
content.put("user_id", aiRecommendDTO.getUserId());
|
||||
content.put("image_urls", "");
|
||||
|
||||
RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(content));
|
||||
@@ -594,13 +594,13 @@ public class PythonService {
|
||||
Response response = null;
|
||||
String bodyStr = null;
|
||||
try {
|
||||
log.info("获取python获取相似商品请求入参content###{}", JSON.toJSONString(content));
|
||||
log.info("获取python获取AI推荐请求入参content###{}", JSON.toJSONString(content));
|
||||
response = client.newCall(request).execute();
|
||||
bodyStr = response.body().string();
|
||||
} catch (IOException ioException) {
|
||||
log.error("PythonService##similarityMatch异常###{}", ExceptionUtil.getThrowableList(ioException));
|
||||
}
|
||||
log.info("识获取python获取相似商品请求结果###{}", bodyStr.trim());
|
||||
log.info("识获取python获取AI推荐请求结果###{}", bodyStr.trim());
|
||||
//去除限流
|
||||
AccessLimitUtils.validateOut("similarityMatch");
|
||||
if (Objects.isNull(response)) {
|
||||
@@ -613,8 +613,8 @@ public class PythonService {
|
||||
JSONObject parseObject = JSON.parseObject(bodyStr.trim());
|
||||
return parseObject;
|
||||
}
|
||||
log.info("获取python获取相似商品请求异常###{}", jsonObject);
|
||||
log.info("获取python获取AI推荐请求异常###{}", jsonObject);
|
||||
//生成失败
|
||||
throw new BusinessException("SimilarityMatch exception.");
|
||||
throw new BusinessException("AI recommendation exception.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user