@chainfuse/ai-tools 0.7.1 → 0.9.0
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/models.d.mts +2 -2
- package/dist/models.mjs +5 -5
- package/dist/providers/customProviders.d.mts +2 -2
- package/dist/providers/customProviders.mjs +23 -9
- package/dist/providers/rawProviders.d.mts +5 -3
- package/dist/providers/rawProviders.mjs +73 -103
- package/dist/registry.mjs +5 -7
- package/dist/serverSelector.d.mts +17 -0
- package/dist/serverSelector.mjs +151 -0
- package/dist/types.d.mts +18 -14
- package/package.json +11 -11
- package/dist/serverSelector/azure.d.mts +0 -5
- package/dist/serverSelector/azure.mjs +0 -284
- package/dist/serverSelector/base.d.mts +0 -22
- package/dist/serverSelector/base.mjs +0 -137
- package/dist/serverSelector/types.d.mts +0 -10
- package/dist/serverSelector/types.mjs +0 -1
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { AiBase } from "./base.mjs";
|
|
2
|
+
export class ServerSelector extends AiBase {
|
|
3
|
+
static determinePrivacyRegion(country, continent) {
|
|
4
|
+
const regions = new Set();
|
|
5
|
+
if (country) {
|
|
6
|
+
switch (country.toUpperCase()) {
|
|
7
|
+
case 'AU':
|
|
8
|
+
regions.add('APPs');
|
|
9
|
+
break;
|
|
10
|
+
case 'BR':
|
|
11
|
+
regions.add('LGPD');
|
|
12
|
+
break;
|
|
13
|
+
case 'CA':
|
|
14
|
+
regions.add('PIPEDA');
|
|
15
|
+
regions.add('GDPR');
|
|
16
|
+
regions.add('revFADP');
|
|
17
|
+
regions.add('UK-GDPR');
|
|
18
|
+
break;
|
|
19
|
+
case 'IN':
|
|
20
|
+
regions.add('PDP');
|
|
21
|
+
break;
|
|
22
|
+
case 'JP':
|
|
23
|
+
regions.add('APPI');
|
|
24
|
+
regions.add('GDPR');
|
|
25
|
+
regions.add('UK-GDPR');
|
|
26
|
+
break;
|
|
27
|
+
case 'KR':
|
|
28
|
+
regions.add('PIPA');
|
|
29
|
+
regions.add('GDPR');
|
|
30
|
+
regions.add('UK-GDPR');
|
|
31
|
+
break;
|
|
32
|
+
case 'NO':
|
|
33
|
+
regions.add('NPDA');
|
|
34
|
+
regions.add('PIPEDA');
|
|
35
|
+
regions.add('GDPR');
|
|
36
|
+
regions.add('APPI');
|
|
37
|
+
regions.add('PIPA');
|
|
38
|
+
regions.add('revFADP');
|
|
39
|
+
regions.add('UK-GDPR');
|
|
40
|
+
break;
|
|
41
|
+
case 'ZA':
|
|
42
|
+
regions.add('PoPIA');
|
|
43
|
+
break;
|
|
44
|
+
case 'CH':
|
|
45
|
+
regions.add('revFADP');
|
|
46
|
+
regions.add('PIPEDA');
|
|
47
|
+
regions.add('GDPR');
|
|
48
|
+
regions.add('APPI');
|
|
49
|
+
regions.add('PIPA');
|
|
50
|
+
regions.add('NPDA');
|
|
51
|
+
regions.add('revFADP');
|
|
52
|
+
regions.add('UK-GDPR');
|
|
53
|
+
break;
|
|
54
|
+
case 'GB':
|
|
55
|
+
regions.add('UK-GDPR');
|
|
56
|
+
regions.add('PIPEDA');
|
|
57
|
+
regions.add('GDPR');
|
|
58
|
+
regions.add('APPI');
|
|
59
|
+
regions.add('PIPA');
|
|
60
|
+
regions.add('NPDA');
|
|
61
|
+
regions.add('revFADP');
|
|
62
|
+
regions.add('UK-GDPR');
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (continent) {
|
|
67
|
+
switch (continent.toUpperCase()) {
|
|
68
|
+
case 'EU':
|
|
69
|
+
regions.add('GDPR');
|
|
70
|
+
regions.add('PIPEDA');
|
|
71
|
+
regions.add('APPI');
|
|
72
|
+
regions.add('PIPA');
|
|
73
|
+
regions.add('NPDA');
|
|
74
|
+
regions.add('revFADP');
|
|
75
|
+
regions.add('UK-GDPR');
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return Array.from(regions);
|
|
80
|
+
}
|
|
81
|
+
async determineLocation(geoRouting = this.config.geoRouting) {
|
|
82
|
+
if (!geoRouting?.userCoordinate?.lat || !geoRouting?.userCoordinate?.lon || !geoRouting?.country || !geoRouting?.continent) {
|
|
83
|
+
console.warn('Location not provided, falling back to nearest Cloudflare POP', 'WARNING: This is slow');
|
|
84
|
+
try {
|
|
85
|
+
const geoJson = await fetch(new URL('https://workers.cloudflare.com/cf.json')).then((geoResponse) => geoResponse.json().then((json) => json));
|
|
86
|
+
return {
|
|
87
|
+
coordinate: {
|
|
88
|
+
lat: geoRouting?.userCoordinate?.lat ?? geoJson.latitude ?? '0',
|
|
89
|
+
lon: geoRouting?.userCoordinate?.lon ?? geoJson.longitude ?? '0',
|
|
90
|
+
},
|
|
91
|
+
country: geoRouting?.country ?? geoJson.country,
|
|
92
|
+
continent: geoRouting?.continent ?? geoJson.continent,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
console.error('Failed to use nearest Cloudflare POP, service distance and privacy regions will be wrong', error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return {
|
|
100
|
+
coordinate: {
|
|
101
|
+
lat: geoRouting?.userCoordinate?.lat ?? '0',
|
|
102
|
+
lon: geoRouting?.userCoordinate?.lon ?? '0',
|
|
103
|
+
},
|
|
104
|
+
country: geoRouting?.country,
|
|
105
|
+
continent: geoRouting?.continent,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async closestServers(servers, requiredCapability, userCoordinate, privacyRegion) {
|
|
109
|
+
if (!userCoordinate || !privacyRegion) {
|
|
110
|
+
const { coordinate, country, continent } = await this.determineLocation();
|
|
111
|
+
if (!userCoordinate)
|
|
112
|
+
userCoordinate = coordinate;
|
|
113
|
+
if (!privacyRegion)
|
|
114
|
+
privacyRegion = ServerSelector.determinePrivacyRegion(country, continent);
|
|
115
|
+
}
|
|
116
|
+
// Skip over the rest of logic if the server can't handle the incoming request
|
|
117
|
+
// @ts-expect-error it's always strings, just sometimes string literals
|
|
118
|
+
const featureFilteredServers = requiredCapability ? servers.filter((server) => server.languageModelAvailability.includes(requiredCapability) || server.textEmbeddingModelAvailability.includes(requiredCapability)) : servers;
|
|
119
|
+
if (featureFilteredServers.length > 0) {
|
|
120
|
+
// Skip over servers not in the save privacy region except if undefined, then you can use any
|
|
121
|
+
const privacyRegionFilteredServers = featureFilteredServers.filter((server) => privacyRegion.length === 0 || ('privacyRegion' in server && privacyRegion.includes(server.privacyRegion)));
|
|
122
|
+
if (privacyRegionFilteredServers.length > 0) {
|
|
123
|
+
// Calculate distance for each server and store it as a tuple [Server, distance]
|
|
124
|
+
const serversWithDistances = await Promise.all([import('haversine-distance'), import('@chainfuse/helpers')]).then(([{ default: haversine }, { Helpers }]) => privacyRegionFilteredServers.map((server) => {
|
|
125
|
+
// Match decimal point length
|
|
126
|
+
return [
|
|
127
|
+
server,
|
|
128
|
+
haversine({
|
|
129
|
+
lat: Helpers.precisionFloat(userCoordinate.lat),
|
|
130
|
+
lon: Helpers.precisionFloat(userCoordinate.lon),
|
|
131
|
+
}, {
|
|
132
|
+
lat: Helpers.precisionFloat(server.coordinate.lat),
|
|
133
|
+
lon: Helpers.precisionFloat(server.coordinate.lon),
|
|
134
|
+
}),
|
|
135
|
+
];
|
|
136
|
+
}));
|
|
137
|
+
// Sort the servers by distance
|
|
138
|
+
serversWithDistances.sort((a, b) => a[1] - b[1]);
|
|
139
|
+
// Extract the ids of the sorted servers
|
|
140
|
+
const sortedServers = serversWithDistances.map(([server]) => server);
|
|
141
|
+
return sortedServers;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
throw new Error(`No server with the capability ${requiredCapability} available in a region covered under ${JSON.stringify(privacyRegion)}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(`No server with the capability ${requiredCapability} available`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Coordinate, PrefixedUuid, UuidExport } from '@chainfuse/types';
|
|
2
|
+
import type { azureCatalog } from '@chainfuse/types/ai-tools/catalog/azure';
|
|
2
3
|
import type { Ai, ExecutionContext, IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
|
|
3
4
|
import type haversine from 'haversine-distance';
|
|
4
5
|
export interface AiConfig {
|
|
@@ -7,11 +8,11 @@ export interface AiConfig {
|
|
|
7
8
|
apiToken: string;
|
|
8
9
|
};
|
|
9
10
|
geoRouting?: {
|
|
10
|
-
userCoordinate?:
|
|
11
|
+
userCoordinate?: Coordinate;
|
|
11
12
|
country?: IncomingRequestCfProperties['country'];
|
|
12
13
|
continent?: IncomingRequestCfProperties['continent'];
|
|
13
14
|
};
|
|
14
|
-
environment: 'production' | 'preview';
|
|
15
|
+
environment: 'internal' | 'production-passive' | 'preview-passive' | 'production-active' | 'preview-active';
|
|
15
16
|
providers: AiConfigProviders;
|
|
16
17
|
backgroundContext?: ExecutionContext;
|
|
17
18
|
}
|
|
@@ -54,6 +55,11 @@ export interface AiConfigWorkersaiRest {
|
|
|
54
55
|
apiToken: string;
|
|
55
56
|
}
|
|
56
57
|
export type AiConfigWorkersaiBinding<T extends Ai = Ai> = T;
|
|
58
|
+
export type AzureServers = typeof azureCatalog;
|
|
59
|
+
export type Servers = AzureServers;
|
|
60
|
+
export type PrivacyRegion = Extract<Servers[number], {
|
|
61
|
+
privacyRegion: string;
|
|
62
|
+
}>['privacyRegion'];
|
|
57
63
|
/**
|
|
58
64
|
* It's a UUID, but the last block is SHA256 of the request body
|
|
59
65
|
*/
|
|
@@ -90,9 +96,10 @@ export interface AiRequestConfig {
|
|
|
90
96
|
*/
|
|
91
97
|
skipCache?: boolean;
|
|
92
98
|
}
|
|
93
|
-
export interface
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
export interface AiRequestMetadataTiming {
|
|
100
|
+
modelTime?: number;
|
|
101
|
+
fromCache: boolean;
|
|
102
|
+
totalRoundtripTime: number;
|
|
96
103
|
}
|
|
97
104
|
export interface AiRequestMetadataServerInfo {
|
|
98
105
|
name: 'anthropic' | 'cloudflare' | 'googleai' | 'openai';
|
|
@@ -104,17 +111,14 @@ export interface AiRequestMetadataServerInfoWithLocation {
|
|
|
104
111
|
*/
|
|
105
112
|
distance: ReturnType<typeof haversine>;
|
|
106
113
|
}
|
|
107
|
-
export interface AiRequestMetadataTiming {
|
|
108
|
-
modelTime?: number;
|
|
109
|
-
fromCache: boolean;
|
|
110
|
-
totalRoundtripTime: number;
|
|
111
|
-
}
|
|
112
114
|
export interface AiRequestMetadata {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
dataspaceId: AiRequestConfig['dataspaceId'];
|
|
116
|
+
messageId: AiRequestConfig['messageId'];
|
|
117
|
+
serverInfo: (AiRequestMetadataServerInfo | AiRequestMetadataServerInfoWithLocation) & {
|
|
118
|
+
timing?: AiRequestMetadataTiming;
|
|
119
|
+
};
|
|
115
120
|
idempotencyId: AiRequestIdempotencyId;
|
|
116
121
|
executor: AiRequestExecutor;
|
|
117
|
-
timing: AiRequestMetadataTiming;
|
|
118
122
|
}
|
|
119
123
|
export type AiRequestMetadataStringified = Record<keyof AiRequestMetadata, string>;
|
|
120
124
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainfuse/ai-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "ChainFuse",
|
|
6
6
|
"homepage": "https://github.com/ChainFuse/packages/tree/main/packages/ai-tools#readme",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"scripts": {
|
|
25
25
|
"fmt": "prettier --check .",
|
|
26
26
|
"fmt:fix": "prettier --write .",
|
|
27
|
-
"lint": "eslint
|
|
27
|
+
"lint": "eslint src",
|
|
28
28
|
"lint:fix": "npm run lint -- --fix",
|
|
29
29
|
"clean": "npx -y rimraf@latest ./dist ./.tsbuildinfo",
|
|
30
30
|
"build": "tsc",
|
|
@@ -48,21 +48,21 @@
|
|
|
48
48
|
},
|
|
49
49
|
"prettier": "@demosjarco/prettier-config",
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ai-sdk/anthropic": "^1.
|
|
52
|
-
"@ai-sdk/azure": "^1.
|
|
53
|
-
"@ai-sdk/google": "^1.1
|
|
51
|
+
"@ai-sdk/anthropic": "^1.2.0",
|
|
52
|
+
"@ai-sdk/azure": "^1.3.0",
|
|
53
|
+
"@ai-sdk/google": "^1.2.1",
|
|
54
54
|
"@ai-sdk/openai": "^1.0.5",
|
|
55
|
-
"@ai-sdk/openai-compatible": "^0.
|
|
56
|
-
"@chainfuse/helpers": "^2.
|
|
57
|
-
"@chainfuse/types": "^
|
|
58
|
-
"ai": "^4.
|
|
55
|
+
"@ai-sdk/openai-compatible": "^0.2.0",
|
|
56
|
+
"@chainfuse/helpers": "^2.1.1",
|
|
57
|
+
"@chainfuse/types": "^2.0.0",
|
|
58
|
+
"ai": "^4.2.0",
|
|
59
59
|
"chalk": "^5.4.1",
|
|
60
60
|
"haversine-distance": "^1.2.3",
|
|
61
61
|
"workers-ai-provider": "^0.2.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@cloudflare/workers-types": "^4.
|
|
64
|
+
"@cloudflare/workers-types": "^4.20250320.0",
|
|
65
65
|
"openai": "^4.89.0"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "60babb051a4005d8495655784427e446fc7c7bcb"
|
|
68
68
|
}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { PrivacyRegion, ServerSelector } from './base.mjs';
|
|
2
|
-
export class AzureServerSelector extends ServerSelector {
|
|
3
|
-
// From: https://gist.github.com/demosjarco/2091b3a197e530f1402e9dfec6666cd8
|
|
4
|
-
servers = new Set([
|
|
5
|
-
{
|
|
6
|
-
id: 'OpenAi-AU-NewSouthWales',
|
|
7
|
-
coordinate: {
|
|
8
|
-
lat: -33.86,
|
|
9
|
-
lon: 151.2094,
|
|
10
|
-
},
|
|
11
|
-
region: PrivacyRegion.Australian_Privacy_Principles,
|
|
12
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
13
|
-
imageModelAvailability: ['dall-e-3'],
|
|
14
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large', 'text-embedding-3-small'],
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: 'OpenAi-BR-SaoPauloState',
|
|
18
|
-
coordinate: {
|
|
19
|
-
lat: -23.55,
|
|
20
|
-
lon: -46.633,
|
|
21
|
-
},
|
|
22
|
-
region: PrivacyRegion.Brazil_General_Data_protection_Law,
|
|
23
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
24
|
-
imageModelAvailability: [],
|
|
25
|
-
textEmbeddingModelAvailability: [],
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
id: 'OpenAI-CA-Toronto',
|
|
29
|
-
coordinate: {
|
|
30
|
-
lat: 43.653,
|
|
31
|
-
lon: -79.383,
|
|
32
|
-
},
|
|
33
|
-
region: PrivacyRegion.Canada_Personal_Information_Protection_and_Electronic_Documents_Act,
|
|
34
|
-
languageModelAvailability: [],
|
|
35
|
-
imageModelAvailability: [],
|
|
36
|
-
textEmbeddingModelAvailability: [],
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
id: 'OpenAI-CA-Quebec',
|
|
40
|
-
coordinate: {
|
|
41
|
-
lat: 46.817,
|
|
42
|
-
lon: -71.217,
|
|
43
|
-
},
|
|
44
|
-
region: PrivacyRegion.Canada_Personal_Information_Protection_and_Electronic_Documents_Act,
|
|
45
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
46
|
-
imageModelAvailability: [],
|
|
47
|
-
textEmbeddingModelAvailability: ['text-embedding-3-small', 'text-embedding-3-large'],
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 'OpenAi-US-Virginia',
|
|
51
|
-
coordinate: {
|
|
52
|
-
lat: 37.3719,
|
|
53
|
-
lon: -79.8164,
|
|
54
|
-
},
|
|
55
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
56
|
-
imageModelAvailability: ['dall-e-3'],
|
|
57
|
-
textEmbeddingModelAvailability: ['text-embedding-3-small', 'text-embedding-3-large'],
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
id: 'OpenAi-US-Virginia2',
|
|
61
|
-
coordinate: {
|
|
62
|
-
lat: 36.6681,
|
|
63
|
-
lon: -78.3889,
|
|
64
|
-
},
|
|
65
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini', 'o1', 'o3-mini'],
|
|
66
|
-
imageModelAvailability: [],
|
|
67
|
-
textEmbeddingModelAvailability: ['text-embedding-3-small', 'text-embedding-3-large'],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
id: 'OpenAi-EU-Paris',
|
|
71
|
-
coordinate: {
|
|
72
|
-
lat: 46.3772,
|
|
73
|
-
lon: 2.373,
|
|
74
|
-
},
|
|
75
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
76
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
77
|
-
imageModelAvailability: [],
|
|
78
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
id: 'OpenAi-EU-Frankfurt',
|
|
82
|
-
coordinate: {
|
|
83
|
-
lat: 50.110924,
|
|
84
|
-
lon: 8.682127,
|
|
85
|
-
},
|
|
86
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
87
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
88
|
-
imageModelAvailability: [],
|
|
89
|
-
textEmbeddingModelAvailability: [],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: 'OpenAi-JP-Tokyo',
|
|
93
|
-
coordinate: {
|
|
94
|
-
lat: 35.68,
|
|
95
|
-
lon: 139.77,
|
|
96
|
-
},
|
|
97
|
-
region: PrivacyRegion.Japan_Act_on_the_Protection_of_Personal_Information,
|
|
98
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
99
|
-
imageModelAvailability: [],
|
|
100
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large', 'text-embedding-3-small'],
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: 'OpenAi-KR-Seoul',
|
|
104
|
-
coordinate: {
|
|
105
|
-
lat: 37.5665,
|
|
106
|
-
lon: 126.978,
|
|
107
|
-
},
|
|
108
|
-
region: PrivacyRegion.Korean_Personal_Information_Protection_Act,
|
|
109
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
110
|
-
imageModelAvailability: [],
|
|
111
|
-
textEmbeddingModelAvailability: [],
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: 'OpenAi-US-Illinois',
|
|
115
|
-
coordinate: {
|
|
116
|
-
lat: 41.8819,
|
|
117
|
-
lon: -87.6278,
|
|
118
|
-
},
|
|
119
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
120
|
-
imageModelAvailability: [],
|
|
121
|
-
textEmbeddingModelAvailability: [],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: 'OpenAi-NO-Oslo',
|
|
125
|
-
coordinate: {
|
|
126
|
-
lat: 59.913868,
|
|
127
|
-
lon: 10.752245,
|
|
128
|
-
},
|
|
129
|
-
region: PrivacyRegion.Norwegian_Personal_Data_Act,
|
|
130
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
131
|
-
imageModelAvailability: [],
|
|
132
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
id: 'OpenAi-EU-Warsaw',
|
|
136
|
-
coordinate: {
|
|
137
|
-
lat: 52.23334,
|
|
138
|
-
lon: 21.01666,
|
|
139
|
-
},
|
|
140
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
141
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
142
|
-
imageModelAvailability: [],
|
|
143
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
id: 'OpenAi-ZA-Johannesburg',
|
|
147
|
-
coordinate: {
|
|
148
|
-
lat: 28.21837,
|
|
149
|
-
lon: -25.73134,
|
|
150
|
-
},
|
|
151
|
-
region: PrivacyRegion.SouthAfrica_Protection_Personal_Information_Act,
|
|
152
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
153
|
-
imageModelAvailability: [],
|
|
154
|
-
textEmbeddingModelAvailability: [],
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
id: 'OpenAi-US-Texas',
|
|
158
|
-
coordinate: {
|
|
159
|
-
lat: 29.4167,
|
|
160
|
-
lon: -98.5,
|
|
161
|
-
},
|
|
162
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
163
|
-
imageModelAvailability: [],
|
|
164
|
-
textEmbeddingModelAvailability: [],
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
id: 'OpenAi-IN-Chennai',
|
|
168
|
-
coordinate: {
|
|
169
|
-
lat: 12.9822,
|
|
170
|
-
lon: 80.1636,
|
|
171
|
-
},
|
|
172
|
-
region: PrivacyRegion.Indian_Personal_Protection,
|
|
173
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
174
|
-
imageModelAvailability: [],
|
|
175
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
id: 'OpenAi-SG-Singapore',
|
|
179
|
-
coordinate: {
|
|
180
|
-
lat: 1.283,
|
|
181
|
-
lon: 103.833,
|
|
182
|
-
},
|
|
183
|
-
languageModelAvailability: [],
|
|
184
|
-
imageModelAvailability: [],
|
|
185
|
-
textEmbeddingModelAvailability: [],
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
id: 'OpenAi-EU-Gavle',
|
|
189
|
-
coordinate: {
|
|
190
|
-
lat: 60.67488,
|
|
191
|
-
lon: 17.14127,
|
|
192
|
-
},
|
|
193
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
194
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o-mini', 'gpt-4o', 'o1', 'o3-mini'],
|
|
195
|
-
imageModelAvailability: ['dall-e-3'],
|
|
196
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
197
|
-
},
|
|
198
|
-
{
|
|
199
|
-
id: 'OpenAi-EU-Madrid',
|
|
200
|
-
coordinate: {
|
|
201
|
-
lat: 3.4209,
|
|
202
|
-
lon: 40.4259,
|
|
203
|
-
},
|
|
204
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
205
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o'],
|
|
206
|
-
imageModelAvailability: [],
|
|
207
|
-
textEmbeddingModelAvailability: [],
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
id: 'OpenAi-CH-Geneva',
|
|
211
|
-
coordinate: {
|
|
212
|
-
lat: 46.204391,
|
|
213
|
-
lon: 6.143158,
|
|
214
|
-
},
|
|
215
|
-
region: PrivacyRegion.Swiss_Federal_Act_on_Data_Protection,
|
|
216
|
-
languageModelAvailability: [],
|
|
217
|
-
imageModelAvailability: [],
|
|
218
|
-
textEmbeddingModelAvailability: [],
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
id: 'OpenAi-AE-Dubai',
|
|
222
|
-
coordinate: {
|
|
223
|
-
lat: 25.266666,
|
|
224
|
-
lon: 55.316666,
|
|
225
|
-
},
|
|
226
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o-mini'],
|
|
227
|
-
imageModelAvailability: [],
|
|
228
|
-
textEmbeddingModelAvailability: [],
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
id: 'OpenAi-CH-Zurich',
|
|
232
|
-
coordinate: {
|
|
233
|
-
lat: 47.451542,
|
|
234
|
-
lon: 8.564572,
|
|
235
|
-
},
|
|
236
|
-
region: PrivacyRegion.Swiss_Federal_Act_on_Data_Protection,
|
|
237
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
238
|
-
imageModelAvailability: [],
|
|
239
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large', 'text-embedding-3-small'],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
id: 'OpenAi-UK-London',
|
|
243
|
-
coordinate: {
|
|
244
|
-
lat: 50.941,
|
|
245
|
-
lon: -0.799,
|
|
246
|
-
},
|
|
247
|
-
region: PrivacyRegion.UK_General_Data_Protection_Regulation,
|
|
248
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
249
|
-
imageModelAvailability: [],
|
|
250
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
id: 'OpenAi-EU-Netherlands',
|
|
254
|
-
coordinate: {
|
|
255
|
-
lat: 52.3667,
|
|
256
|
-
lon: 4.9,
|
|
257
|
-
},
|
|
258
|
-
region: PrivacyRegion.General_Data_Protection_Regulation,
|
|
259
|
-
languageModelAvailability: ['gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
260
|
-
imageModelAvailability: [],
|
|
261
|
-
textEmbeddingModelAvailability: [],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
id: 'OpenAi-US-California',
|
|
265
|
-
coordinate: {
|
|
266
|
-
lat: 37.783,
|
|
267
|
-
lon: -122.417,
|
|
268
|
-
},
|
|
269
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
270
|
-
imageModelAvailability: [],
|
|
271
|
-
textEmbeddingModelAvailability: [],
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
id: 'OpenAi-US-Phoenix',
|
|
275
|
-
coordinate: {
|
|
276
|
-
lat: 33.448376,
|
|
277
|
-
lon: -112.074036,
|
|
278
|
-
},
|
|
279
|
-
languageModelAvailability: ['gpt-35-turbo', 'gpt-4-turbo', 'gpt-4o', 'gpt-4o-mini'],
|
|
280
|
-
imageModelAvailability: [],
|
|
281
|
-
textEmbeddingModelAvailability: ['text-embedding-3-large'],
|
|
282
|
-
},
|
|
283
|
-
]);
|
|
284
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { RawCoordinate } from '@chainfuse/types';
|
|
2
|
-
import type { IncomingRequestCfProperties } from '@cloudflare/workers-types/experimental';
|
|
3
|
-
import { AiBase } from '../base.mjs';
|
|
4
|
-
import type { Server } from './types.mjs';
|
|
5
|
-
export declare enum PrivacyRegion {
|
|
6
|
-
Australian_Privacy_Principles = "APPs",
|
|
7
|
-
Brazil_General_Data_protection_Law = "LGPD",
|
|
8
|
-
Canada_Personal_Information_Protection_and_Electronic_Documents_Act = "PIPEDA",
|
|
9
|
-
General_Data_Protection_Regulation = "GDPR",
|
|
10
|
-
Indian_Personal_Protection = "PDP",
|
|
11
|
-
Japan_Act_on_the_Protection_of_Personal_Information = "APPI",
|
|
12
|
-
Korean_Personal_Information_Protection_Act = "PIPA",
|
|
13
|
-
Norwegian_Personal_Data_Act = "NPDA",
|
|
14
|
-
SouthAfrica_Protection_Personal_Information_Act = "PoPIA",
|
|
15
|
-
Swiss_Federal_Act_on_Data_Protection = "revFADP",
|
|
16
|
-
UK_General_Data_Protection_Regulation = "UK-GDPR"
|
|
17
|
-
}
|
|
18
|
-
export declare abstract class ServerSelector extends AiBase {
|
|
19
|
-
readonly servers: Set<Server>;
|
|
20
|
-
static determinePrivacyRegion(country?: IncomingRequestCfProperties['country'], continent?: IncomingRequestCfProperties['continent']): PrivacyRegion[];
|
|
21
|
-
closestServers(requiredCapability?: (Server['languageModelAvailability'] | Server['textEmbeddingModelAvailability'])[number], userCoordinate?: RawCoordinate, privacyRegion?: PrivacyRegion[]): Server[];
|
|
22
|
-
}
|