fix(media): failed to store the media to /data/media and add image part

This commit is contained in:
Acbox
2026-04-13 12:58:08 +08:00
parent d46269de89
commit 26b01cc463
10 changed files with 507 additions and 7 deletions
+33
View File
@@ -145,6 +145,39 @@ func (r *Resolver) Pipeline() *pipelinepkg.Pipeline {
return r.pipeline
}
// InlineImageAttachments resolves image content hashes to sdk.ImagePart values
// using the configured asset loader. Intended for the discuss driver to inline
// images from new RC segments before calling the LLM.
func (r *Resolver) InlineImageAttachments(ctx context.Context, botID string, refs []pipelinepkg.ImageAttachmentRef) []sdk.ImagePart {
if r == nil || r.assetLoader == nil || len(refs) == 0 {
return nil
}
var parts []sdk.ImagePart
for _, ref := range refs {
contentHash := strings.TrimSpace(ref.ContentHash)
if contentHash == "" {
continue
}
dataURL, mime, err := r.inlineAssetAsDataURL(ctx, botID, contentHash, "image", strings.TrimSpace(ref.Mime))
if err != nil {
if r.logger != nil {
r.logger.Warn(
"inline discuss image attachment failed",
slog.Any("error", err),
slog.String("bot_id", botID),
slog.String("content_hash", contentHash),
)
}
continue
}
parts = append(parts, sdk.ImagePart{
Image: dataURL,
MediaType: mime,
})
}
return parts
}
type usageInfo struct {
InputTokens *int `json:"inputTokens"`
OutputTokens *int `json:"outputTokens"`