@jsonstudio/rcc 0.89.524 → 0.89.552
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/build-info.js +2 -2
- package/dist/cli.js +53 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/auth/oauth-lifecycle.js +97 -24
- package/dist/providers/auth/oauth-lifecycle.js.map +1 -1
- package/dist/providers/core/runtime/base-provider.d.ts +2 -0
- package/dist/providers/core/runtime/base-provider.js +35 -1
- package/dist/providers/core/runtime/base-provider.js.map +1 -1
- package/dist/providers/core/runtime/http-request-executor.js +34 -0
- package/dist/providers/core/runtime/http-request-executor.js.map +1 -1
- package/dist/providers/core/runtime/http-transport-provider.js +23 -0
- package/dist/providers/core/runtime/http-transport-provider.js.map +1 -1
- package/dist/providers/core/runtime/iflow-http-provider.d.ts +4 -0
- package/dist/providers/core/runtime/iflow-http-provider.js +28 -0
- package/dist/providers/core/runtime/iflow-http-provider.js.map +1 -1
- package/dist/providers/core/runtime/rate-limit-manager.d.ts +30 -0
- package/dist/providers/core/runtime/rate-limit-manager.js +136 -0
- package/dist/providers/core/runtime/rate-limit-manager.js.map +1 -0
- package/dist/providers/core/utils/provider-error-reporter.js +31 -5
- package/dist/providers/core/utils/provider-error-reporter.js.map +1 -1
- package/dist/providers/core/utils/provider-type-utils.js +1 -1
- package/dist/providers/core/utils/provider-type-utils.js.map +1 -1
- package/dist/server/runtime/http-server/provider-utils.js +1 -1
- package/dist/server/runtime/http-server/provider-utils.js.map +1 -1
- package/dist/server/runtime/http-server/routes.js +10 -50
- package/dist/server/runtime/http-server/routes.js.map +1 -1
- package/dist/server/runtime/http-server/runtime-manager.js +15 -0
- package/dist/server/runtime/http-server/runtime-manager.js.map +1 -1
- package/dist/token-daemon/history-store.d.ts +75 -0
- package/dist/token-daemon/history-store.js +207 -0
- package/dist/token-daemon/history-store.js.map +1 -0
- package/dist/token-daemon/index.js +104 -10
- package/dist/token-daemon/index.js.map +1 -1
- package/dist/token-daemon/token-daemon.d.ts +3 -0
- package/dist/token-daemon/token-daemon.js +115 -10
- package/dist/token-daemon/token-daemon.js.map +1 -1
- package/dist/token-portal/local-token-portal.d.ts +1 -0
- package/dist/token-portal/local-token-portal.js +89 -0
- package/dist/token-portal/local-token-portal.js.map +1 -0
- package/dist/token-portal/render.d.ts +10 -0
- package/dist/token-portal/render.js +56 -0
- package/dist/token-portal/render.js.map +1 -0
- package/package.json +2 -1
- package/scripts/test-iflow-web-search.mjs +141 -0
- package/scripts/test-iflow.mjs +93 -1
package/scripts/test-iflow.mjs
CHANGED
|
@@ -32,7 +32,8 @@ const args = Object.fromEntries(process.argv.slice(2).map(kv => {
|
|
|
32
32
|
const MODE = String(args.mode || process.env.MODE || 'proxy');
|
|
33
33
|
const RC_BASE = String(process.env.RC_BASE || 'http://127.0.0.1:5506').replace(/\/$/, '');
|
|
34
34
|
const RC_ENDPOINT = String(args.endpoint || process.env.RC_ENDPOINT || '/v1/chat/completions');
|
|
35
|
-
|
|
35
|
+
// 默认模型更新为 iFlow-ROME-30BA3B,除非通过 IFLOW_MODEL 显式覆盖。
|
|
36
|
+
const IFLOW_MODEL = String(process.env.IFLOW_MODEL || 'iFlow-ROME-30BA3B');
|
|
36
37
|
const TEXT = String(process.env.TEXT || 'hello from RouteCodex test');
|
|
37
38
|
const RUN_TOOLS = !!args.tools;
|
|
38
39
|
const CONFIG_PATH = expandHome(String(process.env.CONFIG || args.config || path.join(os.homedir(), '.routecodex', 'config', 'v2', 'iflow-only.json')));
|
|
@@ -170,6 +171,93 @@ async function requestUpstreamChat(oauth, token) {
|
|
|
170
171
|
try { console.log(JSON.stringify(JSON.parse(body), null, 2)); } catch { console.log(body); }
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
async function requestUpstreamWebSearch(oauth, token) {
|
|
175
|
+
const url = `${oauth.apiBase.replace(/\/$/, '')}/chat/completions`;
|
|
176
|
+
const payload = {
|
|
177
|
+
model: IFLOW_MODEL,
|
|
178
|
+
messages: [
|
|
179
|
+
{
|
|
180
|
+
role: 'system',
|
|
181
|
+
content: 'You are an up-to-date web search engine. Call the web_search tool to fetch current results, then answer based on the tool output.'
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
role: 'user',
|
|
185
|
+
content: `${TEXT}. 请先调用 web_search 工具检索相关信息,再根据搜索结果回答。`
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
tools: [
|
|
189
|
+
{
|
|
190
|
+
type: 'function',
|
|
191
|
+
function: {
|
|
192
|
+
name: 'web_search',
|
|
193
|
+
description: 'Perform web search over the public internet and return up-to-date results.',
|
|
194
|
+
parameters: {
|
|
195
|
+
type: 'object',
|
|
196
|
+
properties: {
|
|
197
|
+
query: {
|
|
198
|
+
type: 'string',
|
|
199
|
+
description: 'Search query string.'
|
|
200
|
+
},
|
|
201
|
+
recency: {
|
|
202
|
+
type: 'string',
|
|
203
|
+
description: 'Optional recency filter such as "day", "week", or "month".'
|
|
204
|
+
},
|
|
205
|
+
count: {
|
|
206
|
+
type: 'integer',
|
|
207
|
+
minimum: 1,
|
|
208
|
+
maximum: 50,
|
|
209
|
+
description: 'Maximum number of search results to retrieve (1-50).'
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
required: ['query']
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
tool_choice: {
|
|
218
|
+
type: 'function',
|
|
219
|
+
function: {
|
|
220
|
+
name: 'web_search'
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
stream: false
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const res = await fetch(url, {
|
|
227
|
+
method: 'POST',
|
|
228
|
+
headers: {
|
|
229
|
+
'Authorization': `Bearer ${token.access_token}`,
|
|
230
|
+
'Content-Type': 'application/json'
|
|
231
|
+
},
|
|
232
|
+
body: JSON.stringify(payload)
|
|
233
|
+
});
|
|
234
|
+
const text = await res.text();
|
|
235
|
+
console.log(`[UPSTREAM][web_search] status=${res.status}`);
|
|
236
|
+
let json = null;
|
|
237
|
+
try {
|
|
238
|
+
json = JSON.parse(text);
|
|
239
|
+
console.log(JSON.stringify(json, null, 2));
|
|
240
|
+
} catch {
|
|
241
|
+
console.log(text);
|
|
242
|
+
throw new Error('iflow web_search returned non-JSON payload');
|
|
243
|
+
}
|
|
244
|
+
if (!res.ok) {
|
|
245
|
+
throw new Error(`iflow web_search failed: HTTP ${res.status}`);
|
|
246
|
+
}
|
|
247
|
+
const firstChoice = Array.isArray(json.choices) ? json.choices[0] : null;
|
|
248
|
+
const msg = firstChoice?.message || {};
|
|
249
|
+
const toolCalls = Array.isArray(msg.tool_calls) ? msg.tool_calls : [];
|
|
250
|
+
console.log(`[UPSTREAM][web_search] tool_calls=${toolCalls.length}`);
|
|
251
|
+
if (!toolCalls.length) {
|
|
252
|
+
console.warn('[UPSTREAM][web_search] no tool_calls returned, web_search tool may not be enabled for this model.');
|
|
253
|
+
} else {
|
|
254
|
+
const names = toolCalls
|
|
255
|
+
.map((tc) => (tc && tc.function && typeof tc.function.name === 'string' ? tc.function.name : ''))
|
|
256
|
+
.filter(Boolean);
|
|
257
|
+
console.log(`[UPSTREAM][web_search] tool names: ${names.join(', ')}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
173
261
|
async function requestProxyChat() {
|
|
174
262
|
const url = `${RC_BASE}${RC_ENDPOINT}`;
|
|
175
263
|
const payload = { model: IFLOW_MODEL, messages: [{ role: 'user', content: TEXT }], stream: false };
|
|
@@ -276,6 +364,10 @@ async function main() {
|
|
|
276
364
|
await requestUpstreamChat(oauth, token);
|
|
277
365
|
return;
|
|
278
366
|
}
|
|
367
|
+
if (MODE === 'websearch') {
|
|
368
|
+
await requestUpstreamWebSearch(oauth, token);
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
279
371
|
if (RUN_TOOLS) {
|
|
280
372
|
await requestProxyChat(); // warmup
|
|
281
373
|
await runResponsesToolLoop();
|