Skip to content

fixed #3559 Modify the DefaultToolCallResultConverter.convert method … #3568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Mono;

import org.springframework.ai.util.json.JsonParser;
import org.springframework.lang.Nullable;
Expand All @@ -47,6 +48,11 @@ public String convert(@Nullable Object result, @Nullable Type returnType) {
logger.debug("The tool has no return type. Converting to conventional response.");
return JsonParser.toJson("Done");
}
// handle results of Mono type
if (result instanceof Mono<?>) {
result = ((Mono<?>) result).block();
}

if (result instanceof RenderedImage) {
final var buf = new ByteArrayOutputStream(1024 * 4);
try {
Expand Down