代码拉取完成,页面将自动刷新
同步操作将从 openKylin/kylin-xunfei-nlp-engine 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright 2024 KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "servererror.h"
#include "util.h"
namespace {
const std::map<int, std::tuple<ai_engine::lm::EngineErrorCategory,
ai_engine::lm::NlpEngineErrorCode>>
nlpChatErrorCodeMap = {
{10000,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::FailedToAnswer}},
{10001,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::NoServerService}},
{10002,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::ServerNoResponse}},
{10003,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::InvalidParamType}},
{10004,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::InvalidParamType}},
{10005,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::InvalidParamType}},
{10006,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooManyRequest}},
{10007,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooFrequentRequest}},
{10008,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooManyRequest}},
{10009,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::FailedToConnectServer}},
{10010,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::ServerNoResponse}},
{10011,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::ServerNoResponse}},
{10012,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::ServerNoResponse}},
{10013,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::InvalidWords}},
{10014,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::InvalidWords}},
{10015,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::Unauthorized}},
{10016,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::Unauthorized}},
{10017,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::NoServerService}},
{10019,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::InvalidWords}},
{10110,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::NoServerService}},
{10163,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::InvalidParamType}},
{10222,
{ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::ServerNoResponse}},
{10907,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooManyData}},
{11200,
{ai_engine::lm::EngineErrorCategory::Initialization,
ai_engine::lm::NlpEngineErrorCode::Unauthorized}},
{11201,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooManyRequest}},
{11202,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooFrequentRequest}},
{11203,
{ai_engine::lm::EngineErrorCategory::InputError,
ai_engine::lm::NlpEngineErrorCode::TooFrequentRequest}}};
};
int xunfei_nlp_server_error::parseErrorCode(const std::string &result) {
Json::Value obj = xunfei_nlp_util::formatJsonFromString(result);
if (!obj.isObject() || obj.isNull()) {
return 0;
}
if (obj.isMember("header") && obj["header"].isMember("code") &&
obj["header"].isMember("message")) {
return obj["header"]["code"].asInt();
}
return 0;
}
std::tuple<ai_engine::lm::EngineErrorCategory,
ai_engine::lm::NlpEngineErrorCode>
xunfei_nlp_server_error::errorCode2nlpResult(int errorCode) {
if (nlpChatErrorCodeMap.count(errorCode) > 0) {
return nlpChatErrorCodeMap.at(errorCode);
}
return std::make_tuple(ai_engine::lm::EngineErrorCategory::OutputError,
ai_engine::lm::NlpEngineErrorCode::FailedToAnswer);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。