linrrzqqq commented on code in PR #69302:
URL: https://github.com/apache/doris/pull/69302#discussion_r4320845300
##########
be/src/exprs/function/ai/ai_adapter.h:
##########
@@ -869,16 +970,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");
+ } else if (_chat_json_schema) {
+ append_result_format(doc, request_body, "response_format",
chat_format);
Review Comment:
符合设计预期
--
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]