perf(dingtalk): rewrite answer images concurrently and make the rewrite budget configurable
- outboundimage: fetch and publish up to 4 images in parallel, dedupe in document order, log per-image outcome plus a rewrite summary - dingtalk handler: OutboundRewriteTimeout applies to the image rewrite stage only, falling back to finalDeliveryTimeout - cmd/dobotai: DOBOTAI_OUTBOUND_IMAGE_REWRITE_TIMEOUT (default 60s, invalid values fall back)
This commit is contained in:
@@ -163,6 +163,11 @@ type HandlerOptions struct {
|
||||
SettingsRouter SettingsRouter
|
||||
ReasoningRouter ReasoningRouter
|
||||
LanguageResolver LanguagePreferenceResolver
|
||||
// OutboundRewriteTimeout bounds the outbound image rewrite stage (fetch +
|
||||
// publish). Answers carrying many large screenshots need more than the
|
||||
// delivery timeout, otherwise the remaining images are dropped. Zero keeps
|
||||
// finalDeliveryTimeout.
|
||||
OutboundRewriteTimeout time.Duration
|
||||
}
|
||||
|
||||
type Handler struct {
|
||||
@@ -181,6 +186,9 @@ type Handler struct {
|
||||
now func() time.Time
|
||||
cardUpdateInterval time.Duration
|
||||
finalDeliveryTimeout time.Duration
|
||||
// outboundRewriteTimeout applies to the image rewrite stage only; zero
|
||||
// falls back to finalDeliveryTimeout.
|
||||
outboundRewriteTimeout time.Duration
|
||||
}
|
||||
|
||||
// NewHandler accepts at most one image downloader. A nil/omitted downloader
|
||||
@@ -228,6 +236,8 @@ func NewHandlerWithOptions(cfg TenantConfig, qa QAAsker, reply MarkdownSender, o
|
||||
now: time.Now,
|
||||
cardUpdateInterval: 500 * time.Millisecond,
|
||||
finalDeliveryTimeout: defaultHTTPTimeout,
|
||||
|
||||
outboundRewriteTimeout: opts.OutboundRewriteTimeout,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -653,7 +663,10 @@ func (h *Handler) rewriteOutboundContent(ctx context.Context, content string) st
|
||||
if h.outboundRewriter == nil {
|
||||
return normalizeWideMarkdownTables(sanitizeDisplayAnswer(content))
|
||||
}
|
||||
timeout := h.finalDeliveryTimeout
|
||||
timeout := h.outboundRewriteTimeout
|
||||
if timeout <= 0 {
|
||||
timeout = h.finalDeliveryTimeout
|
||||
}
|
||||
if timeout <= 0 {
|
||||
timeout = defaultHTTPTimeout
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user