@jsonstudio/llms 0.6.2125 → 0.6.2172
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.
- package/dist/conversion/compat/actions/deepseek-web-response.js +27 -3
- package/dist/conversion/compat/actions/strip-orphan-function-calls-tag.js +1 -1
- package/dist/conversion/hub/pipeline/stages/resp_process/resp_process_stage1_tool_governance/index.js +9 -3
- package/dist/conversion/hub/process/chat-process.js +15 -18
- package/dist/conversion/responses/responses-openai-bridge.js +13 -12
- package/dist/conversion/shared/bridge-message-utils.js +92 -39
- package/dist/router/virtual-router/classifier.js +29 -5
- package/dist/router/virtual-router/engine/routing-pools/index.js +111 -5
- package/dist/router/virtual-router/engine-selection/multimodal-capability.d.ts +3 -0
- package/dist/router/virtual-router/engine-selection/multimodal-capability.js +26 -0
- package/dist/router/virtual-router/engine-selection/route-utils.js +6 -2
- package/dist/router/virtual-router/engine-selection/selection-deps.d.ts +1 -0
- package/dist/router/virtual-router/engine-selection/tier-selection.js +2 -0
- package/dist/router/virtual-router/engine.d.ts +2 -0
- package/dist/router/virtual-router/engine.js +57 -14
- package/dist/router/virtual-router/features.js +12 -4
- package/dist/router/virtual-router/message-utils.d.ts +8 -0
- package/dist/router/virtual-router/message-utils.js +170 -45
- package/dist/router/virtual-router/token-counter.js +51 -10
- package/dist/router/virtual-router/types.d.ts +3 -0
- package/dist/servertool/clock/session-scope.d.ts +3 -0
- package/dist/servertool/clock/session-scope.js +52 -0
- package/dist/servertool/engine.js +68 -8
- package/dist/servertool/handlers/clock-auto.js +2 -8
- package/dist/servertool/handlers/clock.js +3 -9
- package/dist/servertool/handlers/stop-message-auto/blocked-report.d.ts +16 -0
- package/dist/servertool/handlers/stop-message-auto/blocked-report.js +349 -0
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.d.ts +23 -0
- package/dist/servertool/handlers/stop-message-auto/iflow-followup.js +503 -0
- package/dist/servertool/handlers/stop-message-auto/routing-state.d.ts +38 -0
- package/dist/servertool/handlers/stop-message-auto/routing-state.js +149 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.d.ts +67 -0
- package/dist/servertool/handlers/stop-message-auto/runtime-utils.js +387 -0
- package/dist/servertool/handlers/stop-message-auto.d.ts +1 -7
- package/dist/servertool/handlers/stop-message-auto.js +69 -971
- package/dist/servertool/handlers/web-search.js +117 -0
- package/package.json +1 -1
|
@@ -217,6 +217,10 @@ function isIflowWebSearchEngine(engine) {
|
|
|
217
217
|
const key = engine.providerKey.toLowerCase();
|
|
218
218
|
return key.startsWith('iflow.');
|
|
219
219
|
}
|
|
220
|
+
function isQwenWebSearchEngine(engine) {
|
|
221
|
+
const key = engine.providerKey.toLowerCase();
|
|
222
|
+
return key.startsWith('qwen.');
|
|
223
|
+
}
|
|
220
224
|
function normalizeResultCount(value) {
|
|
221
225
|
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
222
226
|
const normalized = Math.trunc(value);
|
|
@@ -250,6 +254,18 @@ async function executeWebSearchBackend(args) {
|
|
|
250
254
|
hits = backendResult.hits;
|
|
251
255
|
ok = backendResult.ok;
|
|
252
256
|
}
|
|
257
|
+
else if (isQwenWebSearchEngine(engine) && options.providerInvoker) {
|
|
258
|
+
const backendResult = await executeQwenWebSearchViaProvider({
|
|
259
|
+
options,
|
|
260
|
+
engine,
|
|
261
|
+
query,
|
|
262
|
+
count: args.resultCount,
|
|
263
|
+
requestSuffix
|
|
264
|
+
});
|
|
265
|
+
summary = backendResult.summary;
|
|
266
|
+
hits = backendResult.hits;
|
|
267
|
+
ok = backendResult.ok;
|
|
268
|
+
}
|
|
253
269
|
else if (options.reenterPipeline) {
|
|
254
270
|
const payload = buildWebSearchReenterPayload(engine, query, recency, args.resultCount);
|
|
255
271
|
const followup = await reenterServerToolBackend({
|
|
@@ -586,6 +602,107 @@ async function executeIflowWebSearchViaProvider(args) {
|
|
|
586
602
|
ok
|
|
587
603
|
};
|
|
588
604
|
}
|
|
605
|
+
async function executeQwenWebSearchViaProvider(args) {
|
|
606
|
+
const { options, engine, query, count, requestSuffix } = args;
|
|
607
|
+
if (!options.providerInvoker) {
|
|
608
|
+
return {
|
|
609
|
+
summary: '',
|
|
610
|
+
hits: [],
|
|
611
|
+
ok: false
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
const payload = {
|
|
615
|
+
data: {
|
|
616
|
+
model: engine.id,
|
|
617
|
+
uq: query,
|
|
618
|
+
page: 1,
|
|
619
|
+
rows: count
|
|
620
|
+
},
|
|
621
|
+
metadata: {
|
|
622
|
+
entryEndpoint: '/api/v1/indices/plugin/web_search',
|
|
623
|
+
qwenWebSearch: true,
|
|
624
|
+
routeName: 'web_search'
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
const backend = await options.providerInvoker({
|
|
628
|
+
providerKey: engine.providerKey,
|
|
629
|
+
providerType: undefined,
|
|
630
|
+
modelId: undefined,
|
|
631
|
+
providerProtocol: options.providerProtocol,
|
|
632
|
+
payload,
|
|
633
|
+
entryEndpoint: '/api/v1/indices/plugin/web_search',
|
|
634
|
+
requestId: `${options.requestId}${requestSuffix}`,
|
|
635
|
+
routeHint: 'web_search'
|
|
636
|
+
});
|
|
637
|
+
const providerResponse = backend.providerResponse && typeof backend.providerResponse === 'object'
|
|
638
|
+
? backend.providerResponse
|
|
639
|
+
: null;
|
|
640
|
+
if (!providerResponse) {
|
|
641
|
+
return {
|
|
642
|
+
summary: '',
|
|
643
|
+
hits: [],
|
|
644
|
+
ok: false
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
const container = providerResponse;
|
|
648
|
+
const status = typeof container.status === 'number' ? container.status : undefined;
|
|
649
|
+
const message = typeof container.message === 'string' && container.message.trim()
|
|
650
|
+
? container.message.trim()
|
|
651
|
+
: typeof container.msg === 'string' && container.msg.trim()
|
|
652
|
+
? container.msg.trim()
|
|
653
|
+
: '';
|
|
654
|
+
if (status !== undefined && status !== 0) {
|
|
655
|
+
throw new Error(message || `qwen web_search failed with status=${status}`);
|
|
656
|
+
}
|
|
657
|
+
const dataNode = container.data && typeof container.data === 'object' && !Array.isArray(container.data)
|
|
658
|
+
? container.data
|
|
659
|
+
: undefined;
|
|
660
|
+
const rawDocs = Array.isArray(dataNode?.docs) ? dataNode?.docs : [];
|
|
661
|
+
const hits = [];
|
|
662
|
+
for (const item of rawDocs) {
|
|
663
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
664
|
+
continue;
|
|
665
|
+
const record = item;
|
|
666
|
+
const linkCandidate = typeof record.url === 'string' && record.url.trim()
|
|
667
|
+
? record.url.trim()
|
|
668
|
+
: typeof record.link === 'string' && record.link.trim()
|
|
669
|
+
? record.link.trim()
|
|
670
|
+
: '';
|
|
671
|
+
if (!linkCandidate)
|
|
672
|
+
continue;
|
|
673
|
+
const title = typeof record.title === 'string' && record.title.trim() ? record.title.trim() : undefined;
|
|
674
|
+
const content = typeof record.snippet === 'string' && record.snippet.trim()
|
|
675
|
+
? record.snippet.trim()
|
|
676
|
+
: typeof record.content === 'string' && record.content.trim()
|
|
677
|
+
? record.content.trim()
|
|
678
|
+
: undefined;
|
|
679
|
+
const publishDate = typeof record.timestamp_format === 'string' && record.timestamp_format.trim()
|
|
680
|
+
? record.timestamp_format.trim()
|
|
681
|
+
: typeof record.timestamp === 'string' && record.timestamp.trim()
|
|
682
|
+
? record.timestamp.trim()
|
|
683
|
+
: typeof record.time === 'string' && record.time.trim()
|
|
684
|
+
? record.time.trim()
|
|
685
|
+
: undefined;
|
|
686
|
+
const media = typeof record.source === 'string' && record.source.trim() ? record.source.trim() : undefined;
|
|
687
|
+
hits.push({
|
|
688
|
+
title,
|
|
689
|
+
link: linkCandidate,
|
|
690
|
+
content,
|
|
691
|
+
publish_date: publishDate,
|
|
692
|
+
media
|
|
693
|
+
});
|
|
694
|
+
if (hits.length >= count) {
|
|
695
|
+
break;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
const summary = message || (hits.length ? formatHitsSummary(hits) : '');
|
|
699
|
+
const ok = status === 0 || hits.length > 0;
|
|
700
|
+
return {
|
|
701
|
+
summary,
|
|
702
|
+
hits,
|
|
703
|
+
ok
|
|
704
|
+
};
|
|
705
|
+
}
|
|
589
706
|
function injectWebSearchToolResult(base, toolCall, engine, query, backendResult) {
|
|
590
707
|
const cloned = cloneJson(base);
|
|
591
708
|
const existingOutputs = Array.isArray(cloned.tool_outputs)
|