feat: 新增错误重试记忆表/entity/consts
This commit is contained in:
@@ -9,4 +9,5 @@ const (
|
||||
TableNameModelSession = "model_session"
|
||||
TableNameModelTaskStart = "model_task_start"
|
||||
TableNameModelTaskEnd = "model_task_end"
|
||||
TableNameErrorMemory = "error_memory"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package entity
|
||||
|
||||
import "gitea.redpowerfuture.com/red-future/common/beans"
|
||||
|
||||
type errorMemoryCol struct {
|
||||
beans.SQLBaseCol
|
||||
MemoryKey string
|
||||
Upstream string
|
||||
ErrorCode string
|
||||
MsgFingerprint string
|
||||
Retryable string
|
||||
Reason string
|
||||
AnalyzedBy string
|
||||
}
|
||||
|
||||
var ErrorMemoryCol = errorMemoryCol{
|
||||
SQLBaseCol: beans.DefSQLBaseCol,
|
||||
MemoryKey: "memory_key",
|
||||
Upstream: "upstream",
|
||||
ErrorCode: "error_code",
|
||||
MsgFingerprint: "msg_fingerprint",
|
||||
Retryable: "retryable",
|
||||
Reason: "reason",
|
||||
AnalyzedBy: "analyzed_by",
|
||||
}
|
||||
|
||||
// ErrorMemory 错误重试记忆(LLM 分析结论持久化,永久有效)
|
||||
type ErrorMemory struct {
|
||||
beans.SQLBaseDO `orm:",inline"`
|
||||
MemoryKey string `orm:"memory_key" json:"memoryKey" dc:"记忆键=SHA-256(upstream|code|归一化消息)"`
|
||||
Upstream string `orm:"upstream" json:"upstream" dc:"失败上游BaseURL"`
|
||||
ErrorCode string `orm:"error_code" json:"errorCode" dc:"错误码"`
|
||||
MsgFingerprint string `orm:"msg_fingerprint" json:"msgFingerprint" dc:"归一化消息md5"`
|
||||
Retryable bool `orm:"retryable" json:"retryable" dc:"是否可重试"`
|
||||
Reason string `orm:"reason" json:"reason" dc:"分析原因"`
|
||||
AnalyzedBy string `orm:"analyzed_by" json:"analyzedBy" dc:"分析模型名"`
|
||||
}
|
||||
+25
-1
@@ -361,4 +361,28 @@ WHERE r.system_model = false AND s.system_model = true
|
||||
ALTER TABLE model_gateway_model_manage
|
||||
ADD COLUMN IF NOT EXISTS error_message_mapping JSONB DEFAULT NULL;
|
||||
COMMENT ON COLUMN model_gateway_model_manage.error_message_mapping
|
||||
IS '错误消息映射:{code,message} 的 schema 树(type/attrs/value/defaultValue),解析模型错误响应,defaultValue 为成功码';
|
||||
IS '错误消息映射:{code,message} 的 schema 树(type/attrs/value/defaultValue),解析模型错误响应,defaultValue 为成功码';
|
||||
|
||||
-- =========================
|
||||
-- 错误重试记忆:LLM 分析上游模型错误是否可重试的持久知识库
|
||||
-- memory_key = SHA-256(upstream|error_code|归一化消息),唯一;命中直接复用,永久有效
|
||||
-- =========================
|
||||
CREATE TABLE IF NOT EXISTS model_gateway_error_memory (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
tenant_id BIGINT DEFAULT 0,
|
||||
creator VARCHAR(64) DEFAULT '',
|
||||
created_at TIMESTAMPTZ DEFAULT now(),
|
||||
updater VARCHAR(64) DEFAULT '',
|
||||
updated_at TIMESTAMPTZ DEFAULT now(),
|
||||
deleted_at TIMESTAMPTZ DEFAULT NULL,
|
||||
memory_key CHAR(64) NOT NULL,
|
||||
upstream VARCHAR(512) NOT NULL DEFAULT '',
|
||||
error_code VARCHAR(128) NOT NULL DEFAULT '',
|
||||
msg_fingerprint CHAR(32) NOT NULL DEFAULT '',
|
||||
retryable BOOLEAN NOT NULL DEFAULT false,
|
||||
reason VARCHAR(512) NOT NULL DEFAULT '',
|
||||
analyzed_by VARCHAR(128) NOT NULL DEFAULT ''
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uk_error_memory_memory_key
|
||||
ON model_gateway_error_memory (memory_key)
|
||||
WHERE deleted_at IS NULL;
|
||||
Reference in New Issue
Block a user