@bytenew/bn-applet-ui 1.1.71 → 1.1.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28731,6 +28731,13 @@ var es_array_sort = __webpack_require__(6910);
|
|
|
28731
28731
|
|
|
28732
28732
|
|
|
28733
28733
|
|
|
28734
|
+
|
|
28735
|
+
|
|
28736
|
+
|
|
28737
|
+
|
|
28738
|
+
|
|
28739
|
+
|
|
28740
|
+
|
|
28734
28741
|
|
|
28735
28742
|
|
|
28736
28743
|
|
|
@@ -29977,28 +29984,117 @@ function findParsedRegionConflict(parse, originalAddress) {
|
|
|
29977
29984
|
return '';
|
|
29978
29985
|
}
|
|
29979
29986
|
|
|
29987
|
+
/**
|
|
29988
|
+
* 本地识别错误时,使用原生 fetch 调用大模型接口重新识别
|
|
29989
|
+
* GET /v2/project/column/addressBychat?contents={待识别文本}
|
|
29990
|
+
* 接口返回 data.content 为大模型识别结果的 JSON 字符串(name/mobile/tel/province/city/area/street/addr)
|
|
29991
|
+
* @param {string} address 原始地址字符串
|
|
29992
|
+
* @returns {Promise<{aiResult?: object, failMsg?: string}|null>}
|
|
29993
|
+
* 成功返回 {aiResult}(content 解析后的对象);失败返回 {failMsg}(接口 msg);不支持 fetch 返回 null
|
|
29994
|
+
*/
|
|
29995
|
+
function parseAddressByChat(address) {
|
|
29996
|
+
// 小程序等不支持 fetch 的环境直接跳过,保留本地识别结果
|
|
29997
|
+
if (typeof fetch !== 'function') {
|
|
29998
|
+
console.warn('当前环境不支持 fetch,无法调用大模型地址识别接口');
|
|
29999
|
+
return Promise.resolve(null);
|
|
30000
|
+
}
|
|
30001
|
+
var url = '/v2/project/column/addressBychat?contents=' + address;
|
|
30002
|
+
return fetch(url, {
|
|
30003
|
+
method: 'GET'
|
|
30004
|
+
}).then(function (r) {
|
|
30005
|
+
return r.json();
|
|
30006
|
+
}).then(function (res) {
|
|
30007
|
+
if (res && !res.code && res.data && res.data.content) {
|
|
30008
|
+
try {
|
|
30009
|
+
return {
|
|
30010
|
+
aiResult: JSON.parse(res.data.content)
|
|
30011
|
+
};
|
|
30012
|
+
} catch (e) {
|
|
30013
|
+
console.error('大模型识别结果解析失败:', res.data.content);
|
|
30014
|
+
return {
|
|
30015
|
+
failMsg: '识别结果解析失败'
|
|
30016
|
+
};
|
|
30017
|
+
}
|
|
30018
|
+
}
|
|
30019
|
+
// 接口失败(如未开通 address_aIautorecognition 功能):返回接口 msg
|
|
30020
|
+
return {
|
|
30021
|
+
failMsg: res ? res.msg : '请求失败'
|
|
30022
|
+
};
|
|
30023
|
+
})["catch"](function (error) {
|
|
30024
|
+
console.error('大模型地址识别接口调用失败:', error);
|
|
30025
|
+
return {
|
|
30026
|
+
failMsg: error && error.message ? error.message : '请求异常'
|
|
30027
|
+
};
|
|
30028
|
+
});
|
|
30029
|
+
}
|
|
30030
|
+
|
|
29980
30031
|
/**
|
|
29981
30032
|
* 自动识别地址信息,格式化为省市区街道和收件人等信息
|
|
29982
30033
|
* @param {string} address 原始地址字符串(可含空格、姓名、手机号等)
|
|
29983
30034
|
* @param {object} [sourceData] 组件 sourceData,用于四级地址等配置(extraInfo.isFourAddress)
|
|
29984
30035
|
* @param {object} [options] 可选配置
|
|
29985
30036
|
* @param {array} [options.areaList] 地址库原始数据,默认从全局 areaList 获取
|
|
29986
|
-
* @returns {{name: string, mobile: string, phone: string, zip_code: string, extensionNumber: string, province: string, city: string, area: string, street: string, addr: string, Abnormal?: boolean,
|
|
30037
|
+
* @returns {Promise<{name: string, mobile: string, phone: string, zip_code: string, extensionNumber: string, province: string, city: string, area: string, street: string, addr: string, Abnormal?: boolean, msg?: string}>}
|
|
30038
|
+
* 本地识别错误时会 await 大模型接口重新识别:
|
|
30039
|
+
* AI 识别成功则用其结果覆盖省市区等字段,msg 为「自动识别错误,已使用ai重新识别」;
|
|
30040
|
+
* AI 识别失败则保留原识别内容,msg 为「自动识别错误,ai识别结果+接口msg」
|
|
29987
30041
|
*/
|
|
29988
|
-
function addressParse(
|
|
29989
|
-
|
|
29990
|
-
|
|
29991
|
-
|
|
29992
|
-
|
|
29993
|
-
|
|
29994
|
-
|
|
29995
|
-
|
|
29996
|
-
|
|
29997
|
-
|
|
29998
|
-
|
|
29999
|
-
|
|
30000
|
-
|
|
30001
|
-
|
|
30042
|
+
function addressParse(_x, _x2) {
|
|
30043
|
+
return _addressParse.apply(this, arguments);
|
|
30044
|
+
}
|
|
30045
|
+
function _addressParse() {
|
|
30046
|
+
_addressParse = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(address, sourceData) {
|
|
30047
|
+
var options,
|
|
30048
|
+
list,
|
|
30049
|
+
cleanAddress,
|
|
30050
|
+
parse,
|
|
30051
|
+
conflictLevel,
|
|
30052
|
+
chatResult,
|
|
30053
|
+
aiResult,
|
|
30054
|
+
_args = arguments;
|
|
30055
|
+
return _regenerator().w(function (_context) {
|
|
30056
|
+
while (1) switch (_context.n) {
|
|
30057
|
+
case 0:
|
|
30058
|
+
options = _args.length > 2 && _args[2] !== undefined ? _args[2] : {};
|
|
30059
|
+
list = getGlobalAreaList(options);
|
|
30060
|
+
if (list) {
|
|
30061
|
+
parseArea(list);
|
|
30062
|
+
}
|
|
30063
|
+
cleanAddress = preprocessAddress(address);
|
|
30064
|
+
parse = parseAddressDetail(cleanAddress, sourceData || {}, address); // 识别完毕后校验:输入文本中有明确的省市区文字,但识别结果与之不一致时,调用大模型接口重新识别
|
|
30065
|
+
conflictLevel = findParsedRegionConflict(parse, address);
|
|
30066
|
+
if (!conflictLevel) {
|
|
30067
|
+
_context.n = 2;
|
|
30068
|
+
break;
|
|
30069
|
+
}
|
|
30070
|
+
// 先设置本地识别错误提示,AI 识别成功/失败后覆盖为对应提示
|
|
30071
|
+
parse.msg = '自动识别识别错误:识别出的' + conflictLevel + '与输入地址不一致,请检查或手动填写';
|
|
30072
|
+
_context.n = 1;
|
|
30073
|
+
return parseAddressByChat(address);
|
|
30074
|
+
case 1:
|
|
30075
|
+
chatResult = _context.v;
|
|
30076
|
+
if (chatResult && chatResult.aiResult) {
|
|
30077
|
+
aiResult = chatResult.aiResult;
|
|
30078
|
+
parse.name = aiResult.name || '';
|
|
30079
|
+
parse.mobile = aiResult.mobile || '';
|
|
30080
|
+
parse.phone = aiResult.tel || '';
|
|
30081
|
+
parse.province = aiResult.province || '';
|
|
30082
|
+
parse.city = aiResult.city || '';
|
|
30083
|
+
parse.area = aiResult.area || '';
|
|
30084
|
+
parse.street = aiResult.street || '';
|
|
30085
|
+
parse.addr = aiResult.addr || '';
|
|
30086
|
+
parse.Abnormal = false;
|
|
30087
|
+
parse.msg = '自动识别错误,已使用ai重新识别';
|
|
30088
|
+
} else if (chatResult && chatResult.failMsg) {
|
|
30089
|
+
// AI 识别失败:还用原来的识别内容,把接口返回的 msg 提示上来
|
|
30090
|
+
parse.msg = '自动识别错误,ai识别结果' + chatResult.failMsg;
|
|
30091
|
+
}
|
|
30092
|
+
case 2:
|
|
30093
|
+
return _context.a(2, parse);
|
|
30094
|
+
}
|
|
30095
|
+
}, _callee);
|
|
30096
|
+
}));
|
|
30097
|
+
return _addressParse.apply(this, arguments);
|
|
30002
30098
|
}
|
|
30003
30099
|
;// ../../packages/utils/rewriteAttachmentUrl.js
|
|
30004
30100
|
|