@tashiscool/providers 0.1.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/README.md +177 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +50 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +620 -0
- package/dist/models.js.map +1 -0
- package/dist/registry.d.ts +64 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +290 -0
- package/dist/registry.js.map +1 -0
- package/dist/types.d.ts +127 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +42 -0
package/dist/registry.js
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider Registry
|
|
3
|
+
* Central registry for managing LLM providers and their configurations
|
|
4
|
+
*/
|
|
5
|
+
import { openaiModels, anthropicModels, googleModels, mistralModels, groqModels, deepseekModels, xaiModels, } from './models.js';
|
|
6
|
+
/**
|
|
7
|
+
* Provider configurations
|
|
8
|
+
*/
|
|
9
|
+
const providerConfigs = {
|
|
10
|
+
openai: {
|
|
11
|
+
name: 'OpenAI',
|
|
12
|
+
description: 'OpenAI GPT models including GPT-4o and o1 series',
|
|
13
|
+
baseUrl: 'https://api.openai.com/v1',
|
|
14
|
+
requiredEnvVars: ['OPENAI_API_KEY'],
|
|
15
|
+
optionalEnvVars: ['OPENAI_ORG_ID', 'OPENAI_PROJECT_ID'],
|
|
16
|
+
supportsStreaming: true,
|
|
17
|
+
docsUrl: 'https://platform.openai.com/docs',
|
|
18
|
+
models: openaiModels,
|
|
19
|
+
},
|
|
20
|
+
anthropic: {
|
|
21
|
+
name: 'Anthropic',
|
|
22
|
+
description: 'Claude models including Claude 3.5 Sonnet and Opus',
|
|
23
|
+
baseUrl: 'https://api.anthropic.com',
|
|
24
|
+
requiredEnvVars: ['ANTHROPIC_API_KEY'],
|
|
25
|
+
supportsStreaming: true,
|
|
26
|
+
docsUrl: 'https://docs.anthropic.com',
|
|
27
|
+
models: anthropicModels,
|
|
28
|
+
},
|
|
29
|
+
'azure-openai': {
|
|
30
|
+
name: 'Azure OpenAI',
|
|
31
|
+
description: 'OpenAI models hosted on Microsoft Azure',
|
|
32
|
+
baseUrl: 'https://{resource}.openai.azure.com',
|
|
33
|
+
requiredEnvVars: ['AZURE_OPENAI_API_KEY', 'AZURE_OPENAI_ENDPOINT'],
|
|
34
|
+
optionalEnvVars: ['AZURE_OPENAI_API_VERSION'],
|
|
35
|
+
supportsStreaming: true,
|
|
36
|
+
docsUrl: 'https://learn.microsoft.com/azure/ai-services/openai/',
|
|
37
|
+
models: openaiModels.map((m) => ({ ...m, provider: 'azure-openai' })),
|
|
38
|
+
},
|
|
39
|
+
google: {
|
|
40
|
+
name: 'Google AI',
|
|
41
|
+
description: 'Gemini models from Google',
|
|
42
|
+
baseUrl: 'https://generativelanguage.googleapis.com/v1',
|
|
43
|
+
requiredEnvVars: ['GOOGLE_API_KEY'],
|
|
44
|
+
supportsStreaming: true,
|
|
45
|
+
docsUrl: 'https://ai.google.dev/docs',
|
|
46
|
+
models: googleModels,
|
|
47
|
+
},
|
|
48
|
+
'aws-bedrock': {
|
|
49
|
+
name: 'AWS Bedrock',
|
|
50
|
+
description: 'Foundation models on AWS Bedrock',
|
|
51
|
+
baseUrl: 'https://bedrock-runtime.{region}.amazonaws.com',
|
|
52
|
+
requiredEnvVars: ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY'],
|
|
53
|
+
optionalEnvVars: ['AWS_REGION', 'AWS_SESSION_TOKEN'],
|
|
54
|
+
supportsStreaming: true,
|
|
55
|
+
docsUrl: 'https://docs.aws.amazon.com/bedrock/',
|
|
56
|
+
models: [...anthropicModels, ...mistralModels].map((m) => ({
|
|
57
|
+
...m,
|
|
58
|
+
provider: 'aws-bedrock',
|
|
59
|
+
})),
|
|
60
|
+
},
|
|
61
|
+
mistral: {
|
|
62
|
+
name: 'Mistral AI',
|
|
63
|
+
description: 'Mistral models including Mistral Large and Codestral',
|
|
64
|
+
baseUrl: 'https://api.mistral.ai/v1',
|
|
65
|
+
requiredEnvVars: ['MISTRAL_API_KEY'],
|
|
66
|
+
supportsStreaming: true,
|
|
67
|
+
docsUrl: 'https://docs.mistral.ai/',
|
|
68
|
+
models: mistralModels,
|
|
69
|
+
},
|
|
70
|
+
cohere: {
|
|
71
|
+
name: 'Cohere',
|
|
72
|
+
description: 'Cohere Command and Embed models',
|
|
73
|
+
baseUrl: 'https://api.cohere.ai/v1',
|
|
74
|
+
requiredEnvVars: ['COHERE_API_KEY'],
|
|
75
|
+
supportsStreaming: true,
|
|
76
|
+
docsUrl: 'https://docs.cohere.com/',
|
|
77
|
+
models: [],
|
|
78
|
+
},
|
|
79
|
+
groq: {
|
|
80
|
+
name: 'Groq',
|
|
81
|
+
description: 'Ultra-fast inference for open models',
|
|
82
|
+
baseUrl: 'https://api.groq.com/openai/v1',
|
|
83
|
+
requiredEnvVars: ['GROQ_API_KEY'],
|
|
84
|
+
supportsStreaming: true,
|
|
85
|
+
docsUrl: 'https://console.groq.com/docs',
|
|
86
|
+
models: groqModels,
|
|
87
|
+
},
|
|
88
|
+
ollama: {
|
|
89
|
+
name: 'Ollama',
|
|
90
|
+
description: 'Local LLM inference with Ollama',
|
|
91
|
+
baseUrl: 'http://localhost:11434/api',
|
|
92
|
+
requiredEnvVars: [],
|
|
93
|
+
optionalEnvVars: ['OLLAMA_HOST'],
|
|
94
|
+
supportsStreaming: true,
|
|
95
|
+
docsUrl: 'https://ollama.com/',
|
|
96
|
+
models: [],
|
|
97
|
+
},
|
|
98
|
+
huggingface: {
|
|
99
|
+
name: 'Hugging Face',
|
|
100
|
+
description: 'Hugging Face Inference API',
|
|
101
|
+
baseUrl: 'https://api-inference.huggingface.co',
|
|
102
|
+
requiredEnvVars: ['HUGGINGFACE_API_KEY'],
|
|
103
|
+
supportsStreaming: true,
|
|
104
|
+
docsUrl: 'https://huggingface.co/docs/api-inference',
|
|
105
|
+
models: [],
|
|
106
|
+
},
|
|
107
|
+
'together-ai': {
|
|
108
|
+
name: 'Together AI',
|
|
109
|
+
description: 'Together AI inference platform',
|
|
110
|
+
baseUrl: 'https://api.together.xyz/v1',
|
|
111
|
+
requiredEnvVars: ['TOGETHER_API_KEY'],
|
|
112
|
+
supportsStreaming: true,
|
|
113
|
+
docsUrl: 'https://docs.together.ai/',
|
|
114
|
+
models: [],
|
|
115
|
+
},
|
|
116
|
+
replicate: {
|
|
117
|
+
name: 'Replicate',
|
|
118
|
+
description: 'Replicate model hosting platform',
|
|
119
|
+
baseUrl: 'https://api.replicate.com/v1',
|
|
120
|
+
requiredEnvVars: ['REPLICATE_API_TOKEN'],
|
|
121
|
+
supportsStreaming: true,
|
|
122
|
+
docsUrl: 'https://replicate.com/docs',
|
|
123
|
+
models: [],
|
|
124
|
+
},
|
|
125
|
+
deepseek: {
|
|
126
|
+
name: 'DeepSeek',
|
|
127
|
+
description: 'DeepSeek AI models including V3 and R1',
|
|
128
|
+
baseUrl: 'https://api.deepseek.com',
|
|
129
|
+
requiredEnvVars: ['DEEPSEEK_API_KEY'],
|
|
130
|
+
supportsStreaming: true,
|
|
131
|
+
docsUrl: 'https://platform.deepseek.com/docs',
|
|
132
|
+
models: deepseekModels,
|
|
133
|
+
},
|
|
134
|
+
xai: {
|
|
135
|
+
name: 'xAI',
|
|
136
|
+
description: 'Grok models from xAI',
|
|
137
|
+
baseUrl: 'https://api.x.ai/v1',
|
|
138
|
+
requiredEnvVars: ['XAI_API_KEY'],
|
|
139
|
+
supportsStreaming: true,
|
|
140
|
+
docsUrl: 'https://docs.x.ai/',
|
|
141
|
+
models: xaiModels,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Get provider configuration by ID
|
|
146
|
+
*/
|
|
147
|
+
export function getProvider(id) {
|
|
148
|
+
const config = providerConfigs[id];
|
|
149
|
+
if (!config) {
|
|
150
|
+
throw new Error(`Unknown provider: ${id}`);
|
|
151
|
+
}
|
|
152
|
+
return { id, ...config };
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get all provider configurations
|
|
156
|
+
*/
|
|
157
|
+
export function getAllProviders() {
|
|
158
|
+
return Object.entries(providerConfigs).map(([id, config]) => ({
|
|
159
|
+
id: id,
|
|
160
|
+
...config,
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Check if provider credentials are configured from environment
|
|
165
|
+
*/
|
|
166
|
+
export function isProviderConfigured(id) {
|
|
167
|
+
const config = getProvider(id);
|
|
168
|
+
return config.requiredEnvVars.every((envVar) => !!process.env[envVar]);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get credentials from environment for a provider
|
|
172
|
+
*/
|
|
173
|
+
export function getCredentialsFromEnv(id) {
|
|
174
|
+
const config = getProvider(id);
|
|
175
|
+
const credentials = {};
|
|
176
|
+
// Map common env var patterns to credentials
|
|
177
|
+
for (const envVar of [
|
|
178
|
+
...config.requiredEnvVars,
|
|
179
|
+
...(config.optionalEnvVars || []),
|
|
180
|
+
]) {
|
|
181
|
+
const value = process.env[envVar];
|
|
182
|
+
if (!value)
|
|
183
|
+
continue;
|
|
184
|
+
if (envVar.includes('API_KEY') || envVar.includes('API_TOKEN')) {
|
|
185
|
+
credentials.apiKey = value;
|
|
186
|
+
}
|
|
187
|
+
else if (envVar.includes('ENDPOINT') || envVar.includes('BASE_URL')) {
|
|
188
|
+
credentials.baseUrl = value;
|
|
189
|
+
}
|
|
190
|
+
else if (envVar.includes('ORG')) {
|
|
191
|
+
credentials.organizationId = value;
|
|
192
|
+
}
|
|
193
|
+
else if (envVar.includes('PROJECT')) {
|
|
194
|
+
credentials.projectId = value;
|
|
195
|
+
}
|
|
196
|
+
else if (envVar.includes('REGION')) {
|
|
197
|
+
credentials.region = value;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return credentials;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Create a provider instance with credentials
|
|
204
|
+
*/
|
|
205
|
+
export function createProviderInstance(id, credentials) {
|
|
206
|
+
const config = getProvider(id);
|
|
207
|
+
const creds = credentials || getCredentialsFromEnv(id);
|
|
208
|
+
return {
|
|
209
|
+
config,
|
|
210
|
+
credentials: creds,
|
|
211
|
+
isConfigured() {
|
|
212
|
+
return config.requiredEnvVars.length === 0 || !!creds.apiKey;
|
|
213
|
+
},
|
|
214
|
+
getModel(modelId) {
|
|
215
|
+
return config.models.find((m) => m.id === modelId);
|
|
216
|
+
},
|
|
217
|
+
listModels() {
|
|
218
|
+
return [...config.models];
|
|
219
|
+
},
|
|
220
|
+
listModelsWithCapability(capability) {
|
|
221
|
+
return config.models.filter((m) => m.capabilities[capability]);
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Provider registry class for managing multiple providers
|
|
227
|
+
*/
|
|
228
|
+
export class ProviderRegistry {
|
|
229
|
+
instances = new Map();
|
|
230
|
+
/**
|
|
231
|
+
* Register a provider with credentials
|
|
232
|
+
*/
|
|
233
|
+
register(id, credentials) {
|
|
234
|
+
this.instances.set(id, createProviderInstance(id, credentials));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Register all providers with credentials from environment
|
|
238
|
+
*/
|
|
239
|
+
registerFromEnv() {
|
|
240
|
+
for (const id of Object.keys(providerConfigs)) {
|
|
241
|
+
if (isProviderConfigured(id)) {
|
|
242
|
+
this.register(id);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get a provider instance
|
|
248
|
+
*/
|
|
249
|
+
get(id) {
|
|
250
|
+
return this.instances.get(id);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get all registered providers
|
|
254
|
+
*/
|
|
255
|
+
getAll() {
|
|
256
|
+
return Array.from(this.instances.values());
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Check if a provider is registered
|
|
260
|
+
*/
|
|
261
|
+
has(id) {
|
|
262
|
+
return this.instances.has(id);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Find models across all providers with a capability
|
|
266
|
+
*/
|
|
267
|
+
findModelsWithCapability(capability) {
|
|
268
|
+
const models = [];
|
|
269
|
+
for (const instance of this.instances.values()) {
|
|
270
|
+
models.push(...instance.listModelsWithCapability(capability));
|
|
271
|
+
}
|
|
272
|
+
return models;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Find a model by ID across all providers
|
|
276
|
+
*/
|
|
277
|
+
findModel(modelId) {
|
|
278
|
+
for (const instance of this.instances.values()) {
|
|
279
|
+
const model = instance.getModel(modelId);
|
|
280
|
+
if (model)
|
|
281
|
+
return model;
|
|
282
|
+
}
|
|
283
|
+
return undefined;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Default global registry instance
|
|
288
|
+
*/
|
|
289
|
+
export const defaultRegistry = new ProviderRegistry();
|
|
290
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACL,YAAY,EACZ,eAAe,EACf,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,SAAS,GACV,MAAM,aAAa,CAAC;AAErB;;GAEG;AACH,MAAM,eAAe,GAAmD;IACtE,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,kDAAkD;QAC/D,OAAO,EAAE,2BAA2B;QACpC,eAAe,EAAE,CAAC,gBAAgB,CAAC;QACnC,eAAe,EAAE,CAAC,eAAe,EAAE,mBAAmB,CAAC;QACvD,iBAAiB,EAAE,IAAI;QACvB,O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AAE,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LLM Provider Types
|
|
3
|
+
* Core type definitions for providers, models, and capabilities
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Supported LLM provider identifiers
|
|
7
|
+
*/
|
|
8
|
+
export type ProviderId = 'openai' | 'anthropic' | 'azure-openai' | 'google' | 'aws-bedrock' | 'mistral' | 'cohere' | 'groq' | 'ollama' | 'huggingface' | 'together-ai' | 'replicate' | 'deepseek' | 'xai';
|
|
9
|
+
/**
|
|
10
|
+
* Model capabilities
|
|
11
|
+
*/
|
|
12
|
+
export interface ModelCapabilities {
|
|
13
|
+
/** Supports text generation */
|
|
14
|
+
chat: boolean;
|
|
15
|
+
/** Supports vision/image input */
|
|
16
|
+
vision: boolean;
|
|
17
|
+
/** Supports function/tool calling */
|
|
18
|
+
toolCalling: boolean;
|
|
19
|
+
/** Supports JSON mode output */
|
|
20
|
+
jsonMode: boolean;
|
|
21
|
+
/** Supports structured output with schemas */
|
|
22
|
+
structuredOutput: boolean;
|
|
23
|
+
/** Supports streaming responses */
|
|
24
|
+
streaming: boolean;
|
|
25
|
+
/** Supports embeddings generation */
|
|
26
|
+
embeddings: boolean;
|
|
27
|
+
/** Supports image generation */
|
|
28
|
+
imageGeneration: boolean;
|
|
29
|
+
/** Supports audio input/output */
|
|
30
|
+
audio: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Token pricing information
|
|
34
|
+
*/
|
|
35
|
+
export interface TokenPricing {
|
|
36
|
+
/** Cost per 1M input tokens in USD */
|
|
37
|
+
inputPerMillion: number;
|
|
38
|
+
/** Cost per 1M output tokens in USD */
|
|
39
|
+
outputPerMillion: number;
|
|
40
|
+
/** Cost per 1M cached input tokens (if supported) */
|
|
41
|
+
cachedInputPerMillion?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Model metadata
|
|
45
|
+
*/
|
|
46
|
+
export interface ModelMetadata {
|
|
47
|
+
/** Unique model identifier */
|
|
48
|
+
id: string;
|
|
49
|
+
/** Display name */
|
|
50
|
+
name: string;
|
|
51
|
+
/** Provider this model belongs to */
|
|
52
|
+
provider: ProviderId;
|
|
53
|
+
/** Maximum context window in tokens */
|
|
54
|
+
contextWindow: number;
|
|
55
|
+
/** Maximum output tokens (if different from context) */
|
|
56
|
+
maxOutputTokens?: number;
|
|
57
|
+
/** Model capabilities */
|
|
58
|
+
capabilities: ModelCapabilities;
|
|
59
|
+
/** Token pricing (if available) */
|
|
60
|
+
pricing?: TokenPricing;
|
|
61
|
+
/** Whether this model is deprecated */
|
|
62
|
+
deprecated?: boolean;
|
|
63
|
+
/** Recommended replacement model if deprecated */
|
|
64
|
+
replacement?: string;
|
|
65
|
+
/** Release date */
|
|
66
|
+
releaseDate?: string;
|
|
67
|
+
/** Additional model-specific metadata */
|
|
68
|
+
metadata?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Provider configuration
|
|
72
|
+
*/
|
|
73
|
+
export interface ProviderConfig {
|
|
74
|
+
/** Provider identifier */
|
|
75
|
+
id: ProviderId;
|
|
76
|
+
/** Display name */
|
|
77
|
+
name: string;
|
|
78
|
+
/** Provider description */
|
|
79
|
+
description: string;
|
|
80
|
+
/** Base API URL */
|
|
81
|
+
baseUrl: string;
|
|
82
|
+
/** Required environment variables */
|
|
83
|
+
requiredEnvVars: string[];
|
|
84
|
+
/** Optional environment variables */
|
|
85
|
+
optionalEnvVars?: string[];
|
|
86
|
+
/** Whether provider supports streaming */
|
|
87
|
+
supportsStreaming: boolean;
|
|
88
|
+
/** API documentation URL */
|
|
89
|
+
docsUrl?: string;
|
|
90
|
+
/** Available models for this provider */
|
|
91
|
+
models: ModelMetadata[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Credential configuration for a provider
|
|
95
|
+
*/
|
|
96
|
+
export interface ProviderCredentials {
|
|
97
|
+
/** API key or token */
|
|
98
|
+
apiKey?: string;
|
|
99
|
+
/** Base URL override */
|
|
100
|
+
baseUrl?: string;
|
|
101
|
+
/** Organization ID (for providers that support it) */
|
|
102
|
+
organizationId?: string;
|
|
103
|
+
/** Project ID (for providers that support it) */
|
|
104
|
+
projectId?: string;
|
|
105
|
+
/** Region (for cloud providers) */
|
|
106
|
+
region?: string;
|
|
107
|
+
/** Additional provider-specific options */
|
|
108
|
+
options?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Provider instance with credentials
|
|
112
|
+
*/
|
|
113
|
+
export interface ProviderInstance {
|
|
114
|
+
/** Provider configuration */
|
|
115
|
+
config: ProviderConfig;
|
|
116
|
+
/** Active credentials */
|
|
117
|
+
credentials: ProviderCredentials;
|
|
118
|
+
/** Check if provider is properly configured */
|
|
119
|
+
isConfigured: () => boolean;
|
|
120
|
+
/** Get a specific model by ID */
|
|
121
|
+
getModel: (modelId: string) => ModelMetadata | undefined;
|
|
122
|
+
/** List all available models */
|
|
123
|
+
listModels: () => ModelMetadata[];
|
|
124
|
+
/** List models with specific capability */
|
|
125
|
+
listModelsWithCapability: (capability: keyof ModelCapabilities) => ModelMetadata[];
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,QAAQ,GACR,WAAW,GACX,cAAc,GACd,QAAQ,GACR,aAAa,GACb,SAAS,GACT,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,aAAa,GACb,aAAa,GACb,WAAW,GACX,UAAU,GACV,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+BAA+B;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,kCAAkC;IAClC,MAAM,EA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|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tashiscool/providers",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "LLM provider registry with model metadata and capabilities",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"llm",
|
|
24
|
+
"ai",
|
|
25
|
+
"providers",
|
|
26
|
+
"openai",
|
|
27
|
+
"anthropic",
|
|
28
|
+
"models",
|
|
29
|
+
"registry"
|
|
30
|
+
],
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.0.0",
|
|
34
|
+
"typescript": "^5.4.0",
|
|
35
|
+
"vitest": "^1.6.0"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "https://github.com/tashiscool/llm-utils.git",
|
|
40
|
+
"directory": "packages/providers"
|
|
41
|
+
}
|
|
42
|
+
}
|