ravismash commented on code in PR #1435:
URL: https://github.com/apache/flink-agents/pull/1435#discussion_r4680381038
##########
plan/src/test/java/org/apache/flink/agents/plan/actions/ChatModelActionTest.java:
##########
@@ -59,6 +67,49 @@ void structuredOutputPreservesOriginalBlocks() throws
Exception {
assertFalse(original.getMetadata().containsKey(Agent.STRUCTURED_OUTPUT));
}
+ private static OutputSchema rowSchema() {
+ return new OutputSchema(
+ new RowTypeInfo(
+ new TypeInformation<?>[] {
+ BasicTypeInfo.STRING_TYPE_INFO,
BasicTypeInfo.INT_TYPE_INFO
+ },
+ new String[] {"name", "age"}));
+ }
+
+ @Test
+ void rowSchemaOutputFillsEveryField() throws Exception {
+ Row row =
+ (Row)
+ ChatModelAction.generateStructuredOutput(
+
ChatFixtures.response("{\"name\":\"Ada\",\"age\":36}"),
+ rowSchema());
+ assertEquals("Ada", row.getField("name"));
+ assertEquals(36, row.getField("age"));
+ }
+
+ @Test
+ void rowSchemaOutputKeepsExplicitNull() throws Exception {
+ Row row =
+ (Row)
+ ChatModelAction.generateStructuredOutput(
+
ChatFixtures.response("{\"name\":\"Ada\",\"age\":null}"),
+ rowSchema());
+ assertNull(row.getField("age"));
+ }
+
+ @Test
+ void rowSchemaOutputRejectsMissingField() {
+ IllegalArgumentException error =
+ assertThrows(
+ IllegalArgumentException.class,
+ () ->
+
ChatModelAction.generateStructuredOutputWithReport(
+ reportingContext(),
+
ChatFixtures.response("{\"name\":\"Ada\"}"),
+ rowSchema()));
Review Comment:
Thanks, added. rowSchemaOutputRejectsMissingField now verifies
reportExecutionFailed is called with the PARSER entity and
MODEL_OUTPUT_PARSE_ERROR, the same way ChatModelActionRetryTest does.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]