Skip to content

Commit a1ed57c

Browse files
author
Max Hniebergall
committed
Allow for null/empty content field
1 parent dbbcb09 commit a1ed57c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

server/src/main/java/org/elasticsearch/inference/UnifiedCompletionRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public record Message(Content content, String role, @Nullable String name, @Null
122122
);
123123

124124
static {
125-
PARSER.declareField(constructorArg(), (p, c) -> parseContent(p), new ParseField("content"), ObjectParser.ValueType.VALUE_ARRAY);
125+
PARSER.declareField(optionalConstructorArg(), (p, c) -> parseContent(p), new ParseField("content"), ObjectParser.ValueType.VALUE_ARRAY);
126126
PARSER.declareString(constructorArg(), new ParseField("role"));
127127
PARSER.declareString(optionalConstructorArg(), new ParseField("name"));
128128
PARSER.declareString(optionalConstructorArg(), new ParseField("tool_call_id"));

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/external/request/openai/OpenAiUnifiedChatCompletionRequestEntity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
7878
}
7979
builder.endArray();
8080
}
81+
case null -> {
82+
// do nothing
83+
}
8184
}
8285

8386
builder.field(ROLE_FIELD, message.role());

0 commit comments

Comments
 (0)