@aeye/models 0.1.1 → 0.2.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/ReplicateScrape.md +260 -23
- package/dist/scripts/scrape.js +1 -1
- package/dist/scripts/scrape.js.map +1 -1
- package/dist/scripts/scrapers/aws.d.ts.map +1 -1
- package/dist/scripts/scrapers/aws.js +1 -245
- package/dist/scripts/scrapers/aws.js.map +1 -1
- package/dist/scripts/scrapers/replicate.d.ts +4 -0
- package/dist/scripts/scrapers/replicate.d.ts.map +1 -1
- package/dist/scripts/scrapers/replicate.js +343 -10
- package/dist/scripts/scrapers/replicate.js.map +1 -1
- package/dist/src/models/replicate.d.ts.map +1 -1
- package/dist/src/models/replicate.js +2042 -1880
- package/dist/src/models/replicate.js.map +1 -1
- package/package.json +3 -2
- package/scripts/scrape.ts +1 -1
- package/scripts/scrapers/extract.md +274 -0
- package/scripts/scrapers/replicate.ts +382 -11
- package/src/models/replicate.ts +2042 -1880
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Run `npm run scrape:replicate`
|
|
2
|
+
|
|
3
|
+
I want you to consume one model chunk file at a time. They are in cache/replicate-schemas-chunk-#.json. Each model has latest_version and in the components of the schema has Input & Output. You need to do one at a time because each file is ~ 20k tokens.
|
|
4
|
+
|
|
5
|
+
What you need to do is replace/create a src/replicate.ts file with all model handlers that make sense for each model. A model handler allows you to link a particular model ID with a set of supported functions. Like chat prediction, image generation, etc.
|
|
6
|
+
|
|
7
|
+
Here's the shape of the ModelHandler from the `@aeye/ai` package:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
export interface ModelTransformer {
|
|
11
|
+
chat?: {
|
|
12
|
+
convertRequest?: (request: Request, ctx: AIContextAny) => Promise<object>;
|
|
13
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<Response>;
|
|
14
|
+
parseChunk?: (chunk: object, ctx: AIContextAny) => Promise<Chunk>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
imageGenerate?: {
|
|
18
|
+
convertRequest?: (request: ImageGenerationRequest, ctx: AIContextAny) => Promise<object>;
|
|
19
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<ImageGenerationResponse>;
|
|
20
|
+
parseChunk?: (chunk: object, ctx: AIContextAny) => Promise<ImageGenerationChunk>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
imageEdit?: {
|
|
24
|
+
convertRequest?: (request: ImageEditRequest, ctx: AIContextAny) => Promise<object>;
|
|
25
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<ImageGenerationResponse>;
|
|
26
|
+
parseChunk?: (chunk: object, ctx: AIContextAny) => Promise<ImageGenerationChunk>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
imageAnalyze?: {
|
|
30
|
+
convertRequest?: (request: ImageAnalyzeRequest, ctx: AIContextAny) => Promise<object>;
|
|
31
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<Response>;
|
|
32
|
+
parseChunk?: (chunk: object, ctx: AIContextAny) => Promise<Chunk>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
transcribe?: {
|
|
36
|
+
convertRequest?: (request: TranscriptionRequest, ctx: AIContextAny) => Promise<object>;
|
|
37
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<TranscriptionResponse>;
|
|
38
|
+
parseChunk?: (chunk: object, ctx: AIContextAny) => Promise<TranscriptionChunk>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
speech?: {
|
|
42
|
+
convertRequest?: (request: SpeechRequest, ctx: AIContextAny) => Promise<object>;
|
|
43
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<SpeechResponse>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
embed?: {
|
|
47
|
+
convertRequest?: (request: EmbeddingRequest, ctx: AIContextAny) => Promise<object>;
|
|
48
|
+
parseResponse?: (response: object, ctx: AIContextAny) => Promise<EmbeddingResponse>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
And here are the referenced types:
|
|
54
|
+
```ts
|
|
55
|
+
export type MessageRole = 'system' | 'user' | 'assistant' | 'tool';
|
|
56
|
+
export interface Message {
|
|
57
|
+
role: MessageRole;
|
|
58
|
+
content: string | MessageContent[];
|
|
59
|
+
tokens?: number;
|
|
60
|
+
name?: string;
|
|
61
|
+
toolCallId?: string;
|
|
62
|
+
toolCalls?: ToolCall[];
|
|
63
|
+
refusal?: string;
|
|
64
|
+
cache?: Record<string, any>;
|
|
65
|
+
}
|
|
66
|
+
export type MessageContentType = 'text' | 'image' | 'file' | 'audio';
|
|
67
|
+
export interface MessageContent {
|
|
68
|
+
type: MessageContentType;
|
|
69
|
+
content: Resource;
|
|
70
|
+
format?: string;
|
|
71
|
+
}
|
|
72
|
+
export interface ToolDefinition {
|
|
73
|
+
name: string;
|
|
74
|
+
description?: string;
|
|
75
|
+
parameters: z.ZodType<object>;
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface ToolCall {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
arguments: string;
|
|
82
|
+
}
|
|
83
|
+
export type ToolChoice =
|
|
84
|
+
| 'auto'
|
|
85
|
+
| 'none'
|
|
86
|
+
| 'required'
|
|
87
|
+
| { tool: string };
|
|
88
|
+
export type ResponseFormat =
|
|
89
|
+
| 'text'
|
|
90
|
+
| 'json'
|
|
91
|
+
| { type: z.ZodType<object, object>, strict: boolean };
|
|
92
|
+
export interface Usage {
|
|
93
|
+
text?: {
|
|
94
|
+
input?: number;
|
|
95
|
+
output?: number;
|
|
96
|
+
cached?: number;
|
|
97
|
+
};
|
|
98
|
+
audio?: {
|
|
99
|
+
input?: number;
|
|
100
|
+
output?: number;
|
|
101
|
+
seconds?: number;
|
|
102
|
+
};
|
|
103
|
+
image?: {
|
|
104
|
+
input?: number;
|
|
105
|
+
output?: {
|
|
106
|
+
quality: string;
|
|
107
|
+
size: { width: number; height: number; };
|
|
108
|
+
count: number;
|
|
109
|
+
}[];
|
|
110
|
+
};
|
|
111
|
+
reasoning?: {
|
|
112
|
+
input?: number;
|
|
113
|
+
output?: number;
|
|
114
|
+
cached?: number;
|
|
115
|
+
};
|
|
116
|
+
embeddings?: {
|
|
117
|
+
count?: number;
|
|
118
|
+
tokens?: number;
|
|
119
|
+
};
|
|
120
|
+
cost?: number;
|
|
121
|
+
}
|
|
122
|
+
export type ReasoningEffort = 'low' | 'medium' | 'high';
|
|
123
|
+
export interface Request extends BaseRequest {
|
|
124
|
+
name?: string;
|
|
125
|
+
messages: Message[];
|
|
126
|
+
temperature?: number;
|
|
127
|
+
maxTokens?: number;
|
|
128
|
+
topP?: number;
|
|
129
|
+
frequencyPenalty?: number;
|
|
130
|
+
presencePenalty?: number;
|
|
131
|
+
stop?: string | string[];
|
|
132
|
+
logProbabilities?: boolean;
|
|
133
|
+
logitBias?: Record<string, number>;
|
|
134
|
+
tools?: ToolDefinition[];
|
|
135
|
+
toolsOneAtATime?: boolean;
|
|
136
|
+
toolChoice?: ToolChoice;
|
|
137
|
+
responseFormat?: ResponseFormat;
|
|
138
|
+
reason?: { effort?: ReasoningEffort, maxTokens?: number };
|
|
139
|
+
cacheKey?: string;
|
|
140
|
+
userKey?: string;
|
|
141
|
+
}
|
|
142
|
+
export type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'refusal';
|
|
143
|
+
export interface Model {
|
|
144
|
+
id: string;
|
|
145
|
+
contextWindow?: number;
|
|
146
|
+
maxOutputTokens?: number;
|
|
147
|
+
}
|
|
148
|
+
export type ModelInput = string | Model;
|
|
149
|
+
export interface BaseRequest {
|
|
150
|
+
model?: ModelInput;
|
|
151
|
+
extra?: Record<string, any>;
|
|
152
|
+
}
|
|
153
|
+
export interface BaseResponse {
|
|
154
|
+
usage?: Usage;
|
|
155
|
+
model: ModelInput;
|
|
156
|
+
}
|
|
157
|
+
export interface BaseChunk {
|
|
158
|
+
usage?: Usage;
|
|
159
|
+
model?: ModelInput;
|
|
160
|
+
}
|
|
161
|
+
export interface Response extends BaseResponse {
|
|
162
|
+
content: string;
|
|
163
|
+
toolCalls?: ToolCall[];
|
|
164
|
+
finishReason: FinishReason;
|
|
165
|
+
refusal?: string;
|
|
166
|
+
reasoning?: string;
|
|
167
|
+
}
|
|
168
|
+
export interface Chunk extends BaseChunk {
|
|
169
|
+
content?: string;
|
|
170
|
+
toolCallNamed?: ToolCall;
|
|
171
|
+
toolCallArguments?: ToolCall;
|
|
172
|
+
toolCall?: ToolCall;
|
|
173
|
+
finishReason?: FinishReason;
|
|
174
|
+
refusal?: string;
|
|
175
|
+
reasoning?: string;
|
|
176
|
+
}
|
|
177
|
+
export interface ImageGenerationRequest extends BaseRequest {
|
|
178
|
+
prompt: string;
|
|
179
|
+
n?: number;
|
|
180
|
+
size?: string;
|
|
181
|
+
quality?: 'low' | 'medium' | 'high';
|
|
182
|
+
style?: 'vivid' | 'natural';
|
|
183
|
+
responseFormat?: 'url' | 'b64_json';
|
|
184
|
+
background?: 'transparent' | 'opaque' | 'auto';
|
|
185
|
+
streamCount?: number;
|
|
186
|
+
seed?: number;
|
|
187
|
+
userIdentifier?: string;
|
|
188
|
+
}
|
|
189
|
+
export interface ImageEditRequest extends BaseRequest {
|
|
190
|
+
prompt: string;
|
|
191
|
+
image: Resource;
|
|
192
|
+
mask?: Resource;
|
|
193
|
+
n?: number;
|
|
194
|
+
size?: string;
|
|
195
|
+
responseFormat?: 'url' | 'b64_json';
|
|
196
|
+
seed?: number;
|
|
197
|
+
streamCount?: number;
|
|
198
|
+
userIdentifier?: string;
|
|
199
|
+
}
|
|
200
|
+
export interface ImageGenerationResponse extends BaseResponse {
|
|
201
|
+
images: Array<{
|
|
202
|
+
url?: string;
|
|
203
|
+
b64_json?: string;
|
|
204
|
+
revisedPrompt?: string;
|
|
205
|
+
}>;
|
|
206
|
+
}
|
|
207
|
+
export interface ImageGenerationChunk extends BaseChunk {
|
|
208
|
+
imageData?: string;
|
|
209
|
+
progress?: number;
|
|
210
|
+
done?: boolean;
|
|
211
|
+
image?: {
|
|
212
|
+
url?: string;
|
|
213
|
+
b64_json?: string;
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
export interface TranscriptionRequest extends BaseRequest {
|
|
217
|
+
audio: Resource;
|
|
218
|
+
language?: string;
|
|
219
|
+
prompt?: string;
|
|
220
|
+
temperature?: number;
|
|
221
|
+
responseFormat?: 'json' | 'text' | 'srt' | 'vtt' | 'verbose_json';
|
|
222
|
+
timestampGranularities?: Array<'word' | 'segment'>;
|
|
223
|
+
}
|
|
224
|
+
export interface TranscriptionResponse extends BaseResponse {
|
|
225
|
+
text: string;
|
|
226
|
+
}
|
|
227
|
+
export interface TranscriptionChunk extends BaseChunk {
|
|
228
|
+
delta?: string;
|
|
229
|
+
text?: string;
|
|
230
|
+
segment?: { start: number; end: number; speaker: string, text: string, id: string };
|
|
231
|
+
status?: string;
|
|
232
|
+
}
|
|
233
|
+
export interface SpeechRequest extends BaseRequest{
|
|
234
|
+
text: string;
|
|
235
|
+
instructions?: string;
|
|
236
|
+
voice?: string;
|
|
237
|
+
speed?: number;
|
|
238
|
+
responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
|
|
239
|
+
}
|
|
240
|
+
export interface SpeechResponse extends BaseResponse {
|
|
241
|
+
audio: ReadableStream<any>;
|
|
242
|
+
responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
|
|
243
|
+
}
|
|
244
|
+
export interface EmbeddingRequest extends BaseRequest {
|
|
245
|
+
texts: string[];
|
|
246
|
+
dimensions?: number;
|
|
247
|
+
encodingFormat?: 'float' | 'base64';
|
|
248
|
+
userIdentifier?: string;
|
|
249
|
+
}
|
|
250
|
+
export interface EmbeddingResponse extends BaseResponse {
|
|
251
|
+
embeddings: Array<{
|
|
252
|
+
embedding: number[];
|
|
253
|
+
index: number;
|
|
254
|
+
}>;
|
|
255
|
+
}
|
|
256
|
+
export interface ImageAnalyzeRequest extends BaseRequest{
|
|
257
|
+
prompt: string;
|
|
258
|
+
images: string[];
|
|
259
|
+
maxTokens?: number;
|
|
260
|
+
temperature?: number;
|
|
261
|
+
}
|
|
262
|
+
export type Resource =
|
|
263
|
+
| string // plain text, or data URL, or http(s) URL, or file:// URL
|
|
264
|
+
| AsyncIterable<Uint8Array> // fs.ReadStream, ReadableStream
|
|
265
|
+
| Blob // File
|
|
266
|
+
| Uint8Array
|
|
267
|
+
| URL
|
|
268
|
+
| ArrayBuffer
|
|
269
|
+
| DataView
|
|
270
|
+
| Buffer
|
|
271
|
+
| { blob(): Promise<Blob> | Blob }
|
|
272
|
+
| { url(): string }
|
|
273
|
+
| { read(): Promise<ReadableStream> | ReadableStream }
|
|
274
|
+
```
|