Commit dc98005c by 潘诗林

feat:调用大模型生成预学习话术

1 parent f84c10c3
...@@ -18,6 +18,7 @@ import com.fasterxml.jackson.core.type.TypeReference; ...@@ -18,6 +18,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
...@@ -35,11 +36,6 @@ import java.util.stream.Collectors; ...@@ -35,11 +36,6 @@ import java.util.stream.Collectors;
@Service @Service
public class PreLearnBigModelService { public class PreLearnBigModelService {
/** 大模型API地址 */
private static final String BIG_MODEL_BASE_URL = "http://192.168.1.191:8000/api/v1";
private static final String TEMPLATE_ID = "TEMPLATE-GENERAL-002";
private static final String ACCOUNT_ID = "LEGACY-eb0333776935";
@Autowired @Autowired
private MarketingActivityRemote marketingActivityRemote; private MarketingActivityRemote marketingActivityRemote;
...@@ -61,7 +57,8 @@ public class PreLearnBigModelService { ...@@ -61,7 +57,8 @@ public class PreLearnBigModelService {
@Autowired @Autowired
private ConversationDateService conversationDateService; private ConversationDateService conversationDateService;
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); @Autowired
private Environment env;
/** /**
* 提交大模型异步任务(HTTP POST) * 提交大模型异步任务(HTTP POST)
...@@ -72,11 +69,13 @@ public class PreLearnBigModelService { ...@@ -72,11 +69,13 @@ public class PreLearnBigModelService {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public String submitAsyncTask(String recordingText) { public String submitAsyncTask(String recordingText) {
try { try {
String url = BIG_MODEL_BASE_URL + "/calls/by-template"; String url = env.getProperty("big.model.base.prelearn.url", "http://192.168.1.191:8000/api/v1/calls/by-template");
String template_id = env.getProperty("big.model.base.prelearn.template", "CPPE-BENCH-001");
String account_id = env.getProperty("big.model.base.prelearn.account", "LEGACY-eb0333776935");
JSONObject requestBody = new JSONObject(); JSONObject requestBody = new JSONObject();
requestBody.put("template_id", TEMPLATE_ID); requestBody.put("template_id", template_id);
requestBody.put("account_id", ACCOUNT_ID); requestBody.put("account_id", account_id);
JSONObject variables = new JSONObject(); JSONObject variables = new JSONObject();
variables.put("recording_text", recordingText); variables.put("recording_text", recordingText);
...@@ -214,7 +213,8 @@ public class PreLearnBigModelService { ...@@ -214,7 +213,8 @@ public class PreLearnBigModelService {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public TaskQueryResult queryTaskResult(String modelTaskId) { public TaskQueryResult queryTaskResult(String modelTaskId) {
try { try {
String url = BIG_MODEL_BASE_URL + "/calls/orchestrate/async?task_id=" + modelTaskId; String baseUrl = env.getProperty("big.model.base.prelearn.query.url", "http://192.168.1.191:8000/api/v1/calls/orchestrate/async?task_id=");
String url = baseUrl + modelTaskId;
log.info("queryTaskResult: 查询任务结果, taskId={}", modelTaskId); log.info("queryTaskResult: 查询任务结果, taskId={}", modelTaskId);
Map<String, Object> response = restTemplate.getForObject(url, Map.class); Map<String, Object> response = restTemplate.getForObject(url, Map.class);
...@@ -404,28 +404,4 @@ public class PreLearnBigModelService { ...@@ -404,28 +404,4 @@ public class PreLearnBigModelService {
Math.abs(r.getReceptionStartTime().getTime() - orderDate.getTime()))) Math.abs(r.getReceptionStartTime().getTime() - orderDate.getTime())))
.orElse(recordings.get(0)); .orElse(recordings.get(0));
} }
/**
* 解析ali_asr_model_res.output_data JSON数组,拼接所有content字段
* output_data格式: [{"role":"...","offset":...,"duration":...,"content":"..."}, ...]
*/
private String parseAsrOutputData(String outputData) {
try {
List<Map<String, Object>> segments = OBJECT_MAPPER.readValue(
outputData, new TypeReference<List<Map<String, Object>>>() {});
if (CollectionUtils.isEmpty(segments)) {
return null;
}
return segments.stream()
.map(seg -> {
Object content = seg.get("content");
return content != null ? content.toString() : "";
})
.filter(StringUtils::hasText)
.collect(Collectors.joining("\n"));
} catch (Exception e) {
log.warn("解析ASR outputData失败: {}", e.getMessage());
return null;
}
}
} }
...@@ -128,7 +128,10 @@ ...@@ -128,7 +128,10 @@
<select id="selectByPhoneNumber" resultMap="BaseResultMap"> <select id="selectByPhoneNumber" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List" />, i.id, i.badge_id, i.recording_md5, i.work_order_number, i.recording_filename, i.recording_filesize,
i.recording_start_time, i.recording_end_time, i.recording_duration, i.recording_url, i.right_channel_recording_url,
i.sync_time, i.recording_id, i.resolved_flag, i.upload_flag, i.upload_url, i.process_task_id, i.created_by, i.created_date,
i.updated_by, i.updated_date, i.deleted_flag,i.reception_id,
c.reception_start_time AS reception_start_time c.reception_start_time AS reception_start_time
FROM reception_customer_info c FROM reception_customer_info c
LEFT JOIN inspection_badge_recordings i ON i.reception_id = c.id LEFT JOIN inspection_badge_recordings i ON i.reception_id = c.id
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!