Преглед изворни кода

新增模型预测高性能版本

sdk-team пре 3 година
родитељ
комит
5e93a9b21f

+ 1 - 1
VERSION

@@ -1 +1 @@
-1.36.1628
+1.36.1629

+ 4 - 0
nlp-automl/CMakeLists.txt

@@ -29,6 +29,8 @@ set(nlp-automl_public_header_model
 	include/alibabacloud/nlp-automl/model/GetAsyncPredictResult.h
 	include/alibabacloud/nlp-automl/model/GetPredictResultRequest.h
 	include/alibabacloud/nlp-automl/model/GetPredictResultResult.h
+	include/alibabacloud/nlp-automl/model/GetPredictResultHighRequest.h
+	include/alibabacloud/nlp-automl/model/GetPredictResultHighResult.h
 	include/alibabacloud/nlp-automl/model/RunPreTrainServiceRequest.h
 	include/alibabacloud/nlp-automl/model/RunPreTrainServiceResult.h
 	include/alibabacloud/nlp-automl/model/RunPreTrainServiceNewRequest.h
@@ -44,6 +46,8 @@ set(nlp-automl_src
 	src/model/GetAsyncPredictResult.cc
 	src/model/GetPredictResultRequest.cc
 	src/model/GetPredictResultResult.cc
+	src/model/GetPredictResultHighRequest.cc
+	src/model/GetPredictResultHighResult.cc
 	src/model/RunPreTrainServiceRequest.cc
 	src/model/RunPreTrainServiceResult.cc
 	src/model/RunPreTrainServiceNewRequest.cc

+ 8 - 0
nlp-automl/include/alibabacloud/nlp-automl/Nlp_automlClient.h

@@ -30,6 +30,8 @@
 #include "model/GetAsyncPredictResult.h"
 #include "model/GetPredictResultRequest.h"
 #include "model/GetPredictResultResult.h"
+#include "model/GetPredictResultHighRequest.h"
+#include "model/GetPredictResultHighResult.h"
 #include "model/RunPreTrainServiceRequest.h"
 #include "model/RunPreTrainServiceResult.h"
 #include "model/RunPreTrainServiceNewRequest.h"
@@ -55,6 +57,9 @@ namespace AlibabaCloud
 			typedef Outcome<Error, Model::GetPredictResultResult> GetPredictResultOutcome;
 			typedef std::future<GetPredictResultOutcome> GetPredictResultOutcomeCallable;
 			typedef std::function<void(const Nlp_automlClient*, const Model::GetPredictResultRequest&, const GetPredictResultOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetPredictResultAsyncHandler;
+			typedef Outcome<Error, Model::GetPredictResultHighResult> GetPredictResultHighOutcome;
+			typedef std::future<GetPredictResultHighOutcome> GetPredictResultHighOutcomeCallable;
+			typedef std::function<void(const Nlp_automlClient*, const Model::GetPredictResultHighRequest&, const GetPredictResultHighOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> GetPredictResultHighAsyncHandler;
 			typedef Outcome<Error, Model::RunPreTrainServiceResult> RunPreTrainServiceOutcome;
 			typedef std::future<RunPreTrainServiceOutcome> RunPreTrainServiceOutcomeCallable;
 			typedef std::function<void(const Nlp_automlClient*, const Model::RunPreTrainServiceRequest&, const RunPreTrainServiceOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RunPreTrainServiceAsyncHandler;
@@ -78,6 +83,9 @@ namespace AlibabaCloud
 			GetPredictResultOutcome getPredictResult(const Model::GetPredictResultRequest &request)const;
 			void getPredictResultAsync(const Model::GetPredictResultRequest& request, const GetPredictResultAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			GetPredictResultOutcomeCallable getPredictResultCallable(const Model::GetPredictResultRequest& request) const;
+			GetPredictResultHighOutcome getPredictResultHigh(const Model::GetPredictResultHighRequest &request)const;
+			void getPredictResultHighAsync(const Model::GetPredictResultHighRequest& request, const GetPredictResultHighAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
+			GetPredictResultHighOutcomeCallable getPredictResultHighCallable(const Model::GetPredictResultHighRequest& request) const;
 			RunPreTrainServiceOutcome runPreTrainService(const Model::RunPreTrainServiceRequest &request)const;
 			void runPreTrainServiceAsync(const Model::RunPreTrainServiceRequest& request, const RunPreTrainServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
 			RunPreTrainServiceOutcomeCallable runPreTrainServiceCallable(const Model::RunPreTrainServiceRequest& request) const;

+ 57 - 0
nlp-automl/include/alibabacloud/nlp-automl/model/GetPredictResultHighRequest.h

@@ -0,0 +1,57 @@
+/*
+ * Copyright 2009-2017 Alibaba Cloud All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHREQUEST_H_
+#define ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHREQUEST_H_
+
+#include <alibabacloud/nlp-automl/Nlp_automlExport.h>
+#include <alibabacloud/core/RpcServiceRequest.h>
+#include <string>
+#include <vector>
+#include <map>
+
+namespace AlibabaCloud {
+namespace Nlp_automl {
+namespace Model {
+class ALIBABACLOUD_NLP_AUTOML_EXPORT GetPredictResultHighRequest : public RpcServiceRequest {
+public:
+	GetPredictResultHighRequest();
+	~GetPredictResultHighRequest();
+	int getTopK() const;
+	void setTopK(int topK);
+	std::string getProduct() const;
+	void setProduct(const std::string &product);
+	int getModelId() const;
+	void setModelId(int modelId);
+	std::string getDetailTag() const;
+	void setDetailTag(const std::string &detailTag);
+	std::string getContent() const;
+	void setContent(const std::string &content);
+	std::string getModelVersion() const;
+	void setModelVersion(const std::string &modelVersion);
+
+private:
+	int topK_;
+	std::string product_;
+	int modelId_;
+	std::string detailTag_;
+	std::string content_;
+	std::string modelVersion_;
+};
+} // namespace Model
+} // namespace Nlp_automl
+} // namespace AlibabaCloud
+#endif // !ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHREQUEST_H_

+ 51 - 0
nlp-automl/include/alibabacloud/nlp-automl/model/GetPredictResultHighResult.h

@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009-2017 Alibaba Cloud All rights reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHRESULT_H_
+#define ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHRESULT_H_
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <alibabacloud/core/ServiceResult.h>
+#include <alibabacloud/nlp-automl/Nlp_automlExport.h>
+
+namespace AlibabaCloud
+{
+	namespace Nlp_automl
+	{
+		namespace Model
+		{
+			class ALIBABACLOUD_NLP_AUTOML_EXPORT GetPredictResultHighResult : public ServiceResult
+			{
+			public:
+
+
+				GetPredictResultHighResult();
+				explicit GetPredictResultHighResult(const std::string &payload);
+				~GetPredictResultHighResult();
+				std::string getContent()const;
+
+			protected:
+				void parse(const std::string &payload);
+			private:
+				std::string content_;
+
+			};
+		}
+	}
+}
+#endif // !ALIBABACLOUD_NLP_AUTOML_MODEL_GETPREDICTRESULTHIGHRESULT_H_

+ 36 - 0
nlp-automl/src/Nlp-automlClient.cc

@@ -195,6 +195,42 @@ Nlp_automlClient::GetPredictResultOutcomeCallable Nlp_automlClient::getPredictRe
 	return task->get_future();
 }
 
+Nlp_automlClient::GetPredictResultHighOutcome Nlp_automlClient::getPredictResultHigh(const GetPredictResultHighRequest &request) const
+{
+	auto endpointOutcome = endpointProvider_->getEndpoint();
+	if (!endpointOutcome.isSuccess())
+		return GetPredictResultHighOutcome(endpointOutcome.error());
+
+	auto outcome = makeRequest(endpointOutcome.result(), request);
+
+	if (outcome.isSuccess())
+		return GetPredictResultHighOutcome(GetPredictResultHighResult(outcome.result()));
+	else
+		return GetPredictResultHighOutcome(outcome.error());
+}
+
+void Nlp_automlClient::getPredictResultHighAsync(const GetPredictResultHighRequest& request, const GetPredictResultHighAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
+{
+	auto fn = [this, request, handler, context]()
+	{
+		handler(this, request, getPredictResultHigh(request), context);
+	};
+
+	asyncExecute(new Runnable(fn));
+}
+
+Nlp_automlClient::GetPredictResultHighOutcomeCallable Nlp_automlClient::getPredictResultHighCallable(const GetPredictResultHighRequest &request) const
+{
+	auto task = std::make_shared<std::packaged_task<GetPredictResultHighOutcome()>>(
+			[this, request]()
+			{
+			return this->getPredictResultHigh(request);
+			});
+
+	asyncExecute(new Runnable([task]() { (*task)(); }));
+	return task->get_future();
+}
+
 Nlp_automlClient::RunPreTrainServiceOutcome Nlp_automlClient::runPreTrainService(const RunPreTrainServiceRequest &request) const
 {
 	auto endpointOutcome = endpointProvider_->getEndpoint();

+ 81 - 0
nlp-automl/src/model/GetPredictResultHighRequest.cc

@@ -0,0 +1,81 @@
+/*
+ * Copyright 2009-2017 Alibaba Cloud All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <alibabacloud/nlp-automl/model/GetPredictResultHighRequest.h>
+
+using AlibabaCloud::Nlp_automl::Model::GetPredictResultHighRequest;
+
+GetPredictResultHighRequest::GetPredictResultHighRequest()
+    : RpcServiceRequest("nlp-automl", "2019-11-11", "GetPredictResultHigh") {
+  setMethod(HttpRequest::Method::Post);
+}
+
+GetPredictResultHighRequest::~GetPredictResultHighRequest() {}
+
+int GetPredictResultHighRequest::getTopK() const {
+  return topK_;
+}
+
+void GetPredictResultHighRequest::setTopK(int topK) {
+  topK_ = topK;
+  setBodyParameter(std::string("TopK"), std::to_string(topK));
+}
+
+std::string GetPredictResultHighRequest::getProduct() const {
+  return product_;
+}
+
+void GetPredictResultHighRequest::setProduct(const std::string &product) {
+  product_ = product;
+  setBodyParameter(std::string("Product"), product);
+}
+
+int GetPredictResultHighRequest::getModelId() const {
+  return modelId_;
+}
+
+void GetPredictResultHighRequest::setModelId(int modelId) {
+  modelId_ = modelId;
+  setBodyParameter(std::string("ModelId"), std::to_string(modelId));
+}
+
+std::string GetPredictResultHighRequest::getDetailTag() const {
+  return detailTag_;
+}
+
+void GetPredictResultHighRequest::setDetailTag(const std::string &detailTag) {
+  detailTag_ = detailTag;
+  setBodyParameter(std::string("DetailTag"), detailTag);
+}
+
+std::string GetPredictResultHighRequest::getContent() const {
+  return content_;
+}
+
+void GetPredictResultHighRequest::setContent(const std::string &content) {
+  content_ = content;
+  setBodyParameter(std::string("Content"), content);
+}
+
+std::string GetPredictResultHighRequest::getModelVersion() const {
+  return modelVersion_;
+}
+
+void GetPredictResultHighRequest::setModelVersion(const std::string &modelVersion) {
+  modelVersion_ = modelVersion;
+  setBodyParameter(std::string("ModelVersion"), modelVersion);
+}
+

+ 51 - 0
nlp-automl/src/model/GetPredictResultHighResult.cc

@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009-2017 Alibaba Cloud All rights reserved.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <alibabacloud/nlp-automl/model/GetPredictResultHighResult.h>
+#include <json/json.h>
+
+using namespace AlibabaCloud::Nlp_automl;
+using namespace AlibabaCloud::Nlp_automl::Model;
+
+GetPredictResultHighResult::GetPredictResultHighResult() :
+	ServiceResult()
+{}
+
+GetPredictResultHighResult::GetPredictResultHighResult(const std::string &payload) :
+	ServiceResult()
+{
+	parse(payload);
+}
+
+GetPredictResultHighResult::~GetPredictResultHighResult()
+{}
+
+void GetPredictResultHighResult::parse(const std::string &payload)
+{
+	Json::Reader reader;
+	Json::Value value;
+	reader.parse(payload, value);
+	setRequestId(value["RequestId"].asString());
+	if(!value["Content"].isNull())
+		content_ = value["Content"].asString();
+
+}
+
+std::string GetPredictResultHighResult::getContent()const
+{
+	return content_;
+}
+