@pedrofariasx/qwenproxy 1.2.1 → 1.2.2
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/README.md +3 -13
- package/package.json +1 -1
- package/src/api/server.ts +0 -2
- package/src/cache/memory-cache.ts +3 -2
- package/src/routes/chat.ts +123 -77
- package/src/routes/upload.ts +4 -4
- package/src/services/playwright.ts +1 -0
- package/src/services/qwen.ts +22 -13
- package/src/tools/parser.ts +10 -13
- package/src/utils/context-truncation.ts +0 -5
- package/src/linter/extraction-engine.ts +0 -165
- package/src/linter/index.ts +0 -258
- package/src/linter/repair-normalize.ts +0 -245
- package/src/linter/safety-gate.ts +0 -219
- package/src/linter/streaming-state-machine.ts +0 -252
- package/src/linter/structural-parser.ts +0 -352
- package/src/linter/types.ts +0 -74
- package/src/tests/linter.test.ts +0 -151
- package/src/tests/parallel.test.ts +0 -42
- package/src/tests/structureVerification.test.ts +0 -176
- package/src/tools/ast.ts +0 -15
- package/src/tools/coercion.ts +0 -67
- package/src/tools/confidence.ts +0 -48
- package/src/tools/detector.ts +0 -40
- package/src/tools/executor.ts +0 -236
- package/src/tools/pipeline.ts +0 -122
- package/src/tools/registry-runtime.ts +0 -34
- package/src/tools/repair.ts +0 -42
- package/src/tools/validator.ts +0 -33
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ToolDefinition } from './ast.js';
|
|
2
|
-
|
|
3
|
-
export class RequestToolRegistry {
|
|
4
|
-
private registry: Map<string, ToolDefinition>;
|
|
5
|
-
|
|
6
|
-
constructor(requestTools: unknown[] = []) {
|
|
7
|
-
this.registry = new Map();
|
|
8
|
-
for (const tool of requestTools) {
|
|
9
|
-
if (tool && typeof tool === 'object') {
|
|
10
|
-
const t = tool as any;
|
|
11
|
-
if (t.type === 'function' && t.function && typeof t.function === 'object') {
|
|
12
|
-
const fn = t.function;
|
|
13
|
-
this.registry.set(fn.name, {
|
|
14
|
-
name: fn.name,
|
|
15
|
-
description: fn.description,
|
|
16
|
-
schema: fn.parameters || {},
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
has(name: string): boolean {
|
|
24
|
-
return this.registry.has(name);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get(name: string): ToolDefinition | undefined {
|
|
28
|
-
return this.registry.get(name);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
list(): ToolDefinition[] {
|
|
32
|
-
return Array.from(this.registry.values());
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/tools/repair.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export interface RepairedTool {
|
|
2
|
-
name: string;
|
|
3
|
-
arguments: unknown;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function repairToolCall(extracted: Record<string, unknown>): RepairedTool | null {
|
|
7
|
-
if ('tool' in extracted && !('name' in extracted)) {
|
|
8
|
-
return {
|
|
9
|
-
name: String(extracted.tool),
|
|
10
|
-
arguments: extracted.arguments || {},
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if ('function' in extracted && typeof extracted.function === 'object' && extracted.function !== null) {
|
|
15
|
-
const fn = extracted.function as Record<string, unknown>;
|
|
16
|
-
if ('name' in fn) {
|
|
17
|
-
return {
|
|
18
|
-
name: String(fn.name),
|
|
19
|
-
arguments: fn.arguments || {},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if ('function_call' in extracted && typeof extracted.function_call === 'object' && extracted.function_call !== null) {
|
|
25
|
-
const fn = extracted.function_call as Record<string, unknown>;
|
|
26
|
-
if ('name' in fn) {
|
|
27
|
-
return {
|
|
28
|
-
name: String(fn.name),
|
|
29
|
-
arguments: fn.arguments || {},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if ('name' in extracted) {
|
|
35
|
-
return {
|
|
36
|
-
name: String(extracted.name),
|
|
37
|
-
arguments: extracted.arguments || {},
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
package/src/tools/validator.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import Ajv from 'ajv';
|
|
2
|
-
import type { ToolCallAST, ToolDefinition } from './ast.js';
|
|
3
|
-
|
|
4
|
-
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
5
|
-
|
|
6
|
-
export interface ValidationResult {
|
|
7
|
-
valid: boolean;
|
|
8
|
-
errors: any[] | null;
|
|
9
|
-
missingFields: string[];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function validateToolCall(ast: ToolCallAST, toolDef: ToolDefinition): ValidationResult {
|
|
13
|
-
const validate = ajv.compile(toolDef.schema);
|
|
14
|
-
const valid = validate(ast.arguments);
|
|
15
|
-
|
|
16
|
-
const missingFields: string[] = [];
|
|
17
|
-
if (toolDef.schema && typeof toolDef.schema === 'object' && 'required' in toolDef.schema) {
|
|
18
|
-
const required = (toolDef.schema as any).required;
|
|
19
|
-
if (Array.isArray(required)) {
|
|
20
|
-
for (const field of required) {
|
|
21
|
-
if (!(ast.arguments && typeof ast.arguments === 'object' && field in (ast.arguments as Record<string, unknown>))) {
|
|
22
|
-
missingFields.push(field);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
valid,
|
|
30
|
-
errors: validate.errors ?? null,
|
|
31
|
-
missingFields,
|
|
32
|
-
};
|
|
33
|
-
}
|