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:
127
chatbot/src/model/ChatRequest.cc
Normal file
127
chatbot/src/model/ChatRequest.cc
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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/chatbot/model/ChatRequest.h>
|
||||
|
||||
using AlibabaCloud::Chatbot::Model::ChatRequest;
|
||||
|
||||
ChatRequest::ChatRequest() :
|
||||
RpcServiceRequest("chatbot", "2017-10-11", "Chat")
|
||||
{}
|
||||
|
||||
ChatRequest::~ChatRequest()
|
||||
{}
|
||||
|
||||
std::string ChatRequest::getKnowledgeId()const
|
||||
{
|
||||
return knowledgeId_;
|
||||
}
|
||||
|
||||
void ChatRequest::setKnowledgeId(const std::string& knowledgeId)
|
||||
{
|
||||
knowledgeId_ = knowledgeId;
|
||||
setParameter("KnowledgeId", knowledgeId);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getSenderId()const
|
||||
{
|
||||
return senderId_;
|
||||
}
|
||||
|
||||
void ChatRequest::setSenderId(const std::string& senderId)
|
||||
{
|
||||
senderId_ = senderId;
|
||||
setParameter("SenderId", senderId);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getInstanceId()const
|
||||
{
|
||||
return instanceId_;
|
||||
}
|
||||
|
||||
void ChatRequest::setInstanceId(const std::string& instanceId)
|
||||
{
|
||||
instanceId_ = instanceId;
|
||||
setParameter("InstanceId", instanceId);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getSenderNick()const
|
||||
{
|
||||
return senderNick_;
|
||||
}
|
||||
|
||||
void ChatRequest::setSenderNick(const std::string& senderNick)
|
||||
{
|
||||
senderNick_ = senderNick;
|
||||
setParameter("SenderNick", senderNick);
|
||||
}
|
||||
|
||||
std::vector<std::string> ChatRequest::getPerspective()const
|
||||
{
|
||||
return perspective_;
|
||||
}
|
||||
|
||||
void ChatRequest::setPerspective(const std::vector<std::string>& perspective)
|
||||
{
|
||||
perspective_ = perspective;
|
||||
for(int i = 0; i!= perspective.size(); i++)
|
||||
setParameter("Perspective."+ std::to_string(i), perspective.at(i));
|
||||
}
|
||||
|
||||
std::string ChatRequest::getSessionId()const
|
||||
{
|
||||
return sessionId_;
|
||||
}
|
||||
|
||||
void ChatRequest::setSessionId(const std::string& sessionId)
|
||||
{
|
||||
sessionId_ = sessionId;
|
||||
setParameter("SessionId", sessionId);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getTag()const
|
||||
{
|
||||
return tag_;
|
||||
}
|
||||
|
||||
void ChatRequest::setTag(const std::string& tag)
|
||||
{
|
||||
tag_ = tag;
|
||||
setParameter("Tag", tag);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getUtterance()const
|
||||
{
|
||||
return utterance_;
|
||||
}
|
||||
|
||||
void ChatRequest::setUtterance(const std::string& utterance)
|
||||
{
|
||||
utterance_ = utterance;
|
||||
setParameter("Utterance", utterance);
|
||||
}
|
||||
|
||||
std::string ChatRequest::getAccessKeyId()const
|
||||
{
|
||||
return accessKeyId_;
|
||||
}
|
||||
|
||||
void ChatRequest::setAccessKeyId(const std::string& accessKeyId)
|
||||
{
|
||||
accessKeyId_ = accessKeyId;
|
||||
setParameter("AccessKeyId", accessKeyId);
|
||||
}
|
||||
|
||||
111
chatbot/src/model/ChatResult.cc
Normal file
111
chatbot/src/model/ChatResult.cc
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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/chatbot/model/ChatResult.h>
|
||||
#include <json/json.h>
|
||||
|
||||
using namespace AlibabaCloud::Chatbot;
|
||||
using namespace AlibabaCloud::Chatbot::Model;
|
||||
|
||||
ChatResult::ChatResult() :
|
||||
ServiceResult()
|
||||
{}
|
||||
|
||||
ChatResult::ChatResult(const std::string &payload) :
|
||||
ServiceResult()
|
||||
{
|
||||
parse(payload);
|
||||
}
|
||||
|
||||
ChatResult::~ChatResult()
|
||||
{}
|
||||
|
||||
void ChatResult::parse(const std::string &payload)
|
||||
{
|
||||
Json::Reader reader;
|
||||
Json::Value value;
|
||||
reader.parse(payload, value);
|
||||
|
||||
setRequestId(value["RequestId"].asString());
|
||||
auto allMessages = value["Messages"]["Message"];
|
||||
for (auto value : allMessages)
|
||||
{
|
||||
Message messagesObject;
|
||||
if(!value["Type"].isNull())
|
||||
messagesObject.type = value["Type"].asString();
|
||||
auto allRecommends = value["Recommends"]["Recommend"];
|
||||
for (auto value : allRecommends)
|
||||
{
|
||||
Message::Recommend recommendsObject;
|
||||
if(!value["KnowledgeId"].isNull())
|
||||
recommendsObject.knowledgeId = value["KnowledgeId"].asString();
|
||||
if(!value["Title"].isNull())
|
||||
recommendsObject.title = value["Title"].asString();
|
||||
if(!value["AnswerSource"].isNull())
|
||||
recommendsObject.answerSource = value["AnswerSource"].asString();
|
||||
if(!value["Summary"].isNull())
|
||||
recommendsObject.summary = value["Summary"].asString();
|
||||
if(!value["Content"].isNull())
|
||||
recommendsObject.content = value["Content"].asString();
|
||||
messagesObject.recommends.push_back(recommendsObject);
|
||||
}
|
||||
auto textNode = value["Text"];
|
||||
if(!textNode["Content"].isNull())
|
||||
messagesObject.text.content = textNode["Content"].asString();
|
||||
if(!textNode["AnswerSource"].isNull())
|
||||
messagesObject.text.answerSource = textNode["AnswerSource"].asString();
|
||||
auto knowledgeNode = value["Knowledge"];
|
||||
if(!knowledgeNode["Id"].isNull())
|
||||
messagesObject.knowledge.id = knowledgeNode["Id"].asString();
|
||||
if(!knowledgeNode["Title"].isNull())
|
||||
messagesObject.knowledge.title = knowledgeNode["Title"].asString();
|
||||
if(!knowledgeNode["Summary"].isNull())
|
||||
messagesObject.knowledge.summary = knowledgeNode["Summary"].asString();
|
||||
if(!knowledgeNode["Content"].isNull())
|
||||
messagesObject.knowledge.content = knowledgeNode["Content"].asString();
|
||||
if(!knowledgeNode["AnswerSource"].isNull())
|
||||
messagesObject.knowledge.answerSource = knowledgeNode["AnswerSource"].asString();
|
||||
messages_.push_back(messagesObject);
|
||||
}
|
||||
if(!value["SessionId"].isNull())
|
||||
sessionId_ = value["SessionId"].asString();
|
||||
if(!value["MessageId"].isNull())
|
||||
messageId_ = value["MessageId"].asString();
|
||||
if(!value["Tag"].isNull())
|
||||
tag_ = value["Tag"].asString();
|
||||
|
||||
}
|
||||
|
||||
std::vector<ChatResult::Message> ChatResult::getMessages()const
|
||||
{
|
||||
return messages_;
|
||||
}
|
||||
|
||||
std::string ChatResult::getTag()const
|
||||
{
|
||||
return tag_;
|
||||
}
|
||||
|
||||
std::string ChatResult::getSessionId()const
|
||||
{
|
||||
return sessionId_;
|
||||
}
|
||||
|
||||
std::string ChatResult::getMessageId()const
|
||||
{
|
||||
return messageId_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user