|
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.qmth.boot.core.retrofit.exception.RetrofitResponseError;
|
|
import com.qmth.boot.core.retrofit.exception.RetrofitResponseError;
|
|
|
|
|
|
|
|
+import cn.com.qmth.am.bean.OcrServer;
|
|
import cn.com.qmth.am.bean.ds.AutoScoreRequest;
|
|
import cn.com.qmth.am.bean.ds.AutoScoreRequest;
|
|
import cn.com.qmth.am.bean.ds.AutoScoreResult;
|
|
import cn.com.qmth.am.bean.ds.AutoScoreResult;
|
|
import cn.com.qmth.am.bean.ds.ChatReq;
|
|
import cn.com.qmth.am.bean.ds.ChatReq;
|
|
@@ -66,10 +67,10 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
@Override
|
|
@Override
|
|
- public String ocr(String base64) {
|
|
|
|
- OcrReq dreq = new OcrReq(sysProperty.getOcrModel());
|
|
|
|
|
|
+ public String ocr(OcrServer ocrServer, String base64) {
|
|
|
|
+ OcrReq dreq = new OcrReq(ocrServer.getModel());
|
|
dreq.addMsg(new OcrMessage(base64));
|
|
dreq.addMsg(new OcrMessage(base64));
|
|
- String res = ocr(dreq);
|
|
|
|
|
|
+ String res = ocr(ocrServer, dreq);
|
|
ChatResult result = JSONObject.parseObject(res, ChatResult.class);
|
|
ChatResult result = JSONObject.parseObject(res, ChatResult.class);
|
|
String text = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
String text = result.getChoices().stream().filter(choice -> choice.getMessage().getRole() == ChatRole.assistant)
|
|
.map(choice -> choice.getMessage().getContent()).findFirst().orElse("");
|
|
.map(choice -> choice.getMessage().getContent()).findFirst().orElse("");
|
|
@@ -224,13 +225,13 @@ public class DsMarkingServiceImpl implements DsMarkingService {
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("deprecation")
|
|
@SuppressWarnings("deprecation")
|
|
- private String ocr(ChatReq dreq) {
|
|
|
|
|
|
+ private String ocr(OcrServer ocrServer, ChatReq dreq) {
|
|
|
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
- headers.put("Authorization", "Bearer " + sysProperty.getOcrKey());
|
|
|
|
|
|
+ headers.put("Authorization", "Bearer " + ocrServer.getKey());
|
|
Response resp = null;
|
|
Response resp = null;
|
|
try {
|
|
try {
|
|
- resp = OKHttpUtil.call(HttpMethod.POST, sysProperty.getOcrServer(), headers, JSONObject.toJSONString(dreq));
|
|
|
|
|
|
+ resp = OKHttpUtil.call(HttpMethod.POST, ocrServer.getServer(), headers, JSONObject.toJSONString(dreq));
|
|
if (resp.code() != 200) {
|
|
if (resp.code() != 200) {
|
|
throw new RetrofitResponseError(resp.code(), resp.body().string());
|
|
throw new RetrofitResponseError(resp.code(), resp.body().string());
|
|
} else {
|
|
} else {
|