Add pre train service api.
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
2020-04-15 Version: 1.36.358
|
||||
- Add pre train service api.
|
||||
|
||||
2020-04-15 Version: 1.36.357
|
||||
- CreateNode API add return NodeId.
|
||||
|
||||
|
||||
@@ -28,7 +28,9 @@ set(nlp-automl_public_header_model
|
||||
include/alibabacloud/nlp-automl/model/GetPredictResultRequest.h
|
||||
include/alibabacloud/nlp-automl/model/GetPredictResultResult.h
|
||||
include/alibabacloud/nlp-automl/model/RunContactReviewRequest.h
|
||||
include/alibabacloud/nlp-automl/model/RunContactReviewResult.h )
|
||||
include/alibabacloud/nlp-automl/model/RunContactReviewResult.h
|
||||
include/alibabacloud/nlp-automl/model/RunPreTrainServiceRequest.h
|
||||
include/alibabacloud/nlp-automl/model/RunPreTrainServiceResult.h )
|
||||
|
||||
set(nlp-automl_src
|
||||
src/Nlp-automlClient.cc
|
||||
@@ -39,7 +41,9 @@ set(nlp-automl_src
|
||||
src/model/GetPredictResultRequest.cc
|
||||
src/model/GetPredictResultResult.cc
|
||||
src/model/RunContactReviewRequest.cc
|
||||
src/model/RunContactReviewResult.cc )
|
||||
src/model/RunContactReviewResult.cc
|
||||
src/model/RunPreTrainServiceRequest.cc
|
||||
src/model/RunPreTrainServiceResult.cc )
|
||||
|
||||
add_library(nlp-automl ${LIB_TYPE}
|
||||
${nlp-automl_public_header}
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "model/GetPredictResultResult.h"
|
||||
#include "model/RunContactReviewRequest.h"
|
||||
#include "model/RunContactReviewResult.h"
|
||||
#include "model/RunPreTrainServiceRequest.h"
|
||||
#include "model/RunPreTrainServiceResult.h"
|
||||
|
||||
|
||||
namespace AlibabaCloud
|
||||
@@ -51,6 +53,9 @@ namespace AlibabaCloud
|
||||
typedef Outcome<Error, Model::RunContactReviewResult> RunContactReviewOutcome;
|
||||
typedef std::future<RunContactReviewOutcome> RunContactReviewOutcomeCallable;
|
||||
typedef std::function<void(const Nlp_automlClient*, const Model::RunContactReviewRequest&, const RunContactReviewOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> RunContactReviewAsyncHandler;
|
||||
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;
|
||||
|
||||
Nlp_automlClient(const Credentials &credentials, const ClientConfiguration &configuration);
|
||||
Nlp_automlClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
|
||||
@@ -68,6 +73,9 @@ namespace AlibabaCloud
|
||||
RunContactReviewOutcome runContactReview(const Model::RunContactReviewRequest &request)const;
|
||||
void runContactReviewAsync(const Model::RunContactReviewRequest& request, const RunContactReviewAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
|
||||
RunContactReviewOutcomeCallable runContactReviewCallable(const Model::RunContactReviewRequest& 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;
|
||||
|
||||
private:
|
||||
std::shared_ptr<EndpointProvider> endpointProvider_;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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_RUNPRETRAINSERVICEREQUEST_H_
|
||||
#define ALIBABACLOUD_NLP_AUTOML_MODEL_RUNPRETRAINSERVICEREQUEST_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <alibabacloud/core/RpcServiceRequest.h>
|
||||
#include <alibabacloud/nlp-automl/Nlp_automlExport.h>
|
||||
|
||||
namespace AlibabaCloud
|
||||
{
|
||||
namespace Nlp_automl
|
||||
{
|
||||
namespace Model
|
||||
{
|
||||
class ALIBABACLOUD_NLP_AUTOML_EXPORT RunPreTrainServiceRequest : public RpcServiceRequest
|
||||
{
|
||||
|
||||
public:
|
||||
RunPreTrainServiceRequest();
|
||||
~RunPreTrainServiceRequest();
|
||||
|
||||
std::string getPredictContent()const;
|
||||
void setPredictContent(const std::string& predictContent);
|
||||
std::string getServiceVersion()const;
|
||||
void setServiceVersion(const std::string& serviceVersion);
|
||||
std::string getServiceName()const;
|
||||
void setServiceName(const std::string& serviceName);
|
||||
|
||||
private:
|
||||
std::string predictContent_;
|
||||
std::string serviceVersion_;
|
||||
std::string serviceName_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_NLP_AUTOML_MODEL_RUNPRETRAINSERVICEREQUEST_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_RUNPRETRAINSERVICERESULT_H_
|
||||
#define ALIBABACLOUD_NLP_AUTOML_MODEL_RUNPRETRAINSERVICERESULT_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 RunPreTrainServiceResult : public ServiceResult
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
RunPreTrainServiceResult();
|
||||
explicit RunPreTrainServiceResult(const std::string &payload);
|
||||
~RunPreTrainServiceResult();
|
||||
std::string getPredictResult()const;
|
||||
|
||||
protected:
|
||||
void parse(const std::string &payload);
|
||||
private:
|
||||
std::string predictResult_;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !ALIBABACLOUD_NLP_AUTOML_MODEL_RUNPRETRAINSERVICERESULT_H_
|
||||
@@ -195,3 +195,39 @@ Nlp_automlClient::RunContactReviewOutcomeCallable Nlp_automlClient::runContactRe
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
Nlp_automlClient::RunPreTrainServiceOutcome Nlp_automlClient::runPreTrainService(const RunPreTrainServiceRequest &request) const
|
||||
{
|
||||
auto endpointOutcome = endpointProvider_->getEndpoint();
|
||||
if (!endpointOutcome.isSuccess())
|
||||
return RunPreTrainServiceOutcome(endpointOutcome.error());
|
||||
|
||||
auto outcome = makeRequest(endpointOutcome.result(), request);
|
||||
|
||||
if (outcome.isSuccess())
|
||||
return RunPreTrainServiceOutcome(RunPreTrainServiceResult(outcome.result()));
|
||||
else
|
||||
return RunPreTrainServiceOutcome(outcome.error());
|
||||
}
|
||||
|
||||
void Nlp_automlClient::runPreTrainServiceAsync(const RunPreTrainServiceRequest& request, const RunPreTrainServiceAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context) const
|
||||
{
|
||||
auto fn = [this, request, handler, context]()
|
||||
{
|
||||
handler(this, request, runPreTrainService(request), context);
|
||||
};
|
||||
|
||||
asyncExecute(new Runnable(fn));
|
||||
}
|
||||
|
||||
Nlp_automlClient::RunPreTrainServiceOutcomeCallable Nlp_automlClient::runPreTrainServiceCallable(const RunPreTrainServiceRequest &request) const
|
||||
{
|
||||
auto task = std::make_shared<std::packaged_task<RunPreTrainServiceOutcome()>>(
|
||||
[this, request]()
|
||||
{
|
||||
return this->runPreTrainService(request);
|
||||
});
|
||||
|
||||
asyncExecute(new Runnable([task]() { (*task)(); }));
|
||||
return task->get_future();
|
||||
}
|
||||
|
||||
|
||||
62
nlp-automl/src/model/RunPreTrainServiceRequest.cc
Normal file
62
nlp-automl/src/model/RunPreTrainServiceRequest.cc
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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/RunPreTrainServiceRequest.h>
|
||||
|
||||
using AlibabaCloud::Nlp_automl::Model::RunPreTrainServiceRequest;
|
||||
|
||||
RunPreTrainServiceRequest::RunPreTrainServiceRequest() :
|
||||
RpcServiceRequest("nlp-automl", "2019-11-11", "RunPreTrainService")
|
||||
{
|
||||
setMethod(HttpRequest::Method::Post);
|
||||
}
|
||||
|
||||
RunPreTrainServiceRequest::~RunPreTrainServiceRequest()
|
||||
{}
|
||||
|
||||
std::string RunPreTrainServiceRequest::getPredictContent()const
|
||||
{
|
||||
return predictContent_;
|
||||
}
|
||||
|
||||
void RunPreTrainServiceRequest::setPredictContent(const std::string& predictContent)
|
||||
{
|
||||
predictContent_ = predictContent;
|
||||
setBodyParameter("PredictContent", predictContent);
|
||||
}
|
||||
|
||||
std::string RunPreTrainServiceRequest::getServiceVersion()const
|
||||
{
|
||||
return serviceVersion_;
|
||||
}
|
||||
|
||||
void RunPreTrainServiceRequest::setServiceVersion(const std::string& serviceVersion)
|
||||
{
|
||||
serviceVersion_ = serviceVersion;
|
||||
setBodyParameter("ServiceVersion", serviceVersion);
|
||||
}
|
||||
|
||||
std::string RunPreTrainServiceRequest::getServiceName()const
|
||||
{
|
||||
return serviceName_;
|
||||
}
|
||||
|
||||
void RunPreTrainServiceRequest::setServiceName(const std::string& serviceName)
|
||||
{
|
||||
serviceName_ = serviceName;
|
||||
setBodyParameter("ServiceName", serviceName);
|
||||
}
|
||||
|
||||
51
nlp-automl/src/model/RunPreTrainServiceResult.cc
Normal file
51
nlp-automl/src/model/RunPreTrainServiceResult.cc
Normal file
@@ -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/RunPreTrainServiceResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Nlp_automl;
|
||||
using namespace AlibabaCloud::Nlp_automl::Model;
|
||||
|
||||
RunPreTrainServiceResult::RunPreTrainServiceResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
RunPreTrainServiceResult::RunPreTrainServiceResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
RunPreTrainServiceResult::~RunPreTrainServiceResult()
|
||||
{}
|
||||
|
||||
void RunPreTrainServiceResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
setRequestId(value["RequestId"].asString());
|
||||
if(!value["PredictResult"].isNull())
|
||||
predictResult_ = value["PredictResult"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::string RunPreTrainServiceResult::getPredictResult()const
|
||||
{
|
||||
return predictResult_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user