linrrzqqq commented on code in PR #71438:
URL: https://github.com/apache/doris/pull/71438#discussion_r4811357729


##########
be/src/exprs/function/ai/ai_adapter.h:
##########
@@ -1357,55 +1379,25 @@ class QwenAdapter : public OpenAIAdapter {
             const std::vector<std::string>& /*media_content_types*/,
             std::string& request_body) const override {
         RETURN_IF_ERROR(validate_multimodal_embedding_inputs(
-                "QWEN", media_types, media_urls, {MultimodalType::IMAGE, 
MultimodalType::VIDEO}));
-
-        rapidjson::Document doc;
-        doc.SetObject();
-        auto& allocator = doc.GetAllocator();
-
-        /*{
-            "model": "tongyi-embedding-vision-plus",
-            "input": {
-              "contents": [
-                {"image": "<url>"},
-                {"video": "<url>"}
-              ]
-            }
-            "parameters": {
-              "dimension": 512
-            }
-        }*/
-        doc.AddMember("model", rapidjson::Value(_config.model_name.c_str(), 
allocator), allocator);
-        rapidjson::Value input(rapidjson::kObjectType);
-        rapidjson::Value contents(rapidjson::kArrayType);
+                "QWEN", media_types, media_urls,
+                {MultimodalType::IMAGE, MultimodalType::VIDEO, 
MultimodalType::TEXT}));
 
+        std::vector<std::vector<MultimodalInputItem>> rows;
+        rows.reserve(media_urls.size());
         for (size_t i = 0; i < media_urls.size(); ++i) {
-            rapidjson::Value media_item(rapidjson::kObjectType);
-            if (media_types[i] == MultimodalType::IMAGE) {
-                media_item.AddMember("image", 
rapidjson::Value(media_urls[i].c_str(), allocator),
-                                     allocator);
-            } else {
-                media_item.AddMember("video", 
rapidjson::Value(media_urls[i].c_str(), allocator),
-                                     allocator);
-            }
-            contents.PushBack(media_item, allocator);
+            rows.push_back({{media_types[i], media_urls[i], {}}});
         }
+        return _build_qwen_multimodal_payload(rows, false /* reject_duplicate 
*/, request_body);
+    }
 
-        input.AddMember("contents", contents, allocator);
-        doc.AddMember("input", input, allocator);
-        if (_config.dimensions != -1 && 
supports_dimension_param(_config.model_name)) {
-            rapidjson::Value parameters(rapidjson::kObjectType);
-            std::string param_name = get_dimension_param_name();
-            rapidjson::Value dimension_name(param_name.c_str(), allocator);
-            parameters.AddMember(dimension_name, _config.dimensions, 
allocator);
-            doc.AddMember("parameters", parameters, allocator);
+    Status build_fused_multimodal_embedding_request(
+            const std::vector<std::vector<MultimodalInputItem>>& fused_inputs,
+            std::string& request_body) const override {
+        if (fused_inputs.empty()) {
+            return Status::InvalidArgument("QWEN fused multimodal embed inputs 
can not be empty");
         }
-
-        rapidjson::StringBuffer buffer;
-        rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
-        doc.Accept(writer);
-        request_body = buffer.GetString();
-        return Status::OK();
+        return _build_qwen_multimodal_payload(fused_inputs, true /* 
reject_duplicate */,

Review Comment:
   不用加 enable_fusion, 已经在 description 补充相关前提验证信息



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