feat(txt): add distill txt
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -3612,7 +3612,7 @@ func (s *DesignService) markGenerationFailed(ctx context.Context, projectID stri
|
||||
Role: "error",
|
||||
Type: "error",
|
||||
Title: "图片生成失败",
|
||||
Content: failure.Error(),
|
||||
Content: generationFailureMessage(failure, false),
|
||||
ThreadID: project.LastThreadID,
|
||||
ActionID: project.LastThreadID,
|
||||
StepID: newID(),
|
||||
@@ -3642,7 +3642,7 @@ func (s *DesignService) markAgentGenerationFailed(ctx context.Context, projectID
|
||||
Role: "error",
|
||||
Type: "error",
|
||||
Title: "图片生成失败",
|
||||
Content: failure.Error(),
|
||||
Content: generationFailureMessage(failure, false),
|
||||
ThreadID: threadID,
|
||||
ActionID: threadID,
|
||||
StepID: newID(),
|
||||
@@ -3682,7 +3682,7 @@ func (s *DesignService) markAgentGenerationPartiallyFailed(ctx context.Context,
|
||||
Role: "error",
|
||||
Type: "error",
|
||||
Title: "图片生成部分失败",
|
||||
Content: failure.Error(),
|
||||
Content: generationFailureMessage(failure, true),
|
||||
ThreadID: threadID,
|
||||
ActionID: threadID,
|
||||
StepID: newID(),
|
||||
@@ -3710,7 +3710,7 @@ func (s *DesignService) markNodeActionFailed(ctx context.Context, projectID stri
|
||||
Role: "error",
|
||||
Type: "error",
|
||||
Title: "图片处理失败",
|
||||
Content: failure.Error(),
|
||||
Content: imageActionFailureMessage(failure),
|
||||
ThreadID: threadID,
|
||||
ActionID: threadID,
|
||||
StepID: newID(),
|
||||
@@ -3723,6 +3723,61 @@ func (s *DesignService) markNodeActionFailed(ctx context.Context, projectID stri
|
||||
return s.repo.Save(ctx, project)
|
||||
}
|
||||
|
||||
func generationFailureMessage(failure error, partial bool) string {
|
||||
if partial {
|
||||
if isTimeoutLikeFailure(failure) {
|
||||
return "部分图片已经生成完成,剩余图片耗时较久没有成功返回。已保留成功结果,你可以只重试失败的部分。"
|
||||
}
|
||||
return "部分图片已经生成完成,剩余图片没有成功生成。已保留成功结果,你可以只重试失败的部分。"
|
||||
}
|
||||
if isTimeoutLikeFailure(failure) {
|
||||
return "图片生成耗时较久,这次没有成功完成。画布内容已保留,你可以直接重试,或先降低图片数量/尺寸后再生成。"
|
||||
}
|
||||
if isTemporaryUpstreamFailure(failure) {
|
||||
return "图片生成服务暂时繁忙,这次没有成功完成。画布内容已保留,请稍后重试。"
|
||||
}
|
||||
return "图片生成没有成功完成。画布内容已保留,你可以重新发起生成。"
|
||||
}
|
||||
|
||||
func imageActionFailureMessage(failure error) string {
|
||||
if isTimeoutLikeFailure(failure) {
|
||||
return "图片处理耗时较久,这次没有成功完成。原图已保留,你可以稍后重试。"
|
||||
}
|
||||
if isTemporaryUpstreamFailure(failure) {
|
||||
return "图片处理服务暂时繁忙,这次没有成功完成。原图已保留,请稍后重试。"
|
||||
}
|
||||
return "图片处理没有成功完成。原图已保留,你可以重新发起处理。"
|
||||
}
|
||||
|
||||
func isTimeoutLikeFailure(failure error) bool {
|
||||
if failure == nil {
|
||||
return false
|
||||
}
|
||||
if errors.Is(failure, context.DeadlineExceeded) || errors.Is(failure, context.Canceled) {
|
||||
return true
|
||||
}
|
||||
text := strings.ToLower(failure.Error())
|
||||
return strings.Contains(text, "deadline") ||
|
||||
strings.Contains(text, "timeout") ||
|
||||
strings.Contains(text, "timed out") ||
|
||||
strings.Contains(text, "awaiting headers") ||
|
||||
strings.Contains(text, "lease expired")
|
||||
}
|
||||
|
||||
func isTemporaryUpstreamFailure(failure error) bool {
|
||||
if failure == nil {
|
||||
return false
|
||||
}
|
||||
text := strings.ToLower(failure.Error())
|
||||
return strings.Contains(text, "overload") ||
|
||||
strings.Contains(text, "too many requests") ||
|
||||
strings.Contains(text, "rate limit") ||
|
||||
strings.Contains(text, "temporar") ||
|
||||
strings.Contains(text, "service unavailable") ||
|
||||
strings.Contains(text, "bad gateway") ||
|
||||
strings.Contains(text, "gateway")
|
||||
}
|
||||
|
||||
func (s *DesignService) markIsolatedGenerationFailed(ctx context.Context, projectID string, targetNodeID string, _ error) error {
|
||||
project, err := s.repo.Get(ctx, projectID)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user