@node-llm/core 1.16.0 → 1.16.1
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/aliases.d.ts +747 -344
- package/dist/aliases.d.ts.map +1 -1
- package/dist/aliases.js +790 -387
- package/dist/aliases.json +132 -0
- package/dist/interceptors/InterceptorChain.d.ts +47 -0
- package/dist/interceptors/InterceptorChain.d.ts.map +1 -0
- package/dist/interceptors/InterceptorChain.js +63 -0
- package/dist/interceptors/examples.d.ts +19 -0
- package/dist/interceptors/examples.d.ts.map +1 -0
- package/dist/interceptors/examples.js +38 -0
- package/dist/models/models.d.ts +572 -0
- package/dist/models/models.d.ts.map +1 -0
- package/dist/models/models.js +15963 -0
- package/dist/models/models.json +24151 -13163
- package/dist/models/pricing.json +87 -0
- package/dist/utils/ThinkingNormalizer.d.ts +16 -0
- package/dist/utils/ThinkingNormalizer.d.ts.map +1 -0
- package/dist/utils/ThinkingNormalizer.js +30 -0
- package/dist/utils/sanitize.d.ts +21 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/dist/utils/sanitize.js +76 -0
- package/package.json +13 -10
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chatgpt-4o": {
|
|
3
|
+
"openai": "chatgpt-4o-latest",
|
|
4
|
+
"openrouter": "openai/chatgpt-4o-latest"
|
|
5
|
+
},
|
|
6
|
+
"claude-3-5-haiku": {
|
|
7
|
+
"anthropic": "claude-3-5-haiku-20241022",
|
|
8
|
+
"openrouter": "anthropic/claude-3.5-haiku",
|
|
9
|
+
"bedrock": "anthropic.claude-3-5-haiku-20241022-v1:0"
|
|
10
|
+
},
|
|
11
|
+
"claude-3-5-sonnet": {
|
|
12
|
+
"anthropic": "claude-3-5-sonnet-20240620",
|
|
13
|
+
"openrouter": "anthropic/claude-3.5-sonnet",
|
|
14
|
+
"bedrock": "anthropic.claude-3-5-sonnet-20240620-v1:0"
|
|
15
|
+
},
|
|
16
|
+
"claude-sonnet-4-5": {
|
|
17
|
+
"anthropic": "claude-sonnet-4-5-20250929"
|
|
18
|
+
},
|
|
19
|
+
"claude-sonnet-4": {
|
|
20
|
+
"anthropic": "claude-sonnet-4-20250514"
|
|
21
|
+
},
|
|
22
|
+
"claude-3-7-sonnet": {
|
|
23
|
+
"anthropic": "claude-3-7-sonnet-20250219",
|
|
24
|
+
"openrouter": "anthropic/claude-3.7-sonnet",
|
|
25
|
+
"bedrock": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
|
|
26
|
+
},
|
|
27
|
+
"claude-3-haiku": {
|
|
28
|
+
"anthropic": "claude-3-haiku-20240307",
|
|
29
|
+
"openrouter": "anthropic/claude-3-haiku",
|
|
30
|
+
"bedrock": "anthropic.claude-3-haiku-20240307-v1:0:200k"
|
|
31
|
+
},
|
|
32
|
+
"claude-3-opus": {
|
|
33
|
+
"anthropic": "claude-3-opus-20240229",
|
|
34
|
+
"openrouter": "anthropic/claude-3-opus",
|
|
35
|
+
"bedrock": "anthropic.claude-3-opus-20240229-v1:0:200k"
|
|
36
|
+
},
|
|
37
|
+
"claude-3-sonnet": {
|
|
38
|
+
"bedrock": "anthropic.claude-3-sonnet-20240229-v1:0"
|
|
39
|
+
},
|
|
40
|
+
"deepseek-chat": {
|
|
41
|
+
"deepseek": "deepseek-chat",
|
|
42
|
+
"openrouter": "deepseek/deepseek-chat"
|
|
43
|
+
},
|
|
44
|
+
"gemini-flash": {
|
|
45
|
+
"gemini": "gemini-flash-latest",
|
|
46
|
+
"vertexai": "gemini-flash-latest",
|
|
47
|
+
"openrouter": "google/gemini-flash-latest"
|
|
48
|
+
},
|
|
49
|
+
"gemini-pro": {
|
|
50
|
+
"gemini": "gemini-1.5-pro-001",
|
|
51
|
+
"vertexai": "gemini-1.5-pro-001",
|
|
52
|
+
"openrouter": "google/gemini-1.5-pro-001"
|
|
53
|
+
},
|
|
54
|
+
"gemini-1.5-flash": {
|
|
55
|
+
"gemini": "gemini-1.5-flash-001",
|
|
56
|
+
"vertexai": "gemini-1.5-flash-001",
|
|
57
|
+
"openrouter": "google/gemini-1.5-flash-001"
|
|
58
|
+
},
|
|
59
|
+
"gemini-1.5-pro": {
|
|
60
|
+
"gemini": "gemini-1.5-pro-001",
|
|
61
|
+
"vertexai": "gemini-1.5-pro-001",
|
|
62
|
+
"openrouter": "google/gemini-1.5-pro-001"
|
|
63
|
+
},
|
|
64
|
+
"gemini-2.0-flash": {
|
|
65
|
+
"gemini": "gemini-2.0-flash",
|
|
66
|
+
"vertexai": "gemini-2.0-flash"
|
|
67
|
+
},
|
|
68
|
+
"gemini-2.0-flash-001": {
|
|
69
|
+
"gemini": "gemini-2.0-flash-001",
|
|
70
|
+
"openrouter": "google/gemini-2.0-flash-001",
|
|
71
|
+
"vertexai": "gemini-2.0-flash-001"
|
|
72
|
+
},
|
|
73
|
+
"gpt-3.5-turbo": {
|
|
74
|
+
"openai": "gpt-3.5-turbo",
|
|
75
|
+
"openrouter": "openai/gpt-3.5-turbo"
|
|
76
|
+
},
|
|
77
|
+
"gpt-4": {
|
|
78
|
+
"openai": "gpt-4",
|
|
79
|
+
"openrouter": "openai/gpt-4"
|
|
80
|
+
},
|
|
81
|
+
"gpt-4-turbo": {
|
|
82
|
+
"openai": "gpt-4-turbo",
|
|
83
|
+
"openrouter": "openai/gpt-4-turbo"
|
|
84
|
+
},
|
|
85
|
+
"gpt-4o": {
|
|
86
|
+
"openai": "gpt-4o",
|
|
87
|
+
"openrouter": "openai/gpt-4o"
|
|
88
|
+
},
|
|
89
|
+
"gpt-4o-mini": {
|
|
90
|
+
"openai": "gpt-4o-mini",
|
|
91
|
+
"openrouter": "openai/gpt-4o-mini"
|
|
92
|
+
},
|
|
93
|
+
"llama-3-1-405b": {
|
|
94
|
+
"openrouter": "meta-llama/llama-3.1-405b"
|
|
95
|
+
},
|
|
96
|
+
"llama-3-1-405b-instruct": {
|
|
97
|
+
"openrouter": "meta-llama/llama-3.1-405b-instruct"
|
|
98
|
+
},
|
|
99
|
+
"llama-3-1-70b": {
|
|
100
|
+
"openrouter": "meta-llama/llama-3.1-70b"
|
|
101
|
+
},
|
|
102
|
+
"llama-3-1-70b-instruct": {
|
|
103
|
+
"openrouter": "meta-llama/llama-3.1-70b-instruct"
|
|
104
|
+
},
|
|
105
|
+
"llama-3-1-8b": {
|
|
106
|
+
"openrouter": "meta-llama/llama-3.1-8b"
|
|
107
|
+
},
|
|
108
|
+
"llama-3-1-8b-instruct": {
|
|
109
|
+
"openrouter": "meta-llama/llama-3.1-8b-instruct"
|
|
110
|
+
},
|
|
111
|
+
"llama-3-2-1b-instruct": {
|
|
112
|
+
"openrouter": "meta-llama/llama-3.2-1b-instruct"
|
|
113
|
+
},
|
|
114
|
+
"llama-3-2-3b-instruct": {
|
|
115
|
+
"openrouter": "meta-llama/llama-3.2-3b-instruct"
|
|
116
|
+
},
|
|
117
|
+
"llama-3-3-70b-instruct": {
|
|
118
|
+
"openrouter": "meta-llama/llama-3.3-70b-instruct"
|
|
119
|
+
},
|
|
120
|
+
"mistral-large": {
|
|
121
|
+
"mistral": "mistral-large-latest",
|
|
122
|
+
"openrouter": "mistralai/mistral-large"
|
|
123
|
+
},
|
|
124
|
+
"mistral-medium": {
|
|
125
|
+
"mistral": "mistral-medium-latest",
|
|
126
|
+
"openrouter": "mistralai/mistral-medium"
|
|
127
|
+
},
|
|
128
|
+
"mistral-small": {
|
|
129
|
+
"mistral": "mistral-small-latest",
|
|
130
|
+
"openrouter": "mistralai/mistral-small"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Message } from "../chat/Message.js";
|
|
2
|
+
import { ChatResponseString } from "../chat/ChatResponse.js";
|
|
3
|
+
/**
|
|
4
|
+
* Interceptor for processing messages before they are sent to the LLM.
|
|
5
|
+
* Return modified messages or void to keep original.
|
|
6
|
+
*/
|
|
7
|
+
export type RequestInterceptor = (messages: Message[]) => Promise<Message[] | void> | Message[] | void;
|
|
8
|
+
/**
|
|
9
|
+
* Interceptor for processing LLM responses before they are returned to the user.
|
|
10
|
+
* Return modified response or void to keep original.
|
|
11
|
+
*/
|
|
12
|
+
export type ResponseInterceptor = (response: ChatResponseString) => Promise<ChatResponseString | void> | ChatResponseString | void;
|
|
13
|
+
/**
|
|
14
|
+
* Manages a chain of interceptors that can modify requests and responses.
|
|
15
|
+
*/
|
|
16
|
+
export declare class InterceptorChain {
|
|
17
|
+
private requestInterceptors;
|
|
18
|
+
private responseInterceptors;
|
|
19
|
+
/**
|
|
20
|
+
* Add a request interceptor to the chain.
|
|
21
|
+
*/
|
|
22
|
+
addRequestInterceptor(interceptor: RequestInterceptor): this;
|
|
23
|
+
/**
|
|
24
|
+
* Add a response interceptor to the chain.
|
|
25
|
+
*/
|
|
26
|
+
addResponseInterceptor(interceptor: ResponseInterceptor): this;
|
|
27
|
+
/**
|
|
28
|
+
* Execute all request interceptors in order.
|
|
29
|
+
*/
|
|
30
|
+
executeRequestInterceptors(messages: Message[]): Promise<Message[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Execute all response interceptors in order.
|
|
33
|
+
*/
|
|
34
|
+
executeResponseInterceptors(response: ChatResponseString): Promise<ChatResponseString>;
|
|
35
|
+
/**
|
|
36
|
+
* Clear all interceptors.
|
|
37
|
+
*/
|
|
38
|
+
clear(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get the number of registered interceptors.
|
|
41
|
+
*/
|
|
42
|
+
get size(): {
|
|
43
|
+
request: number;
|
|
44
|
+
response: number;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=InterceptorChain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InterceptorChain.d.ts","sourceRoot":"","sources":["../../src/interceptors/InterceptorChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,EAAE,GAAG,IAAI,CAAC;AAEvG;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,kBAAkB,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,GAAG,kBAAkB,GAAG,IAAI,CAAC;AAEnI;;GAEG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,oBAAoB,CAA6B;IAEzD;;OAEG;IACH,qBAAqB,CAAC,WAAW,EAAE,kBAAkB,GAAG,IAAI;IAK5D;;OAEG;IACH,sBAAsB,CAAC,WAAW,EAAE,mBAAmB,GAAG,IAAI;IAK9D;;OAEG;IACG,0BAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAazE;;OAEG;IACG,2BAA2B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAa5F;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAKhD;CACF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manages a chain of interceptors that can modify requests and responses.
|
|
3
|
+
*/
|
|
4
|
+
export class InterceptorChain {
|
|
5
|
+
requestInterceptors = [];
|
|
6
|
+
responseInterceptors = [];
|
|
7
|
+
/**
|
|
8
|
+
* Add a request interceptor to the chain.
|
|
9
|
+
*/
|
|
10
|
+
addRequestInterceptor(interceptor) {
|
|
11
|
+
this.requestInterceptors.push(interceptor);
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Add a response interceptor to the chain.
|
|
16
|
+
*/
|
|
17
|
+
addResponseInterceptor(interceptor) {
|
|
18
|
+
this.responseInterceptors.push(interceptor);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute all request interceptors in order.
|
|
23
|
+
*/
|
|
24
|
+
async executeRequestInterceptors(messages) {
|
|
25
|
+
let current = messages;
|
|
26
|
+
for (const interceptor of this.requestInterceptors) {
|
|
27
|
+
const result = await interceptor(current);
|
|
28
|
+
if (result) {
|
|
29
|
+
current = result;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return current;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Execute all response interceptors in order.
|
|
36
|
+
*/
|
|
37
|
+
async executeResponseInterceptors(response) {
|
|
38
|
+
let current = response;
|
|
39
|
+
for (const interceptor of this.responseInterceptors) {
|
|
40
|
+
const result = await interceptor(current);
|
|
41
|
+
if (result) {
|
|
42
|
+
current = result;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return current;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Clear all interceptors.
|
|
49
|
+
*/
|
|
50
|
+
clear() {
|
|
51
|
+
this.requestInterceptors = [];
|
|
52
|
+
this.responseInterceptors = [];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the number of registered interceptors.
|
|
56
|
+
*/
|
|
57
|
+
get size() {
|
|
58
|
+
return {
|
|
59
|
+
request: this.requestInterceptors.length,
|
|
60
|
+
response: this.responseInterceptors.length
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Message } from "../chat/Message.js";
|
|
2
|
+
import { ChatResponseString } from "../chat/ChatResponse.js";
|
|
3
|
+
/**
|
|
4
|
+
* Example: Redact PII (emails, phone numbers) from messages before sending to LLM.
|
|
5
|
+
*/
|
|
6
|
+
export declare function piiRedactionInterceptor(messages: Message[]): Message[];
|
|
7
|
+
/**
|
|
8
|
+
* Example: Log all requests for debugging/auditing.
|
|
9
|
+
*/
|
|
10
|
+
export declare function requestLoggerInterceptor(messages: Message[]): void;
|
|
11
|
+
/**
|
|
12
|
+
* Example: Log all responses for debugging/auditing.
|
|
13
|
+
*/
|
|
14
|
+
export declare function responseLoggerInterceptor(response: ChatResponseString): void;
|
|
15
|
+
/**
|
|
16
|
+
* Example: Add a custom header/footer to all responses.
|
|
17
|
+
*/
|
|
18
|
+
export declare function responseWrapperInterceptor(response: ChatResponseString): ChatResponseString;
|
|
19
|
+
//# sourceMappingURL=examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../../src/interceptors/examples.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAYtE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,CAElE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAK5E;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,kBAAkB,GAAG,kBAAkB,CAS3F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ChatResponseString } from "../chat/ChatResponse.js.js";
|
|
2
|
+
/**
|
|
3
|
+
* Example: Redact PII (emails, phone numbers) from messages before sending to LLM.
|
|
4
|
+
*/
|
|
5
|
+
export function piiRedactionInterceptor(messages) {
|
|
6
|
+
const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g;
|
|
7
|
+
const phoneRegex = /\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g;
|
|
8
|
+
return messages.map(msg => ({
|
|
9
|
+
...msg,
|
|
10
|
+
content: typeof msg.content === 'string'
|
|
11
|
+
? msg.content
|
|
12
|
+
.replace(emailRegex, '[EMAIL_REDACTED]')
|
|
13
|
+
.replace(phoneRegex, '[PHONE_REDACTED]')
|
|
14
|
+
: msg.content
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Example: Log all requests for debugging/auditing.
|
|
19
|
+
*/
|
|
20
|
+
export function requestLoggerInterceptor(messages) {
|
|
21
|
+
console.log('[Request Interceptor] Sending messages:', JSON.stringify(messages, null, 2));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Example: Log all responses for debugging/auditing.
|
|
25
|
+
*/
|
|
26
|
+
export function responseLoggerInterceptor(response) {
|
|
27
|
+
console.log('[Response Interceptor] Received response:', {
|
|
28
|
+
content: response.toString().substring(0, 100) + '...',
|
|
29
|
+
usage: response.usage
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Example: Add a custom header/footer to all responses.
|
|
34
|
+
*/
|
|
35
|
+
export function responseWrapperInterceptor(response) {
|
|
36
|
+
const wrapped = `--- AI Response ---\n${response.toString()}\n--- End Response ---`;
|
|
37
|
+
return new ChatResponseString(wrapped, response.usage, response.model, response.provider, response.reasoning);
|
|
38
|
+
}
|