feat(aihr): persist sop prompt version
This commit is contained in:
+2
-1
@@ -35,7 +35,7 @@ public final class AihrSopDto {
|
||||
public record SopReviewRequest(Boolean usable, String reviewer, String note) {
|
||||
}
|
||||
|
||||
public record SopReviewResponse(Long id, Boolean usable, String status, String reviewedAt) {
|
||||
public record SopReviewResponse(Long id, Boolean usable, String status, String reviewedAt, String promptVersion) {
|
||||
}
|
||||
|
||||
public record AnswerFeedbackRequest(String queryText, Long fragmentId, List<Long> fragmentIds, String verdict, String category, String position, String source, Long reviewId) {
|
||||
@@ -117,6 +117,7 @@ public final class AihrSopDto {
|
||||
List<RecordResponse> records,
|
||||
List<String> keyPoints,
|
||||
List<String> cautions,
|
||||
String promptVersion,
|
||||
Long reviewId
|
||||
) {
|
||||
}
|
||||
|
||||
+13
-5
@@ -1839,6 +1839,7 @@ public class AihrSopSeedService {
|
||||
response.records(),
|
||||
response.keyPoints(),
|
||||
response.cautions(),
|
||||
response.promptVersion(),
|
||||
reviewId
|
||||
);
|
||||
}
|
||||
@@ -1854,8 +1855,8 @@ public class AihrSopSeedService {
|
||||
jdbcTemplate.update(connection -> {
|
||||
PreparedStatement ps = connection.prepareStatement("""
|
||||
INSERT INTO aihr_sop_answer_review
|
||||
(tenant_id, query_text, category, answer_text, reference_text, snippet_count, source, status, create_time, update_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, '待评审', ?, ?)
|
||||
(tenant_id, query_text, category, answer_text, reference_text, snippet_count, source, prompt_version, status, create_time, update_time)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, '待评审', ?, ?)
|
||||
""", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setString(1, TENANT_ID);
|
||||
ps.setString(2, truncate(response.queryText(), 1000));
|
||||
@@ -1864,9 +1865,10 @@ public class AihrSopSeedService {
|
||||
ps.setString(5, truncate(response.reference(), 1000));
|
||||
ps.setInt(6, response.snippets() == null ? 0 : response.snippets().size());
|
||||
ps.setString(7, normalizeSearchSource(source));
|
||||
ps.setString(8, firstNonBlank(response.promptVersion(), "unknown"));
|
||||
Timestamp now = Timestamp.valueOf(java.time.LocalDateTime.now());
|
||||
ps.setTimestamp(8, now);
|
||||
ps.setTimestamp(9, now);
|
||||
ps.setTimestamp(10, now);
|
||||
return ps;
|
||||
}, keyHolder);
|
||||
Number key = keyHolder.getKey();
|
||||
@@ -1878,7 +1880,7 @@ public class AihrSopSeedService {
|
||||
|
||||
private SopReviewResponse sopReview(Long id) {
|
||||
List<SopReviewResponse> rows = jdbcTemplate.query("""
|
||||
SELECT id, usable, status, reviewed_time
|
||||
SELECT id, usable, status, reviewed_time, prompt_version
|
||||
FROM aihr_sop_answer_review
|
||||
WHERE tenant_id = ? AND id = ?
|
||||
LIMIT 1
|
||||
@@ -1888,7 +1890,8 @@ public class AihrSopSeedService {
|
||||
rs.getLong("id"),
|
||||
rs.getObject("usable") == null ? null : rs.getBoolean("usable"),
|
||||
rs.getString("status"),
|
||||
reviewedTime == null ? "" : reviewedTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"))
|
||||
reviewedTime == null ? "" : reviewedTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")),
|
||||
firstNonBlank(rs.getString("prompt_version"), "unknown")
|
||||
);
|
||||
}, TENANT_ID, id);
|
||||
return rows.isEmpty() ? null : rows.get(0);
|
||||
@@ -1936,6 +1939,7 @@ public class AihrSopSeedService {
|
||||
`reference_text` varchar(1000) DEFAULT NULL COMMENT '引用',
|
||||
`snippet_count` int DEFAULT 0 COMMENT '命中片段数',
|
||||
`source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源',
|
||||
`prompt_version` varchar(80) DEFAULT NULL COMMENT '答案生成提示词版本',
|
||||
`usable` tinyint DEFAULT NULL COMMENT '人工评审是否可用',
|
||||
`reviewer` varchar(100) DEFAULT NULL COMMENT '评审人',
|
||||
`note` varchar(500) DEFAULT NULL COMMENT '评审备注',
|
||||
@@ -1948,6 +1952,7 @@ public class AihrSopSeedService {
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='AI HR SOP问答人工评审';
|
||||
""");
|
||||
ensureColumn("aihr_sop_answer_review", "source", "ALTER TABLE aihr_sop_answer_review ADD COLUMN `source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源' AFTER `snippet_count`");
|
||||
ensureColumn("aihr_sop_answer_review", "prompt_version", "ALTER TABLE aihr_sop_answer_review ADD COLUMN `prompt_version` varchar(80) DEFAULT NULL COMMENT '答案生成提示词版本' AFTER `source`");
|
||||
sopReviewTableReady = true;
|
||||
}
|
||||
}
|
||||
@@ -2293,6 +2298,7 @@ public class AihrSopSeedService {
|
||||
records(),
|
||||
digest.keyPoints(),
|
||||
appendCautions(digest.cautions(), extraCautions),
|
||||
digest.promptVersion(),
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -2356,6 +2362,7 @@ public class AihrSopSeedService {
|
||||
records(),
|
||||
List.of(),
|
||||
appendCautions(List.of("未生成结构化概要,已返回命中原文片段。"), extraCautions),
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
@@ -2660,6 +2667,7 @@ public class AihrSopSeedService {
|
||||
records(),
|
||||
List.of(),
|
||||
cautions,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@@ -210,6 +210,7 @@ CREATE TABLE IF NOT EXISTS `aihr_sop_answer_review` (
|
||||
`reference_text` varchar(1000) DEFAULT NULL COMMENT '引用',
|
||||
`snippet_count` int DEFAULT 0 COMMENT '命中片段数',
|
||||
`source` varchar(50) DEFAULT 'knowledge_search' COMMENT '来源',
|
||||
`prompt_version` varchar(80) DEFAULT NULL COMMENT '答案生成提示词版本',
|
||||
`usable` tinyint DEFAULT NULL COMMENT '人工评审是否可用',
|
||||
`reviewer` varchar(100) DEFAULT NULL COMMENT '评审人',
|
||||
`note` varchar(500) DEFAULT NULL COMMENT '评审备注',
|
||||
|
||||
Reference in New Issue
Block a user