CHATBOT SDK Auto Released By yanke.yk,Version:1.19.0

Signed-off-by: haowei.yao <haowei.yao@alibaba-inc.com>
This commit is contained in:
haowei.yao
2018-07-05 14:35:10 +08:00
parent 364cab6ffa
commit 0880c7f722
11 changed files with 662 additions and 2 deletions

View File

@@ -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_CHATBOT_CHATBOTCLIENT_H_
#define ALIBABACLOUD_CHATBOT_CHATBOTCLIENT_H_
#include <future>
#include <alibabacloud/core/AsyncCallerContext.h>
#include <alibabacloud/core/EndpointProvider.h>
#include <alibabacloud/core/RpcServiceClient.h>
#include "ChatbotExport.h"
#include "model/ChatRequest.h"
#include "model/ChatResult.h"
namespace AlibabaCloud
{
namespace Chatbot
{
class ALIBABACLOUD_CHATBOT_EXPORT ChatbotClient : public RpcServiceClient
{
public:
typedef Outcome<Error, Model::ChatResult> ChatOutcome;
typedef std::future<ChatOutcome> ChatOutcomeCallable;
typedef std::function<void(const ChatbotClient*, const Model::ChatRequest&, const ChatOutcome&, const std::shared_ptr<const AsyncCallerContext>&)> ChatAsyncHandler;
ChatbotClient(const Credentials &credentials, const ClientConfiguration &configuration);
ChatbotClient(const std::shared_ptr<CredentialsProvider> &credentialsProvider, const ClientConfiguration &configuration);
ChatbotClient(const std::string &accessKeyId, const std::string &accessKeySecret, const ClientConfiguration &configuration);
~ChatbotClient();
ChatOutcome chat(const Model::ChatRequest &request)const;
void chatAsync(const Model::ChatRequest& request, const ChatAsyncHandler& handler, const std::shared_ptr<const AsyncCallerContext>& context = nullptr) const;
ChatOutcomeCallable chatCallable(const Model::ChatRequest& request) const;
private:
std::shared_ptr<EndpointProvider> endpointProvider_;
};
}
}
#endif // !ALIBABACLOUD_CHATBOT_CHATBOTCLIENT_H_

View File

@@ -0,0 +1,32 @@
/*
* 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_CHATBOT_CHATBOTEXPORT_H_
#define ALIBABACLOUD_CHATBOT_CHATBOTEXPORT_H_
#include <alibabacloud/core/Global.h>
#if defined(ALIBABACLOUD_SHARED)
# if defined(ALIBABACLOUD_CHATBOT_LIBRARY)
# define ALIBABACLOUD_CHATBOT_EXPORT ALIBABACLOUD_DECL_EXPORT
# else
# define ALIBABACLOUD_CHATBOT_EXPORT ALIBABACLOUD_DECL_IMPORT
# endif
#else
# define ALIBABACLOUD_CHATBOT_EXPORT
#endif
#endif // !ALIBABACLOUD_CHATBOT_CHATBOTEXPORT_H_

View File

@@ -0,0 +1,72 @@
/*
* 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_CHATBOT_MODEL_CHATREQUEST_H_
#define ALIBABACLOUD_CHATBOT_MODEL_CHATREQUEST_H_
#include <string>
#include <vector>
#include <alibabacloud/core/RpcServiceRequest.h>
#include <alibabacloud/chatbot/ChatbotExport.h>
namespace AlibabaCloud
{
namespace Chatbot
{
namespace Model
{
class ALIBABACLOUD_CHATBOT_EXPORT ChatRequest : public RpcServiceRequest
{
public:
ChatRequest();
~ChatRequest();
std::string getKnowledgeId()const;
void setKnowledgeId(const std::string& knowledgeId);
std::string getSenderId()const;
void setSenderId(const std::string& senderId);
std::string getInstanceId()const;
void setInstanceId(const std::string& instanceId);
std::string getSenderNick()const;
void setSenderNick(const std::string& senderNick);
std::vector<std::string> getPerspective()const;
void setPerspective(const std::vector<std::string>& perspective);
std::string getSessionId()const;
void setSessionId(const std::string& sessionId);
std::string getTag()const;
void setTag(const std::string& tag);
std::string getUtterance()const;
void setUtterance(const std::string& utterance);
std::string getAccessKeyId()const;
void setAccessKeyId(const std::string& accessKeyId);
private:
std::string knowledgeId_;
std::string senderId_;
std::string instanceId_;
std::string senderNick_;
std::vector<std::string> perspective_;
std::string sessionId_;
std::string tag_;
std::string utterance_;
std::string accessKeyId_;
};
}
}
}
#endif // !ALIBABACLOUD_CHATBOT_MODEL_CHATREQUEST_H_

View File

@@ -0,0 +1,85 @@
/*
* 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_CHATBOT_MODEL_CHATRESULT_H_
#define ALIBABACLOUD_CHATBOT_MODEL_CHATRESULT_H_
#include <string>
#include <vector>
#include <utility>
#include <alibabacloud/core/ServiceResult.h>
#include <alibabacloud/chatbot/ChatbotExport.h>
namespace AlibabaCloud
{
namespace Chatbot
{
namespace Model
{
class ALIBABACLOUD_CHATBOT_EXPORT ChatResult : public ServiceResult
{
public:
struct Message
{
struct Text
{
std::string content;
std::string answerSource;
};
struct Knowledge
{
std::string content;
std::string answerSource;
std::string title;
std::string summary;
std::string id;
};
struct Recommend
{
std::string answerSource;
std::string content;
std::string title;
std::string summary;
std::string knowledgeId;
};
std::string type;
Text text;
std::vector<Message::Recommend> recommends;
Knowledge knowledge;
};
ChatResult();
explicit ChatResult(const std::string &payload);
~ChatResult();
std::vector<Message> getMessages()const;
std::string getTag()const;
std::string getSessionId()const;
std::string getMessageId()const;
protected:
void parse(const std::string &payload);
private:
std::vector<Message> messages_;
std::string tag_;
std::string sessionId_;
std::string messageId_;
};
}
}
}
#endif // !ALIBABACLOUD_CHATBOT_MODEL_CHATRESULT_H_