@aeye/replicate 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 ADDED
@@ -0,0 +1,610 @@
1
+ # @aeye/replicate
2
+
3
+ Replicate provider for the @aeye (AI TypeScript) framework. This package provides integration with Replicate's platform for running AI models in the cloud.
4
+
5
+ ## Features
6
+
7
+ - **Thousands of Models**: Access to a vast library of open-source AI models
8
+ - **Model Adapters**: Flexible adapter system for handling model-specific schemas
9
+ - **Multiple Capabilities**: Support for chat, image generation, transcription, and more
10
+ - **Streaming**: Real-time streaming for supported models
11
+ - **Custom Models**: Deploy and use your own models
12
+ - **Version Control**: Pin specific model versions for reproducibility
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @aeye/replicate @aeye/ai @aeye/core replicate zod
18
+ ```
19
+
20
+ ## Important Note
21
+
22
+ **Replicate has no consistent API** - each model has its own input/output schema. This means you need to register model adapters for each model you want to use. The @aeye framework provides a flexible adapter system to handle this.
23
+
24
+ ## Quick Start
25
+
26
+ ```typescript
27
+ import { ReplicateProvider } from '@aeye/replicate';
28
+ import { AI } from '@aeye/ai';
29
+ import { createLlama3Adapter } from '@aeye/replicate';
30
+
31
+ // Create provider with adapters
32
+ const replicate = new ReplicateProvider({
33
+ apiKey: process.env.REPLICATE_API_KEY!,
34
+ transformers: {
35
+ 'meta/meta-llama-3-70b-instruct': createLlama3Adapter(),
36
+ },
37
+ });
38
+
39
+ // Use with AI instance
40
+ const ai = AI.with()
41
+ .providers({ replicate })
42
+ .create();
43
+
44
+ // Make a request
45
+ const response = await ai.chat.get([
46
+ { role: 'user', content: 'Explain neural networks' }
47
+ ], {
48
+ metadata: { model: 'meta/meta-llama-3-70b-instruct' }
49
+ });
50
+
51
+ console.log(response.content);
52
+ ```
53
+
54
+ ## Configuration
55
+
56
+ ### Basic Configuration
57
+
58
+ ```typescript
59
+ import { ReplicateProvider, ReplicateConfig } from '@aeye/replicate';
60
+
61
+ const config: ReplicateConfig = {
62
+ apiKey: process.env.REPLICATE_API_KEY!,
63
+ transformers: {
64
+ // Register adapters for models you want to use
65
+ 'meta/meta-llama-3-70b-instruct': createLlama3Adapter(),
66
+ 'stability-ai/sdxl': createSDXLAdapter(),
67
+ },
68
+ };
69
+
70
+ const provider = new ReplicateProvider(config);
71
+ ```
72
+
73
+ ### Custom Base URL
74
+
75
+ ```typescript
76
+ const provider = new ReplicateProvider({
77
+ apiKey: process.env.REPLICATE_API_KEY!,
78
+ baseUrl: 'https://custom.replicate.com', // Optional custom endpoint
79
+ transformers: {
80
+ // ... your adapters
81
+ },
82
+ });
83
+ ```
84
+
85
+ ## Model Adapters
86
+
87
+ Model adapters translate between the @aeye standard interface and each model's specific input/output format.
88
+
89
+ ### Using Built-in Adapters
90
+
91
+ ```typescript
92
+ import {
93
+ createLlama3Adapter,
94
+ createSDXLAdapter,
95
+ createWhisperAdapter,
96
+ } from '@aeye/replicate';
97
+
98
+ const provider = new ReplicateProvider({
99
+ apiKey: process.env.REPLICATE_API_KEY!,
100
+ transformers: {
101
+ // Chat model
102
+ 'meta/meta-llama-3-70b-instruct': createLlama3Adapter(),
103
+
104
+ // Image generation
105
+ 'stability-ai/sdxl': createSDXLAdapter(),
106
+
107
+ // Audio transcription
108
+ 'openai/whisper': createWhisperAdapter(),
109
+ },
110
+ });
111
+ ```
112
+
113
+ ### Creating Custom Adapters
114
+
115
+ TODO-FIX example
116
+
117
+ ```typescript
118
+ import { ModelTransformer } from '@aeye/ai';
119
+ import type { Request, Response } from '@aeye/core';
120
+
121
+ const myCustomAdapter: ModelTransformer = {
122
+ // Convert @aeye request to model-specific input
123
+ transformRequest: (request: Request) => {
124
+ return {
125
+ prompt: request.messages[request.messages.length - 1].content,
126
+ temperature: request.temperature ?? 0.7,
127
+ max_tokens: request.maxTokens ?? 500,
128
+ // ... other model-specific parameters
129
+ };
130
+ },
131
+
132
+ // Convert model output to @aeye response
133
+ transformResponse: (output: unknown): Response => {
134
+ const result = output as { text: string; tokens_used?: number };
135
+
136
+ return {
137
+ content: result.text,
138
+ finishReason: 'stop',
139
+ usage: {
140
+ inputTokens: 0,
141
+ outputTokens: result.tokens_used ?? 0,
142
+ totalTokens: result.tokens_used ?? 0,
143
+ },
144
+ };
145
+ },
146
+
147
+ // Optional: streaming support
148
+ transformStreamChunk: (chunk: unknown) => {
149
+ const data = chunk as { text?: string };
150
+
151
+ return {
152
+ content: data.text,
153
+ };
154
+ },
155
+ };
156
+
157
+ // Register the adapter
158
+ const provider = new ReplicateProvider({
159
+ apiKey: process.env.REPLICATE_API_KEY!,
160
+ transformers: {
161
+ 'owner/my-custom-model': myCustomAdapter,
162
+ },
163
+ });
164
+ ```
165
+
166
+ ## Usage Examples
167
+
168
+ ### Chat Completions
169
+
170
+ ```typescript
171
+ import { AI } from '@aeye/ai';
172
+ import { ReplicateProvider, createLlama3Adapter } from '@aeye/replicate';
173
+
174
+ const replicate = new ReplicateProvider({
175
+ apiKey: process.env.REPLICATE_API_KEY!,
176
+ transformers: {
177
+ 'meta/meta-llama-3-70b-instruct': createLlama3Adapter(),
178
+ },
179
+ });
180
+
181
+ const ai = AI.with()
182
+ .providers({ replicate })
183
+ .create();
184
+
185
+ const response = await ai.chat.get([
186
+ { role: 'system', content: 'You are a helpful assistant.' },
187
+ { role: 'user', content: 'What is machine learning?' }
188
+ ], {
189
+ metadata: { model: 'meta/meta-llama-3-70b-instruct' }
190
+ });
191
+
192
+ console.log(response.content);
193
+ ```
194
+
195
+ ### Streaming Chat
196
+
197
+ ```typescript
198
+ for await (const chunk of ai.chat.stream([
199
+ { role: 'user', content: 'Write a story about a robot' }
200
+ ], {
201
+ metadata: { model: 'meta/meta-llama-3-70b-instruct' }
202
+ })) {
203
+ if (chunk.content) {
204
+ process.stdout.write(chunk.content);
205
+ }
206
+ }
207
+ ```
208
+
209
+ ### Image Generation
210
+
211
+ ```typescript
212
+ import { createSDXLAdapter } from '@aeye/replicate';
213
+
214
+ const replicate = new ReplicateProvider({
215
+ apiKey: process.env.REPLICATE_API_KEY!,
216
+ transformers: {
217
+ 'stability-ai/sdxl': createSDXLAdapter(),
218
+ },
219
+ });
220
+
221
+ const ai = AI.with()
222
+ .providers({ replicate })
223
+ .create();
224
+
225
+ const imageResponse = await ai.image.generate.get({
226
+ prompt: 'A serene mountain landscape at sunset',
227
+ size: '1024x1024',
228
+ }, {
229
+ metadata: { model: 'stability-ai/sdxl' }
230
+ });
231
+
232
+ console.log('Generated image URL:', imageResponse.images[0].url);
233
+ ```
234
+
235
+ ### Audio Transcription
236
+
237
+ ```typescript
238
+ import { createWhisperAdapter } from '@aeye/replicate';
239
+ import fs from 'fs';
240
+
241
+ const replicate = new ReplicateProvider({
242
+ apiKey: process.env.REPLICATE_API_KEY!,
243
+ transformers: {
244
+ 'openai/whisper': createWhisperAdapter(),
245
+ },
246
+ });
247
+
248
+ const ai = AI.with()
249
+ .providers({ replicate })
250
+ .create();
251
+
252
+ const audioBuffer = fs.readFileSync('audio.mp3');
253
+
254
+ const transcription = await ai.transcribe.get({
255
+ audio: audioBuffer,
256
+ }, {
257
+ metadata: { model: 'openai/whisper' }
258
+ });
259
+
260
+ console.log('Transcription:', transcription.text);
261
+ ```
262
+
263
+ ### Using Specific Model Versions
264
+
265
+ ```typescript
266
+ // Pin to a specific version for reproducibility
267
+ const response = await ai.chat.get(messages, {
268
+ metadata: {
269
+ model: 'meta/meta-llama-3-70b-instruct',
270
+ version: 'fbfb20b472b2f3bdd101412a9f70a0ed4fc0ced78a77ff00970ee7a2383c575d',
271
+ }
272
+ });
273
+ ```
274
+
275
+ ### Direct API Usage
276
+
277
+ ```typescript
278
+ const executor = replicate.createExecutor();
279
+
280
+ const response = await executor(
281
+ {
282
+ messages: [
283
+ { role: 'user', content: 'Hello!' }
284
+ ],
285
+ temperature: 0.7,
286
+ maxTokens: 500,
287
+ },
288
+ {},
289
+ { model: 'meta/meta-llama-3-70b-instruct' }
290
+ );
291
+ ```
292
+
293
+ ### List Available Models
294
+
295
+ ```typescript
296
+ const models = await replicate.listModels();
297
+
298
+ models.forEach(model => {
299
+ console.log(`${model.id}`);
300
+ console.log(` Description: ${model.metadata.description}`);
301
+ console.log(` Runs: ${model.metadata.runCount}`);
302
+ console.log(` Capabilities: ${Array.from(model.capabilities).join(', ')}`);
303
+ });
304
+ ```
305
+
306
+ ### Search Models
307
+
308
+ You can search for models with specific capabilities:
309
+
310
+ ```typescript
311
+ // Using the Replicate client directly
312
+ const client = new Replicate({ auth: process.env.REPLICATE_API_KEY! });
313
+
314
+ const results = await client.models.search({
315
+ query: 'text generation',
316
+ });
317
+
318
+ for await (const model of results) {
319
+ console.log(model.owner + '/' + model.name);
320
+ }
321
+ ```
322
+
323
+ ## Configuration Options
324
+
325
+ ### ReplicateConfig
326
+
327
+ | Property | Type | Required | Description |
328
+ |----------|------|----------|-------------|
329
+ | `apiKey` | `string` | Yes | Replicate API key from https://replicate.com/account/api-tokens |
330
+ | `baseUrl` | `string` | No | Custom base URL for API endpoint |
331
+ | `transformers` | `Record<string, ModelTransformer>` | No | Model adapters for request/response conversion |
332
+
333
+ ### ModelTransformer Interface
334
+
335
+ ```typescript
336
+ interface ModelTransformer {
337
+ // Convert @aeye request to model input
338
+ transformRequest: (request: Request) => Record<string, unknown>;
339
+
340
+ // Convert model output to @aeye response
341
+ transformResponse: (output: unknown) => Response;
342
+
343
+ // Optional: convert stream chunks
344
+ transformStreamChunk?: (chunk: unknown) => Chunk;
345
+
346
+ // Optional: convert image request
347
+ transformImageRequest?: (request: ImageGenerationRequest) => Record<string, unknown>;
348
+
349
+ // Optional: convert image response
350
+ transformImageResponse?: (output: unknown) => ImageGenerationResponse;
351
+
352
+ // Optional: convert transcription request
353
+ transformTranscriptionRequest?: (request: TranscriptionRequest) => Record<string, unknown>;
354
+
355
+ // Optional: convert transcription response
356
+ transformTranscriptionResponse?: (output: unknown) => TranscriptionResponse;
357
+ }
358
+ ```
359
+
360
+ ## Built-in Adapters
361
+
362
+ The package includes adapters for popular models:
363
+
364
+ ### Chat Models
365
+
366
+ - **`createLlama3Adapter()`**: Meta Llama 3 models
367
+ - `meta/meta-llama-3-8b-instruct`
368
+ - `meta/meta-llama-3-70b-instruct`
369
+
370
+ ### Image Generation
371
+
372
+ - **`createSDXLAdapter()`**: Stable Diffusion XL
373
+ - `stability-ai/sdxl`
374
+
375
+ - **`createFluxAdapter()`**: Flux models
376
+ - `black-forest-labs/flux-schnell`
377
+ - `black-forest-labs/flux-dev`
378
+
379
+ ### Audio
380
+
381
+ - **`createWhisperAdapter()`**: OpenAI Whisper
382
+ - `openai/whisper`
383
+
384
+ ### Embeddings
385
+
386
+ - **`createBGEAdapter()`**: BGE embeddings
387
+ - `replicate/bge-large-en-v1.5`
388
+
389
+ More adapters are being added regularly. Check the package exports for the latest list.
390
+
391
+ ## Error Handling
392
+
393
+ ```typescript
394
+ try {
395
+ const response = await ai.chat.get(messages, {
396
+ metadata: { model: 'meta/meta-llama-3-70b-instruct' }
397
+ });
398
+ } catch (error) {
399
+ if (error.message.includes('No transformer registered')) {
400
+ console.error('Missing model adapter - register a transformer for this model');
401
+ } else if (error.message.includes('Rate limit')) {
402
+ console.error('Rate limit exceeded');
403
+ } else {
404
+ console.error('Error:', error);
405
+ }
406
+ }
407
+ ```
408
+
409
+ ## Model Format
410
+
411
+ Replicate models use the format `owner/model-name`:
412
+
413
+ - `meta/meta-llama-3-70b-instruct`
414
+ - `stability-ai/sdxl`
415
+ - `openai/whisper`
416
+ - `mistralai/mixtral-8x7b-instruct-v0.1`
417
+
418
+ To use a specific version, append the version ID:
419
+
420
+ - `meta/meta-llama-3-70b-instruct:fbfb20b472b2f3bdd101412a9f70a0ed4fc0ced78a77ff00970ee7a2383c575d`
421
+
422
+ ## Best Practices
423
+
424
+ 1. **Register Adapters**: Always register adapters for models you use
425
+ ```typescript
426
+ transformers: {
427
+ 'owner/model': createAdapter(),
428
+ }
429
+ ```
430
+
431
+ 2. **Pin Versions**: Use specific versions in production
432
+ ```typescript
433
+ model: 'owner/model:version-id'
434
+ ```
435
+
436
+ 3. **Handle Missing Adapters**: Provide helpful errors
437
+ ```typescript
438
+ if (!transformer) {
439
+ throw new Error('No adapter registered for ' + model);
440
+ }
441
+ ```
442
+
443
+ 4. **Cache Model Lists**: Replicate's model list is large
444
+ ```typescript
445
+ const models = await replicate.listModels();
446
+ // Cache the results
447
+ ```
448
+
449
+ 5. **Monitor Usage**: Replicate charges per prediction
450
+ ```typescript
451
+ console.log('Tokens used:', response.usage.totalTokens);
452
+ ```
453
+
454
+ 6. **Test Adapters**: Verify adapter behavior with test data
455
+ ```typescript
456
+ const testRequest = { messages: [{ role: 'user', content: 'test' }] };
457
+ const input = adapter.transformRequest(testRequest);
458
+ console.log('Model input:', input);
459
+ ```
460
+
461
+ ## Creating Model Adapters
462
+
463
+ Here's a complete example of creating an adapter:
464
+
465
+ ```typescript
466
+ import { ModelTransformer } from '@aeye/ai';
467
+ import type { Request, Response, Chunk } from '@aeye/core';
468
+
469
+ export function createMyModelAdapter(): ModelTransformer {
470
+ return {
471
+ transformRequest: (request: Request) => {
472
+ // Extract the last user message as the prompt
473
+ const lastMessage = request.messages[request.messages.length - 1];
474
+ const prompt = typeof lastMessage.content === 'string'
475
+ ? lastMessage.content
476
+ : lastMessage.content.map(c => c.content).join(' ');
477
+
478
+ // Build model-specific input
479
+ return {
480
+ prompt,
481
+ temperature: request.temperature ?? 0.7,
482
+ max_length: request.maxTokens ?? 500,
483
+ top_p: request.topP,
484
+ stop_sequences: Array.isArray(request.stop)
485
+ ? request.stop
486
+ : request.stop
487
+ ? [request.stop]
488
+ : undefined,
489
+ };
490
+ },
491
+
492
+ transformResponse: (output: unknown): Response => {
493
+ const result = output as {
494
+ output: string[];
495
+ metrics?: { predict_time?: number };
496
+ };
497
+
498
+ // Combine output array into single string
499
+ const content = result.output.join('');
500
+
501
+ return {
502
+ content,
503
+ finishReason: 'stop',
504
+ usage: {
505
+ inputTokens: 0, // Replicate doesn't always provide token counts
506
+ outputTokens: 0,
507
+ totalTokens: 0,
508
+ },
509
+ };
510
+ },
511
+
512
+ transformStreamChunk: (chunk: unknown) => {
513
+ const data = chunk as { output?: string };
514
+
515
+ return {
516
+ content: data.output,
517
+ };
518
+ },
519
+ };
520
+ }
521
+ ```
522
+
523
+ ## API Reference
524
+
525
+ ### ReplicateProvider
526
+
527
+ **Constructor**: `new ReplicateProvider(config: ReplicateConfig)`
528
+
529
+ **Methods**:
530
+ - `createExecutor<TContext, TMetadata>(config?)` - Create executor with adapters
531
+ - `createStreamer<TContext, TMetadata>(config?)` - Create streamer with adapters
532
+ - `listModels(config?)` - List available models from Replicate
533
+ - `generateImage<TContext>(request, ctx, config?)` - Generate images
534
+ - `transcribe<TContext>(request, ctx, config?)` - Transcribe audio
535
+ - `embed<TContext>(request, ctx, config?)` - Generate embeddings
536
+
537
+ ## Supported Features
538
+
539
+ - ✅ Chat completions (with adapters)
540
+ - ✅ Streaming (model-dependent)
541
+ - ✅ Image generation (with adapters)
542
+ - ✅ Audio transcription (with adapters)
543
+ - ✅ Embeddings (with adapters)
544
+ - ✅ Custom models
545
+ - ✅ Version pinning
546
+ - ❌ Function calling (model-dependent)
547
+ - ❌ Structured outputs (model-dependent)
548
+
549
+ Feature availability depends on the specific model and adapter.
550
+
551
+ ## Finding Models
552
+
553
+ Browse available models at:
554
+ - https://replicate.com/explore
555
+
556
+ Popular model categories:
557
+ - **Language Models**: Llama, Mistral, Mixtral, etc.
558
+ - **Image Generation**: SDXL, Flux, ControlNet, etc.
559
+ - **Audio**: Whisper, MusicGen, etc.
560
+ - **Video**: Stable Video Diffusion, etc.
561
+ - **Image Enhancement**: Upscaling, face restoration, etc.
562
+
563
+ ## Getting an API Key
564
+
565
+ 1. Visit https://replicate.com
566
+ 2. Create an account or sign in
567
+ 3. Navigate to https://replicate.com/account/api-tokens
568
+ 4. Generate a new API token
569
+ 5. Store it securely in your environment variables
570
+
571
+ ## Related Packages
572
+
573
+ - **[@aeye/core](../core)**: Core @aeye framework types and interfaces
574
+ - **[@aeye/ai](../ai)**: AI abstractions and utilities
575
+ - **[@aeye/openai](../openai)**: OpenAI provider
576
+ - **[@aeye/anthropic](../anthropic)**: Anthropic Claude provider
577
+ - **[@aeye/openrouter](../openrouter)**: Multi-provider gateway
578
+
579
+ ## Links
580
+
581
+ - [Replicate Website](https://replicate.com)
582
+ - [Replicate Documentation](https://replicate.com/docs)
583
+ - [Replicate Models](https://replicate.com/explore)
584
+ - [Replicate API Reference](https://replicate.com/docs/reference/http)
585
+ - [Replicate Pricing](https://replicate.com/pricing)
586
+
587
+ ## License
588
+
589
+ MIT
590
+
591
+ ## Contributing
592
+
593
+ Contributions are welcome, especially new model adapters! Please see the main [@aeye repository](https://github.com/ClickerMonkey/aeye) for contribution guidelines.
594
+
595
+ ### Contributing Adapters
596
+
597
+ To contribute a new model adapter:
598
+
599
+ 1. Create the adapter function in `src/adapters.ts`
600
+ 2. Export it from `src/index.ts`
601
+ 3. Add tests for the adapter
602
+ 4. Update this README with usage examples
603
+ 5. Submit a pull request
604
+
605
+ ## Support
606
+
607
+ For issues and questions:
608
+ - GitHub Issues: https://github.com/ClickerMonkey/aeye/issues
609
+ - Documentation: https://github.com/ClickerMonkey/aeye
610
+ - Replicate Discord: https://discord.gg/replicate
@@ -0,0 +1,2 @@
1
+ export * from './replicate';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './replicate';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Replicate Provider
3
+ *
4
+ * Provider for Replicate API with model adapter support.
5
+ * Replicate has no consistent API - each model has its own input/output schema.
6
+ * Users must register ModelAdapters for each model they want to use.
7
+ */
8
+ import type { AIContextAny, AIMetadataAny, Chunk, EmbeddingRequest, EmbeddingResponse, ImageAnalyzeRequest, ImageEditRequest, ImageGenerationRequest, ImageGenerationResponse, ModelInfo, ModelTransformer, Provider, SpeechRequest, SpeechResponse, TranscriptionRequest, TranscriptionResponse } from '@aeye/ai';
9
+ import { type Executor, type Streamer, type Response } from '@aeye/core';
10
+ export interface ReplicateConfig {
11
+ apiKey: string;
12
+ baseUrl?: string;
13
+ /**
14
+ * Model-specific transformers for request/response conversion
15
+ * Map of model ID (owner/name) to transformer
16
+ */
17
+ transformers?: Record<string, ModelTransformer>;
18
+ }
19
+ export declare class ReplicateProvider implements Provider<ReplicateConfig> {
20
+ readonly name = "replicate";
21
+ readonly config: ReplicateConfig;
22
+ constructor(config: ReplicateConfig);
23
+ /**
24
+ * List available models from Replicate
25
+ *
26
+ * Note: This only lists models from specific collections.
27
+ * Users can still use any Replicate model by specifying the full owner/name.
28
+ */
29
+ listModels(config?: ReplicateConfig): Promise<ModelInfo[]>;
30
+ /**
31
+ * Check Replicate API health
32
+ */
33
+ checkHealth(config?: ReplicateConfig): Promise<boolean>;
34
+ /**
35
+ * Get transformer for a specific model
36
+ */
37
+ private getTransformer;
38
+ /**
39
+ * Does a simple request
40
+ *
41
+ * @param config
42
+ * @param request
43
+ * @param ctx
44
+ * @param metadata
45
+ */
46
+ private doRequest;
47
+ /**
48
+ * Does a simple request
49
+ *
50
+ * @param config
51
+ * @param request
52
+ * @param ctx
53
+ * @param metadata
54
+ */
55
+ private doStream;
56
+ /**
57
+ * Create executor for chat/completion
58
+ *
59
+ * Note: Chat requires a model transformer in config for request/response conversion
60
+ */
61
+ createExecutor(config?: ReplicateConfig): Executor<AIContextAny, AIMetadataAny>;
62
+ /**
63
+ * Create streamer for chat/completion
64
+ */
65
+ createStreamer(config?: ReplicateConfig): Streamer<AIContextAny, AIMetadataAny>;
66
+ /**
67
+ * Generate image using Replicate
68
+ *
69
+ * Requires a ModelTransformer for the specific model being used.
70
+ */
71
+ generateImage(request: ImageGenerationRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<ImageGenerationResponse>;
72
+ /**
73
+ * Generate image using Replicate
74
+ *
75
+ * Requires a ModelTransformer for the specific model being used.
76
+ */
77
+ generateImageStream(request: ImageGenerationRequest, ctx: AIContextAny, config?: ReplicateConfig): AsyncGenerator<never, AsyncGenerator<import("@aeye/ai").ImageGenerationChunk, void, unknown>, unknown>;
78
+ /**
79
+ * Edit image using Replicate
80
+ *
81
+ * Requires a ModelTransformer for the specific model being used.
82
+ */
83
+ editImage(request: ImageEditRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<ImageGenerationResponse>;
84
+ /**
85
+ * Edit image using Replicate
86
+ *
87
+ * Requires a ModelTransformer for the specific model being used.
88
+ */
89
+ editImageStream(request: ImageEditRequest, ctx: AIContextAny, config?: ReplicateConfig): AsyncGenerator<never, AsyncGenerator<import("@aeye/ai").ImageGenerationChunk, void, unknown>, unknown>;
90
+ /**
91
+ * Analyze image using Replicate
92
+ *
93
+ * Requires a ModelTransformer for the specific model being used.
94
+ */
95
+ analyzeImage(request: ImageAnalyzeRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<Response>;
96
+ /**
97
+ * Analyze image using Replicate
98
+ *
99
+ * Requires a ModelTransformer for the specific model being used.
100
+ */
101
+ analyzeImageStream(request: ImageAnalyzeRequest, ctx: AIContextAny, config?: ReplicateConfig): AsyncGenerator<never, AsyncGenerator<Chunk, void, unknown>, unknown>;
102
+ /**
103
+ * Transcribe audio using Replicate
104
+ *
105
+ * Requires a ModelTransformer for the specific model being used.
106
+ */
107
+ transcribe(request: TranscriptionRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<TranscriptionResponse>;
108
+ /**
109
+ * Transcribe audio using Replicate
110
+ *
111
+ * Requires a ModelTransformer for the specific model being used.
112
+ */
113
+ transcribeStream(request: TranscriptionRequest, ctx: AIContextAny, config?: ReplicateConfig): AsyncGenerator<never, AsyncGenerator<import("@aeye/ai").TranscriptionChunk, void, unknown>, unknown>;
114
+ /**
115
+ * Generate speech using Replicate
116
+ *
117
+ * Requires a ModelTransformer for the specific model being used.
118
+ */
119
+ speech(request: SpeechRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<SpeechResponse>;
120
+ /**
121
+ * Generate embeddings using Replicate
122
+ *
123
+ * Requires a ModelTransformer for the specific model being used.
124
+ */
125
+ embed(request: EmbeddingRequest, ctx: AIContextAny, config?: ReplicateConfig): Promise<EmbeddingResponse>;
126
+ }
127
+ //# sourceMappingURL=replicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replicate.d.ts","sourceRoot":"","sources":["../src/replicate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EAEvB,SAAS,EAET,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAkD,KAAK,QAAQ,EAAgB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAOvI,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CACjD;AA8ID,qBAAa,iBAAkB,YAAW,QAAQ,CAAC,eAAe,CAAC;IACjE,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;gBAErB,MAAM,EAAE,eAAe;IAInC;;;;;OAKG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,eA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AoB,EAC7B,GAAG,EAAE,YAAY,EACjB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAIjC;;;;OAIG;IACI,gBAAgB,CACrB,OAAO,EAAE,oBAAoB,EAC7B,GAAG,EAAE,YAAY,EACjB,MAAM,CAAC,EAAE,eAAe;IAK1B;;;;OAIG;IACG,MAAM,CACV,OAAO,EAAE,aAAa,EACtB,GAAG,EAAE,YAAY,EACjB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC;IAI1B;;;;OAIG;IACG,KAAK,CACT,OAAO,EAAE,gBAAgB,EACzB,GAAG,EAAE,YAAY,EACjB,MAAM,CAAC,EAAE,eAAe,GACvB,OAAO,CAAC,iBAAiB,CAAC;CAG9B"}
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Replicate Provider
3
+ *
4
+ * Provider for Replicate API with model adapter support.
5
+ * Replicate has no consistent API - each model has its own input/output schema.
6
+ * Users must register ModelAdapters for each model they want to use.
7
+ */
8
+ import { getModel } from '@aeye/core';
9
+ import Replicate from 'replicate';
10
+ // ============================================================================
11
+ // Helper Functions
12
+ // ============================================================================
13
+ function createClient(config) {
14
+ return new Replicate({
15
+ auth: config.apiKey,
16
+ baseUrl: config.baseUrl,
17
+ });
18
+ }
19
+ /**
20
+ * Convert Replicate model to ModelInfo
21
+ */
22
+ function convertModel(model) {
23
+ const modelId = `${model.owner}/${model.name}`;
24
+ // Try to detect capabilities from schema
25
+ const capabilities = new Set();
26
+ // Check if it's likely an image model based on name/description
27
+ const lowerName = model.name.toLowerCase();
28
+ const lowerDesc = (model.description || '').toLowerCase();
29
+ if (lowerName.includes('stable-diffusion') ||
30
+ lowerName.includes('sdxl') ||
31
+ lowerName.includes('flux') ||
32
+ lowerName.includes('imagen') ||
33
+ lowerDesc.includes('image generation') ||
34
+ lowerDesc.includes('text-to-image')) {
35
+ capabilities.add('image');
36
+ }
37
+ if (lowerName.includes('whisper') ||
38
+ lowerName.includes('transcribe') ||
39
+ lowerDesc.includes('speech-to-text') ||
40
+ lowerDesc.includes('transcription')) {
41
+ capabilities.add('hearing');
42
+ }
43
+ if (lowerName.includes('tts') ||
44
+ lowerName.includes('speech') ||
45
+ lowerDesc.includes('text-to-speech')) {
46
+ capabilities.add('audio');
47
+ }
48
+ if (lowerName.includes('embed') ||
49
+ lowerDesc.includes('embedding')) {
50
+ capabilities.add('embedding');
51
+ }
52
+ if (lowerName.includes('llm') ||
53
+ lowerName.includes('chat') ||
54
+ lowerName.includes('gpt') ||
55
+ lowerName.includes('llama') ||
56
+ lowerDesc.includes('language model')) {
57
+ capabilities.add('chat');
58
+ }
59
+ // Determine tier based on popularity
60
+ let tier = 'experimental';
61
+ if (model.run_count > 1000000) {
62
+ tier = 'flagship';
63
+ }
64
+ else if (model.run_count > 100000) {
65
+ tier = 'efficient';
66
+ }
67
+ return {
68
+ id: modelId,
69
+ provider: 'replicate',
70
+ name: model.name,
71
+ capabilities,
72
+ pricing: {},
73
+ contextWindow: 0, // Unknown without model-specific info
74
+ maxOutputTokens: undefined,
75
+ tier,
76
+ metadata: {
77
+ owner: model.owner,
78
+ description: model.description,
79
+ runCount: model.run_count,
80
+ githubUrl: model.github_url,
81
+ paperUrl: model.paper_url,
82
+ coverImageUrl: model.cover_image_url,
83
+ },
84
+ };
85
+ }
86
+ // ============================================================================
87
+ // Provider Implementation
88
+ // ============================================================================
89
+ export class ReplicateProvider {
90
+ name = 'replicate';
91
+ config;
92
+ constructor(config) {
93
+ this.config = config;
94
+ }
95
+ /**
96
+ * List available models from Replicate
97
+ *
98
+ * Note: This only lists models from specific collections.
99
+ * Users can still use any Replicate model by specifying the full owner/name.
100
+ */
101
+ async listModels(config) {
102
+ const repConfig = config || this.config;
103
+ const client = createClient(repConfig);
104
+ try {
105
+ // Get featured/popular models from Replicate
106
+ // We'll fetch a few popular collections
107
+ const collections = [
108
+ 'text-to-image',
109
+ 'image-to-text',
110
+ 'text-to-speech',
111
+ 'speech-to-text',
112
+ ];
113
+ const allModels = [];
114
+ for (const collection of collections) {
115
+ try {
116
+ // Fetch models from collection
117
+ const modelsIterator = await client.collections.get(collection);
118
+ if (modelsIterator.models) {
119
+ for (const model of modelsIterator.models) {
120
+ try {
121
+ allModels.push(convertModel(model));
122
+ }
123
+ catch (error) {
124
+ console.warn(`Failed to convert Replicate model ${model.name}:`, error);
125
+ }
126
+ }
127
+ }
128
+ }
129
+ catch (error) {
130
+ console.warn(`Failed to fetch Replicate collection ${collection}:`, error);
131
+ }
132
+ }
133
+ return allModels;
134
+ }
135
+ catch (error) {
136
+ console.error('Failed to list Replicate models:', error);
137
+ return [];
138
+ }
139
+ }
140
+ /**
141
+ * Check Replicate API health
142
+ */
143
+ async checkHealth(config) {
144
+ try {
145
+ const repConfig = config || this.config;
146
+ const client = createClient(repConfig);
147
+ // Try to fetch account info as a health check
148
+ await client.models.list();
149
+ return true;
150
+ }
151
+ catch (error) {
152
+ console.error('Replicate health check failed:', error);
153
+ return false;
154
+ }
155
+ }
156
+ /**
157
+ * Get transformer for a specific model
158
+ */
159
+ getTransformer(modelId, config) {
160
+ const repConfig = config || this.config;
161
+ return repConfig.transformers?.[modelId];
162
+ }
163
+ /**
164
+ * Does a simple request
165
+ *
166
+ * @param config
167
+ * @param request
168
+ * @param ctx
169
+ * @param metadata
170
+ */
171
+ async doRequest(config, request, ctx, metadata, requestSignal, getConverters) {
172
+ const repConfig = config || this.config;
173
+ // Extract model ID from metadata
174
+ const model = getModel(request.model || metadata?.model || ctx.metadata?.model);
175
+ if (!model) {
176
+ throw new Error('Replicate executor requires model ID in metadata');
177
+ }
178
+ // Get transformer for model
179
+ const transformer = this.getTransformer(model.id, repConfig);
180
+ if (!transformer) {
181
+ throw new Error(`Replicate model "${model.id}" requires a ModelTransformer. ` +
182
+ 'Add a transformer to your ReplicateConfig.transformers.');
183
+ }
184
+ // Ensure transformer has necessary methods
185
+ const { convertRequest, parseResponse } = getConverters(transformer);
186
+ if (!convertRequest || !parseResponse) {
187
+ throw new Error(`Replicate model "${model.id}" requires a ModelTransformer with convertRequest and parseResponse.` +
188
+ `Ensure the transformer for model "${model.id}" has the necessary methods.`);
189
+ }
190
+ const signal = requestSignal || ctx.signal;
191
+ const modelId = model.id;
192
+ const client = createClient(repConfig);
193
+ // Convert request using transformer
194
+ const input = convertRequest(request, ctx);
195
+ // Run prediction
196
+ const output = await client.run(modelId, { input, signal });
197
+ // Parse response using transformer
198
+ return parseResponse(output, ctx);
199
+ }
200
+ /**
201
+ * Does a simple request
202
+ *
203
+ * @param config
204
+ * @param request
205
+ * @param ctx
206
+ * @param metadata
207
+ */
208
+ async *doStream(config, request, ctx, metadata, requestSignal, getConverters) {
209
+ const repConfig = config || this.config;
210
+ // Extract model ID from metadata
211
+ const model = getModel(request.model || metadata?.model || ctx.metadata?.model);
212
+ if (!model) {
213
+ throw new Error('Replicate executor requires model ID in metadata');
214
+ }
215
+ // Get transformer for model
216
+ const transformer = this.getTransformer(model.id, repConfig);
217
+ if (!transformer) {
218
+ throw new Error(`Replicate model "${model.id}" requires a ModelTransformer. ` +
219
+ 'Add a transformer to your ReplicateConfig.transformers.');
220
+ }
221
+ // Ensure transformer has necessary methods
222
+ const { convertRequest, parseChunk } = getConverters(transformer);
223
+ if (!convertRequest || !parseChunk) {
224
+ throw new Error(`Replicate model "${model.id}" requires a ModelTransformer with convertRequest and parseChunk.` +
225
+ `Ensure the transformer for model "${model.id}" has the necessary methods.`);
226
+ }
227
+ const signal = requestSignal || ctx.signal;
228
+ const modelId = model.id;
229
+ const client = createClient(repConfig);
230
+ // Convert request using transformer
231
+ const input = convertRequest(request, ctx);
232
+ // Stream prediction
233
+ for await (const event of client.stream(modelId, { input, signal })) {
234
+ if (signal?.aborted) {
235
+ throw new Error('Request aborted');
236
+ }
237
+ // Parse chunk using transformer
238
+ const chunk = parseChunk(event, ctx);
239
+ yield chunk;
240
+ }
241
+ }
242
+ /**
243
+ * Create executor for chat/completion
244
+ *
245
+ * Note: Chat requires a model transformer in config for request/response conversion
246
+ */
247
+ createExecutor(config) {
248
+ const repConfig = config || this.config;
249
+ return async (request, ctx, metadata, signal) => {
250
+ return this.doRequest(repConfig, request, ctx, metadata, signal, (transformer) => transformer.chat || {});
251
+ };
252
+ }
253
+ /**
254
+ * Create streamer for chat/completion
255
+ */
256
+ createStreamer(config) {
257
+ const provider = this;
258
+ return async function* (request, ctx, metadata, signal) {
259
+ const stream = provider.doStream(config, request, ctx, metadata, signal, (transformer) => transformer.chat || {});
260
+ const chunks = [];
261
+ for await (const chunk of stream) {
262
+ chunks.push(chunk);
263
+ yield chunk;
264
+ }
265
+ return {
266
+ model: request.model || chunks.find(c => c.model)?.model,
267
+ content: chunks.map(c => c.content).join(''),
268
+ finishReason: chunks.find(c => c.finishReason)?.finishReason || 'stop',
269
+ usage: chunks.find(c => c.usage)?.usage,
270
+ reasoning: chunks.map(c => c.reasoning).filter(Boolean).join(''),
271
+ refusal: chunks.map(c => c.refusal).filter(Boolean).join(''),
272
+ toolCalls: chunks.map(c => c.toolCall).filter(tc => !!tc),
273
+ };
274
+ };
275
+ }
276
+ /**
277
+ * Generate image using Replicate
278
+ *
279
+ * Requires a ModelTransformer for the specific model being used.
280
+ */
281
+ async generateImage(request, ctx, config) {
282
+ return this.doRequest(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageGenerate || {});
283
+ }
284
+ /**
285
+ * Generate image using Replicate
286
+ *
287
+ * Requires a ModelTransformer for the specific model being used.
288
+ */
289
+ async *generateImageStream(request, ctx, config) {
290
+ return this.doStream(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageGenerate || {});
291
+ }
292
+ /**
293
+ * Edit image using Replicate
294
+ *
295
+ * Requires a ModelTransformer for the specific model being used.
296
+ */
297
+ async editImage(request, ctx, config) {
298
+ return this.doRequest(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageEdit || {});
299
+ }
300
+ /**
301
+ * Edit image using Replicate
302
+ *
303
+ * Requires a ModelTransformer for the specific model being used.
304
+ */
305
+ async *editImageStream(request, ctx, config) {
306
+ return this.doStream(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageEdit || {});
307
+ }
308
+ /**
309
+ * Analyze image using Replicate
310
+ *
311
+ * Requires a ModelTransformer for the specific model being used.
312
+ */
313
+ async analyzeImage(request, ctx, config) {
314
+ return this.doRequest(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageAnalyze || {});
315
+ }
316
+ /**
317
+ * Analyze image using Replicate
318
+ *
319
+ * Requires a ModelTransformer for the specific model being used.
320
+ */
321
+ async *analyzeImageStream(request, ctx, config) {
322
+ return this.doStream(config, request, ctx, undefined, ctx.signal, (transformer) => transformer.imageAnalyze || {});
323
+ }
324
+ /**
325
+ * Transcribe audio using Replicate
326
+ *
327
+ * Requires a ModelTransformer for the specific model being used.
328
+ */
329
+ async transcribe(request, ctx, config) {
330
+ return this.doRequest(config, request, ctx, undefined, undefined, (transformer) => transformer.transcribe || {});
331
+ }
332
+ /**
333
+ * Transcribe audio using Replicate
334
+ *
335
+ * Requires a ModelTransformer for the specific model being used.
336
+ */
337
+ async *transcribeStream(request, ctx, config) {
338
+ return this.doStream(config, request, ctx, undefined, undefined, (transformer) => transformer.transcribe || {});
339
+ }
340
+ /**
341
+ * Generate speech using Replicate
342
+ *
343
+ * Requires a ModelTransformer for the specific model being used.
344
+ */
345
+ async speech(request, ctx, config) {
346
+ return this.doRequest(config, request, ctx, undefined, undefined, (transformer) => transformer.speech || {});
347
+ }
348
+ /**
349
+ * Generate embeddings using Replicate
350
+ *
351
+ * Requires a ModelTransformer for the specific model being used.
352
+ */
353
+ async embed(request, ctx, config) {
354
+ return this.doRequest(config, request, ctx, undefined, undefined, (transformer) => transformer.embed || {});
355
+ }
356
+ }
357
+ //# sourceMappingURL=replicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replicate.js","sourceRoot":"","sources":["../src/replicate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsBH,OAAO,EAAwC,Q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AC,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACrH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CACd,OAA6B,EAC7B,GAAiB,EACjB,MAAwB;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACnH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAA,CAAE,gBAAgB,CACrB,OAA6B,EAC7B,GAAiB,EACjB,MAAwB;QAExB,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IAClH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CACV,OAAsB,EACtB,GAAiB,EACjB,MAAwB;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;IAC/G,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CACT,OAAyB,EACzB,GAAiB,EACjB,MAAwB;QAExB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAC9G,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@aeye/replicate",
3
+ "version": "0.1.0",
4
+ "description": "@aeye Replicate - Replicate integration for @aeye",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "test": "jest",
11
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
12
+ "typecheck": "tsc --noEmit"
13
+ },
14
+ "keywords": [
15
+ "ai",
16
+ "replicate",
17
+ "typescript"
18
+ ],
19
+ "author": "ClickerMonkey",
20
+ "license": "MIT",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/ClickerMonkey/aeye.git",
24
+ "directory": "packages/replicate"
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "README.md",
29
+ "LICENSE"
30
+ ],
31
+ "dependencies": {
32
+ "@aeye/ai": "^0.1.0",
33
+ "@aeye/core": "^0.1.0",
34
+ "replicate": "^1.3.0"
35
+ },
36
+ "devDependencies": {
37
+ "typescript": "^5.9.3"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "engines": {
43
+ "node": ">=16.0.0"
44
+ },
45
+ "homepage": "https://github.com/ClickerMonkey/aeye#readme",
46
+ "bugs": {
47
+ "url": "https://github.com/ClickerMonkey/aeye/issues"
48
+ }
49
+ }