HappenLee commented on code in PR #55017:
URL: https://github.com/apache/doris/pull/55017#discussion_r2292976346


##########
be/src/vec/functions/llm/llm_adapter.h:
##########
@@ -50,11 +52,120 @@ class LLMAdapter {
     virtual Status parse_response(const std::string& response_body,
                                   std::vector<std::string>& results) const = 0;
 
+    virtual Status build_embedding_request(const std::vector<std::string>& 
inputs,
+                                           std::string& request_body) const {
+        return Status::NotSupported("{} does not support the Embed feature.", 
get_type());
+    }
+
+    virtual Status parse_embedding_response(const std::string& response_body,
+                                            std::vector<std::vector<float>>& 
results) const {
+        return Status::NotSupported("{} does not support the Embed feature.", 
get_type());
+    }
+
     // Get the adapter type identifier
     virtual std::string get_type() const = 0;
 
 protected:
     TLLMResource _config;
+
+    // return true if the model support dimension parameter
+    virtual bool supports_dimension_param(const std::string& model_name) const 
{ return false; }
+
+    // Different providers may have different dimension parameter names.
+    virtual std::string get_dimension_param_name() const { return 
"dimensions"; }
+
+    virtual void add_dimension_params(rapidjson::Value& doc,
+                                      rapidjson::Document::AllocatorType& 
allocator) const {
+        if (_config.dimensions != -1 && 
supports_dimension_param(_config.model_name)) {
+            std::string param_name = get_dimension_param_name();
+            rapidjson::Value name(param_name.c_str(), allocator);
+            doc.AddMember(name, _config.dimensions, allocator);
+        }
+    }
+};
+
+// Most LLM-providers' Embedding formats are based on VoyageAI.
+class VoyageAIAdapter : public LLMAdapter {
+public:
+    std::string get_type() const override { return "voyageai"; }

Review Comment:
   type should use `enum class`, not `std::string`



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