Skip to content
Draft
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 @@ -79,6 +79,16 @@ public OrchestrationClient(@Nonnull final HttpDestination destination) {
@Nonnull
public static CompletionRequestConfiguration toCompletionPostRequest(
@Nonnull final OrchestrationPrompt prompt, @Nonnull final OrchestrationModuleConfig config) {
if (prompt.getMessages().size() == 1 && prompt.getMessages().get(0) instanceof UserMessage m) {
val items = m.content().items();
if (items.size() == 1 && items.get(0) instanceof TextItem t) {
val JSON_SCHEMA = "https://json-schema.org/draft/2020-12/schema";
if (t.text().contains(JSON_SCHEMA) && config.getTemplateConfig() != null) {
log.warn("Combination of `entity(...)` and `withTemplateConfig(...)` is not supported.");
}
Comment on lines +85 to +88
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if testing just for https://json-schema.org/draft/2020-12/schema is good here. This might lead to false positives if a users specifies the schema version in their actual prompt (not sure how likely it is, but might happen?!)

I would thus add a bit of the formatting around it to the test string.

Suggested change
val JSON_SCHEMA = "https://json-schema.org/draft/2020-12/schema";
if (t.text().contains(JSON_SCHEMA) && config.getTemplateConfig() != null) {
log.warn("Combination of `entity(...)` and `withTemplateConfig(...)` is not supported.");
}
val JSON_SCHEMA = "\\n \\\"$schema\\\" : \\\"https://json-schema.org/draft/2020-12/schema\\\",";
if (t.text().contains(JSON_SCHEMA) && config.getTemplateConfig() != null) {
log.warn("Combination of `entity(...)` and `withTemplateConfig(...)` is not supported.");
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely we shouldn't put this in OrchestrationClient altogether. If we put this into code, it'd be better located in Spring AI related class(es) 🤔

}
}

return ConfigToRequestTransformer.toCompletionPostRequest(prompt, config);
}

Expand Down
Loading