github-actions[bot] commented on code in PR #69302:
URL: https://github.com/apache/doris/pull/69302#discussion_r4332718912


##########
be/src/exprs/function/ai/ai_adapter.h:
##########
@@ -949,16 +1050,64 @@ class OpenAIAdapter : public VoyageAIAdapter {
             doc.AddMember("messages", messages, allocator);
         }
 
-        rapidjson::StringBuffer buffer;
-        rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
-        doc.Accept(writer);
-        request_body = buffer.GetString();
+        if (structured_batch) {
+            // These complete format fragments are compile-time constants. 
RawValue writes
+            // them unchanged on every request; no schema construction or 
parsing is needed.
+            /* {
+              "type": "json_schema", "name": "ai_batch_result", "strict": true,
+              "schema": {
+                  "type": "object",
+                  "properties": {"results": {"type": "array", "items": 
{"type": "string"}}},
+                  "required": ["results"],
+                  "additionalProperties": false
+                }
+            } */
+            static constexpr std::string_view responses_format =
+                    
R"({"type":"json_schema","name":"ai_batch_result","strict":true,"schema":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}}},"required":["results"],"additionalProperties":false}})";
+            /* {
+              "type": "json_schema",
+              "json_schema": {
+                "name": "ai_batch_result", "strict": true,
+                "schema": {
+                  "type": "object",
+                  "properties": {"results": {"type": "array", "items": 
{"type": "string"}}},
+                  "required": ["results"],
+                  "additionalProperties": false
+                }
+              }
+            } */
+            static constexpr std::string_view chat_format =
+                    
R"({"type":"json_schema","json_schema":{"name":"ai_batch_result","strict":true,"schema":{"type":"object","properties":{"results":{"type":"array","items":{"type":"string"}}},"required":["results"],"additionalProperties":false}}})";
+            if (_config.endpoint.ends_with("responses")) {
+                append_result_format(doc, request_body, "format", 
responses_format, "text");

Review Comment:
   [P1] Gate the Responses schema for MiniMax resources
   
   `MinimaxAdapter` inherits this Responses branch. An existing MINIMAX 
resource at `https://api.minimax.io/v1/responses`, for example using 
`MiniMax-M3.1-Flash`, now sends `text.format.type=json_schema` because the new 
property defaults to true. MiniMax's [published Responses request 
schema](https://platform.minimax.io/docs/api-reference/responses-create.md) 
restricts `CreateResponseReq.text.format.type` to the single value `text`; the 
generated request therefore violates that endpoint's allowed format values. 
Please select format constraints by provider/endpoint and keep MiniMax 
Responses on prompt-only batching when schema output is unsupported. This is a 
separate Responses endpoint instance from the existing Qwen Chat thread at line 
1084, and changing Chat's schema/object selection does not cover this branch.



##########
be/src/exprs/function/ai/ai_functions.h:
##########
@@ -288,7 +307,7 @@ class AIFunction : public IFunction {
                 statistics->record_parse(MonotonicNanos() - parse_start, 
parse_failed);
             }
         });
-        RETURN_IF_ERROR(adapter->parse_response(response, parsed_response));
+        RETURN_IF_ERROR(adapter->parse_batch_response(response, 
parsed_response));

Review Comment:
   [P2] Migrate the separate profile regression HTTP fixture
   
   `regression-test/suites/ai_p0/test_ai_profile.groovy:61` still builds scalar 
content with `JsonOutput.toJson(inputs.collect { "ok" })`, yielding a bare 
array such as `["ok"]`. Its resources use OPENAI, so the first `AI_GENERATE` 
query at line 171 now reaches this call and fails with `Invalid structured 
batch result: expected results array` after the initial HTTP retry, before the 
profile checks can run. This is a different fixture from the BE unit-test 
fixture in the existing thread, which this PR already fixes. Wrap the profile 
fixture's scalar/missing/recursive results as `[results: inputs.collect { "ok" 
}]`, while preserving the aggregate endpoint's plain-text response.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to