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


##########
be/src/exprs/function/ai/ai_adapter.h:
##########
@@ -1170,34 +1257,54 @@ class GeminiAdapter : public AIAdapter {
         auto& allocator = doc.GetAllocator();
 
         /*{
-          "model": "models/gemini-embedding-001",
-          "content": {
-              "parts": [
-                {
-                  "text": "xxx"
-                }
-              ]
+          "requests": [
+            {
+              "model": "models/gemini-embedding-001",
+              "content": {
+                "parts": [
+                  {
+                    "text": "xxx"
+                  }
+                ]
+              },
+              "outputDimensionality": 1024
+            },
+            {
+              "model": "models/gemini-embedding-001",
+              "content": {
+                "parts": [
+                  {
+                    "text": "yyy"
+                  }
+                ]
+              },
+              "outputDimensionality": 1024
             }
-          "outputDimensionality": 1024
+          ]
         }*/
 
         // gemini requires the model format as `models/{model}`
         std::string model_name = _config.model_name;
         if (!model_name.starts_with("models/")) {
             model_name = "models/" + model_name;
         }
-        doc.AddMember("model", rapidjson::Value(model_name.c_str(), 
allocator), allocator);
-        add_dimension_params(doc, allocator);
 
-        rapidjson::Value content(rapidjson::kObjectType);
+        rapidjson::Value requests(rapidjson::kArrayType);
         for (const auto& input : inputs) {
+            rapidjson::Value request(rapidjson::kObjectType);
+            request.AddMember("model", rapidjson::Value(model_name.c_str(), 
allocator), allocator);
+            add_dimension_params(request, allocator);
+
+            rapidjson::Value content(rapidjson::kObjectType);
             rapidjson::Value parts(rapidjson::kArrayType);
             rapidjson::Value part(rapidjson::kObjectType);
             part.AddMember("text", rapidjson::Value(input.c_str(), allocator), 
allocator);
             parts.PushBack(part, allocator);
             content.AddMember("parts", parts, allocator);
+            request.AddMember("content", content, allocator);
+            requests.PushBack(request, allocator);
         }
-        doc.AddMember("content", content, allocator);
+        doc.AddMember("requests", requests, allocator);
 

Review Comment:
   This changes Gemini text embeddings from the old single-request shape (`{ 
"model": ..., "content": ... }`) to a batched `requests` envelope, but the PR 
does not update endpoint handling at all. In FE we still accept generic Gemini 
endpoints like `...:generateContent` (`AIResourceTest` uses that shape), and 
unlike OpenAI we do not normalize Gemini endpoints here. As a result, an 
existing Gemini EMBED resource can start sending an incompatible payload to the 
same endpoint after this patch, which is a functional regression rather than 
just a performance change.
   
   Please either keep backward-compatible request formatting for the current 
endpoint, or add explicit endpoint migration/normalization plus coverage that 
proves EMBED still works with the configured Gemini endpoint variants.



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