Request for Feedback #95
Replies: 3 comments 3 replies
-
|
Thank you for exmaples. I've been able to find method I have produced some looping code that fullfils my flow:
Detailspublic String askClaude(final String system, final String body) {
final var messageBuilder = createConversation(system, body);
var response = this.client.messages().create(messageBuilder.build());
boolean doLoop = true;
while (doLoop) {
final var previousResponse = response;
messageBuilder.addMessage(previousResponse);
final var newResponse = response.content().stream()
.map(content -> content.accept(new ContentBlock.Visitor<Message>() {
@Override
public Message visitTextBlock(@NotNull final TextBlock textBlock) {
return null; // end of looping
}
@Override
public Message visitToolUseBlock(@NotNull final ToolUseBlock toolUseBlock) {
messageBuilder.addMessage(
MessageParam.builder()
.role(MessageParam.Role.USER)
.content(
MessageParam.Content.ofContentBlockParams(
List.of(
ContentBlockParam.ofToolResultBlockParam(
ToolResultBlockParam.builder()
.type(ToolResultBlockParam.Type.TOOL_RESULT)
.toolUseId(toolUseBlock.id())
.content(executeToolUse(toolUseBlock))
.build()
)
)
)
)
.build()
);
return SyncRequestClient.this.client.messages().create(messageBuilder.build());
}
}))
.filter(Objects::nonNull)
.findFirst()
.orElse(null);
// kind of heuristic ending
doLoop = newResponse != null;
if (newResponse != null) {
response = newResponse;
}
}
return response.content()
.stream()
.flatMap(contentBlock -> contentBlock.textBlock().stream())
.map(TextBlock::text)
.collect(Collectors.joining());
} |
Beta Was this translation helpful? Give feedback.
-
|
Hi team, thanks for the good examples. Do we have a api to support big request body set/big body response? Or is not necessary in fact? like this case : |
Beta Was this translation helpful? Give feedback.
-
|
This API is, frankly, insane. It looks like it was AI generated and is excessively, and confusingly verbose. There's no documentation. There are no complete examples. There's a ton of confusingly and similarly named classes. This is really how we have to return a tool call result? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 Hi everyone!
This SDK is in alpha, and we are actively iterating on its design and making improvements. We would love to hear your thoughts and feedback!
As you try the new SDK, please share your thoughts and feedback. We'll be actively monitoring discussion threads and new issues.
Thanks in advance! We hope to make a Java SDK you'll love using.
Beta Was this translation helpful? Give feedback.
All reactions