clefbase 2.0.7 → 2.0.9
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 +748 -55
- package/dist/__tests__/full-feature-validation.test.d.ts +6 -0
- package/dist/__tests__/full-feature-validation.test.d.ts.map +1 -0
- package/dist/__tests__/full-feature-validation.test.js +329 -0
- package/dist/__tests__/full-feature-validation.test.js.map +1 -0
- package/dist/ai.d.ts +294 -9
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js +198 -8
- package/dist/ai.js.map +1 -1
- package/dist/app.d.ts +7 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +18 -3
- package/dist/app.js.map +1 -1
- package/dist/auth/index.d.ts +28 -3
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +71 -9
- package/dist/auth/index.js.map +1 -1
- package/dist/cli-src/cli/commands/init.js +30 -0
- package/dist/cli-src/cli/config.js +3 -0
- package/dist/cli.js +32 -1
- package/dist/db/index.d.ts +38 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +55 -1
- package/dist/db/index.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -3
- package/dist/react/index.js.map +1 -1
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +11 -6
- package/dist/storage/index.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/dist/ai.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpClient } from "./http";
|
|
2
|
-
export type AIProvider = "anthropic" | "google";
|
|
2
|
+
export type AIProvider = "anthropic" | "google" | "ollama";
|
|
3
3
|
export type AIModelCategory = "text" | "code" | "image" | "video" | "embedding";
|
|
4
4
|
/**
|
|
5
5
|
* A model available in the project's AI service.
|
|
@@ -14,6 +14,76 @@ export interface AIModel {
|
|
|
14
14
|
supportsStreaming?: boolean;
|
|
15
15
|
supportsSystemPrompt?: boolean;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* An image passed to text generation models for vision/multimodal analysis.
|
|
19
|
+
* You can provide either a URL or base64 encoded data.
|
|
20
|
+
*/
|
|
21
|
+
export interface ImageInputForText {
|
|
22
|
+
/**
|
|
23
|
+
* Image source: either a public URL or base64-encoded data.
|
|
24
|
+
* Base64 format: `"data:image/jpeg;base64,/9j/4AAQSkZJRg..."`
|
|
25
|
+
*/
|
|
26
|
+
source: string;
|
|
27
|
+
/** MIME type, e.g. `"image/jpeg"`, `"image/png"`, `"image/webp"`, `"image/gif"` */
|
|
28
|
+
mediaType?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Optional description or context for the image (helps model understand intent).
|
|
31
|
+
* Claude and Gemini use this to better contextualize the image.
|
|
32
|
+
*/
|
|
33
|
+
description?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A reference image for image or video generation (image-to-image, image-to-video).
|
|
37
|
+
* Provide a source image that the generative model will use as a starting point.
|
|
38
|
+
*/
|
|
39
|
+
export interface ImageReferenceForGeneration {
|
|
40
|
+
/**
|
|
41
|
+
* Image source: either a public URL or base64-encoded data.
|
|
42
|
+
* Base64 format: `"data:image/jpeg;base64,/9j/4AAQSkZJRg..."`
|
|
43
|
+
*/
|
|
44
|
+
source: string;
|
|
45
|
+
/** MIME type, e.g. `"image/jpeg"`, `"image/png"`, `"image/webp"` */
|
|
46
|
+
mediaType?: string;
|
|
47
|
+
/**
|
|
48
|
+
* How strongly the generated output should adhere to the reference image.
|
|
49
|
+
* Range: 0 (ignore reference) to 1 (strict adherence). Default: 0.7.
|
|
50
|
+
* Higher values produce outputs more similar to the reference.
|
|
51
|
+
*/
|
|
52
|
+
strength?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A file attached to text/code generation for analysis.
|
|
56
|
+
* Supports documents (PDF, DOCX), code files, data files, and more.
|
|
57
|
+
* You can provide either a URL or base64 encoded data.
|
|
58
|
+
*/
|
|
59
|
+
export interface FileInputForText {
|
|
60
|
+
/**
|
|
61
|
+
* File source: either a public URL or base64-encoded data.
|
|
62
|
+
* Base64 format: `"data:application/pdf;base64,JVBERi0xLjQ..."`
|
|
63
|
+
* For code: `"data:text/typescript;base64,ZXhwb3J0IGZ1bmN0aW9u..."`
|
|
64
|
+
*/
|
|
65
|
+
source: string;
|
|
66
|
+
/**
|
|
67
|
+
* MIME type. Common examples:
|
|
68
|
+
* - Documents: `"application/pdf"`, `"application/msword"`, `"text/plain"`
|
|
69
|
+
* - Spreadsheets: `"application/vnd.ms-excel"`, `"text/csv"`
|
|
70
|
+
* - Code: `"text/typescript"`, `"text/python"`, `"application/json"`
|
|
71
|
+
* - Archives: `"application/zip"`, `"application/x-tar"`
|
|
72
|
+
* - Video: `"video/mp4"`, `"video/quicktime"` (for transcription/analysis)
|
|
73
|
+
* - Audio: `"audio/mpeg"`, `"audio/wav"` (for transcription/analysis)
|
|
74
|
+
*/
|
|
75
|
+
mediaType?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Optional file name for clarity, e.g. `"api-docs.pdf"`, `"schema.ts"`.
|
|
78
|
+
* Helps the model understand the file context.
|
|
79
|
+
*/
|
|
80
|
+
filename?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Optional description of the file's purpose or content.
|
|
83
|
+
* E.g. "Database schema", "User guide", "API specification".
|
|
84
|
+
*/
|
|
85
|
+
description?: string;
|
|
86
|
+
}
|
|
17
87
|
export interface GenerateTextOptions {
|
|
18
88
|
/** Model ID, e.g. `"claude-sonnet-4-5"` or `"gemini-2.5-flash"` */
|
|
19
89
|
model: string;
|
|
@@ -30,6 +100,19 @@ export interface GenerateTextOptions {
|
|
|
30
100
|
role: "user" | "assistant";
|
|
31
101
|
content: string;
|
|
32
102
|
}>;
|
|
103
|
+
/**
|
|
104
|
+
* Optional images for multimodal text generation (vision).
|
|
105
|
+
* Supported by Claude 3+, Gemini 1.5+, and other vision-capable models.
|
|
106
|
+
* The model will analyze the image(s) along with your prompt.
|
|
107
|
+
*/
|
|
108
|
+
images?: ImageInputForText[];
|
|
109
|
+
/**
|
|
110
|
+
* Optional files for document/code analysis.
|
|
111
|
+
* Supports PDFs, Word docs, spreadsheets, code files, JSON, video/audio transcription, and more.
|
|
112
|
+
* The model will analyze the file contents along with your prompt.
|
|
113
|
+
* Great for summarizing, explaining, or extracting information from documents.
|
|
114
|
+
*/
|
|
115
|
+
files?: FileInputForText[];
|
|
33
116
|
}
|
|
34
117
|
export interface GenerateTextResult {
|
|
35
118
|
id: string;
|
|
@@ -60,6 +143,12 @@ export interface GenerateImageOptions {
|
|
|
60
143
|
* Leave undefined to use the bucket root.
|
|
61
144
|
*/
|
|
62
145
|
outputFolder?: string;
|
|
146
|
+
/**
|
|
147
|
+
* Optional reference image for image-to-image generation.
|
|
148
|
+
* The model will use this image as a starting point and modify it based on your prompt.
|
|
149
|
+
* Enables style transfer, inpainting, upscaling, and controlled variations.
|
|
150
|
+
*/
|
|
151
|
+
referenceImage?: ImageReferenceForGeneration;
|
|
63
152
|
}
|
|
64
153
|
export interface GeneratedMediaFile {
|
|
65
154
|
/** ID of the file in project Storage */
|
|
@@ -95,6 +184,12 @@ export interface GenerateVideoOptions {
|
|
|
95
184
|
* Folder inside the AI-output storage bucket where the video will be saved.
|
|
96
185
|
*/
|
|
97
186
|
outputFolder?: string;
|
|
187
|
+
/**
|
|
188
|
+
* Optional reference image for image-to-video generation.
|
|
189
|
+
* The model will generate a video that begins with or is inspired by this image.
|
|
190
|
+
* Useful for creating animations from static frames or consistent visual narratives.
|
|
191
|
+
*/
|
|
192
|
+
referenceImage?: ImageReferenceForGeneration;
|
|
98
193
|
}
|
|
99
194
|
export interface GenerateVideoResult {
|
|
100
195
|
id: string;
|
|
@@ -174,23 +269,33 @@ export declare class AIError extends Error {
|
|
|
174
269
|
/**
|
|
175
270
|
* Clefbase AI service — obtained via `getAI(app)`.
|
|
176
271
|
*
|
|
177
|
-
* Provides access to text/code generation (Claude & Gemini
|
|
178
|
-
* (Imagen
|
|
272
|
+
* Provides access to text/code generation (Claude & Gemini, or local Llama/Mistral with Ollama),
|
|
273
|
+
* image generation (Imagen 4), video generation (Veo 2), and text embeddings.
|
|
179
274
|
* Generated images and videos are automatically saved to the project's
|
|
180
275
|
* configured storage bucket.
|
|
181
276
|
*
|
|
277
|
+
* **Local LLM Support via Ollama:**
|
|
278
|
+
* Run open-source models (Llama 2, Mistral, Orca, etc.) on your own infrastructure
|
|
279
|
+
* using Ollama. Simply enable Ollama and point to your local instance.
|
|
280
|
+
*
|
|
182
281
|
* @example
|
|
183
282
|
* import { initClefbase, getAI } from "clefbase";
|
|
184
283
|
*
|
|
185
284
|
* const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
|
|
186
285
|
* const ai = getAI(app);
|
|
187
286
|
*
|
|
188
|
-
* // ── Text / code
|
|
287
|
+
* // ── Text / code with cloud models ──────────────────────────────────────────
|
|
189
288
|
* const { content } = await ai.text({
|
|
190
289
|
* model: "claude-sonnet-4-5",
|
|
191
290
|
* prompt: "Explain promises in JavaScript",
|
|
192
291
|
* });
|
|
193
292
|
*
|
|
293
|
+
* // ── Text / code with local models (Ollama) ────────────────────────────────
|
|
294
|
+
* const { content } = await ai.text({
|
|
295
|
+
* model: "ollama:mistral",
|
|
296
|
+
* prompt: "Explain async/await in JavaScript",
|
|
297
|
+
* });
|
|
298
|
+
*
|
|
194
299
|
* // ── Multi-turn chat ────────────────────────────────────────────────────────
|
|
195
300
|
* const { content } = await ai.text({
|
|
196
301
|
* model: "gemini-2.5-flash",
|
|
@@ -221,15 +326,16 @@ export declare class AIError extends Error {
|
|
|
221
326
|
* aspectRatio: "16:9",
|
|
222
327
|
* });
|
|
223
328
|
*
|
|
224
|
-
* // ── Embeddings
|
|
329
|
+
* // ── Embeddings (cloud or local) ────────────────────────────────────────────
|
|
225
330
|
* const { embeddings } = await ai.embedding({
|
|
226
|
-
* model: "gemini-embedding-001",
|
|
331
|
+
* model: "gemini-embedding-001", // or "ollama:nomic-embed-text"
|
|
227
332
|
* input: ["Hello world", "Semantic search"],
|
|
228
333
|
* });
|
|
229
334
|
* // embeddings: number[][]
|
|
230
335
|
*
|
|
231
336
|
* // ── Browse models ──────────────────────────────────────────────────────────
|
|
232
337
|
* const imageModels = await ai.listModels({ category: "image" });
|
|
338
|
+
* const localModels = await ai.listModels({ provider: "ollama" });
|
|
233
339
|
*
|
|
234
340
|
* // ── Usage ──────────────────────────────────────────────────────────────────
|
|
235
341
|
* const stats = await ai.getStats();
|
|
@@ -253,28 +359,112 @@ export declare class ClefbaseAI {
|
|
|
253
359
|
category?: AIModelCategory;
|
|
254
360
|
}): Promise<AIModel[]>;
|
|
255
361
|
/**
|
|
256
|
-
* Generate text or code with a Claude or
|
|
362
|
+
* Generate text or code with a Claude, Gemini, or local Ollama model.
|
|
363
|
+
*
|
|
364
|
+
* **Vision Support:** Send images along with your prompt for multimodal analysis
|
|
365
|
+
* (object detection, OCR, description, etc.). Supported by Claude 3+, Gemini 1.5+.
|
|
366
|
+
*
|
|
367
|
+
* **Local Models:** If you have Ollama running locally and enabled in your
|
|
368
|
+
* project's AI configuration, you can use models like `"ollama:mistral"`,
|
|
369
|
+
* `"ollama:llama2"`, etc. They support system prompts and conversation history.
|
|
370
|
+
*
|
|
371
|
+
* **Supported Cloud Models:** `claude-sonnet-4-5`, `claude-opus-4-5`, `gemini-2.5-flash`, etc.
|
|
257
372
|
*
|
|
258
373
|
* @example
|
|
259
|
-
*
|
|
374
|
+
* // Cloud model with text only
|
|
375
|
+
* const { content } = await ai.text({
|
|
260
376
|
* model: "claude-sonnet-4-5",
|
|
261
377
|
* prompt: "Write a bubble-sort in Python",
|
|
262
378
|
* systemPrompt: "Return only code, no explanation.",
|
|
263
379
|
* maxTokens: 512,
|
|
264
380
|
* });
|
|
381
|
+
*
|
|
382
|
+
* // Vision: analyze an image from a URL
|
|
383
|
+
* const { content } = await ai.text({
|
|
384
|
+
* model: "claude-sonnet-4-5",
|
|
385
|
+
* prompt: "What objects are in this image? List them.",
|
|
386
|
+
* images: [
|
|
387
|
+
* { source: "https://example.com/photo.jpg" }
|
|
388
|
+
* ],
|
|
389
|
+
* });
|
|
390
|
+
*
|
|
391
|
+
* // Vision: multiple images
|
|
392
|
+
* const { content } = await ai.text({
|
|
393
|
+
* model: "gemini-2.5-flash",
|
|
394
|
+
* prompt: "Compare these two diagrams",
|
|
395
|
+
* images: [
|
|
396
|
+
* { source: "https://example.com/diagram-1.png", description: "Before" },
|
|
397
|
+
* { source: "https://example.com/diagram-2.png", description: "After" },
|
|
398
|
+
* ],
|
|
399
|
+
* });
|
|
400
|
+
*
|
|
401
|
+
* // Vision: base64-encoded image
|
|
402
|
+
* const { content } = await ai.text({
|
|
403
|
+
* model: "claude-sonnet-4-5",
|
|
404
|
+
* prompt: "Extract text from this screenshot",
|
|
405
|
+
* images: [
|
|
406
|
+
* { source: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA..." }
|
|
407
|
+
* ],
|
|
408
|
+
* });
|
|
409
|
+
*
|
|
410
|
+
* // Local model (Ollama)
|
|
411
|
+
* const { content } = await ai.text({
|
|
412
|
+
* model: "ollama:mistral",
|
|
413
|
+
* prompt: "Explain quantum computing",
|
|
414
|
+
* });
|
|
265
415
|
*/
|
|
266
416
|
text(options: GenerateTextOptions): Promise<GenerateTextResult>;
|
|
267
417
|
/**
|
|
268
418
|
* Generate one or more images with an Imagen model.
|
|
269
419
|
* Outputs are automatically saved to the project's storage bucket.
|
|
270
420
|
*
|
|
421
|
+
* **Image-to-Image:** Provide a `referenceImage` to modify, enhance, or transform
|
|
422
|
+
* an existing image based on your prompt. Use cases: style transfer, upscaling,
|
|
423
|
+
* inpainting, controlled variations, and compositional changes.
|
|
424
|
+
*
|
|
271
425
|
* @example
|
|
426
|
+
* // Text-to-image
|
|
272
427
|
* const { files } = await ai.image({
|
|
273
428
|
* model: "imagen-4.0-generate-001",
|
|
274
429
|
* prompt: "A futuristic city skyline at sunset",
|
|
275
430
|
* aspectRatio: "16:9",
|
|
276
431
|
* });
|
|
277
432
|
* const path = files[0].fullPath; // use with storage.ref()
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* // Image-to-image: style transfer
|
|
436
|
+
* const { files } = await ai.image({
|
|
437
|
+
* model: "imagen-4.0-generate-001",
|
|
438
|
+
* prompt: "Repaint this in the style of Van Gogh's Starry Night",
|
|
439
|
+
* referenceImage: {
|
|
440
|
+
* source: "https://example.com/portrait.jpg",
|
|
441
|
+
* strength: 0.6, // 60% adherence to reference
|
|
442
|
+
* },
|
|
443
|
+
* });
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* // Image-to-image: upscale with detail enhancement
|
|
447
|
+
* const { files } = await ai.image({
|
|
448
|
+
* model: "imagen-4.0-generate-001",
|
|
449
|
+
* prompt: "Upscale and enhance details, make it sharper and more vibrant",
|
|
450
|
+
* referenceImage: {
|
|
451
|
+
* source: "data:image/jpeg;base64,...",
|
|
452
|
+
* strength: 0.9, // high similarity to original
|
|
453
|
+
* },
|
|
454
|
+
* numberOfImages: 1,
|
|
455
|
+
* });
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* // Image-to-image: inpainting / object modification
|
|
459
|
+
* const { files } = await ai.image({
|
|
460
|
+
* model: "imagen-4.0-generate-001",
|
|
461
|
+
* prompt: "Replace the sky with a sunset",
|
|
462
|
+
* referenceImage: {
|
|
463
|
+
* source: "https://example.com/landscape.jpg",
|
|
464
|
+
* strength: 0.7,
|
|
465
|
+
* },
|
|
466
|
+
* outputFolder: "upscaled",
|
|
467
|
+
* });
|
|
278
468
|
*/
|
|
279
469
|
image(options: GenerateImageOptions): Promise<GenerateImageResult>;
|
|
280
470
|
/**
|
|
@@ -282,24 +472,78 @@ export declare class ClefbaseAI {
|
|
|
282
472
|
* This is an async server-side operation — the SDK call blocks until the
|
|
283
473
|
* job completes (usually 1–5 minutes). Outputs are saved to project storage.
|
|
284
474
|
*
|
|
475
|
+
* **Image-to-Video:** Provide a `referenceImage` to generate a video that
|
|
476
|
+
* begins with or is inspired by a static frame. Use cases: animating photos,
|
|
477
|
+
* creating consistent visual narratives, camera movements, or temporal extensions.
|
|
478
|
+
*
|
|
285
479
|
* @example
|
|
480
|
+
* // Text-to-video
|
|
286
481
|
* const { status, files } = await ai.video({
|
|
287
482
|
* model: "veo-3.1-generate-preview",
|
|
288
483
|
* prompt: "A golden retriever running on a sunny beach",
|
|
289
484
|
* durationSeconds: 5,
|
|
290
485
|
* outputFolder: "clips",
|
|
291
486
|
* });
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* // Image-to-video: animate a static photo
|
|
490
|
+
* const { status, files } = await ai.video({
|
|
491
|
+
* model: "veo-3.1-generate-preview",
|
|
492
|
+
* prompt: "The person starts walking toward the camera. Soft focus bokeh background.",
|
|
493
|
+
* referenceImage: {
|
|
494
|
+
* source: "https://example.com/portrait.jpg",
|
|
495
|
+
* strength: 0.8, // strong visual consistency
|
|
496
|
+
* },
|
|
497
|
+
* durationSeconds: 4,
|
|
498
|
+
* outputFolder: "animations",
|
|
499
|
+
* });
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* // Image-to-video: cinematic camera movement
|
|
503
|
+
* const { status, files } = await ai.video({
|
|
504
|
+
* model: "veo-3.1-generate-preview",
|
|
505
|
+
* prompt: "Smooth dolly-in camera movement, revealing more of the landscape",
|
|
506
|
+
* referenceImage: {
|
|
507
|
+
* source: "https://example.com/landscape.jpg",
|
|
508
|
+
* strength: 0.7,
|
|
509
|
+
* },
|
|
510
|
+
* durationSeconds: 6,
|
|
511
|
+
* aspectRatio: "16:9",
|
|
512
|
+
* });
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* // Image-to-video: temporal extension (what happens next?)
|
|
516
|
+
* const { status, files } = await ai.video({
|
|
517
|
+
* model: "veo-3.1-generate-preview",
|
|
518
|
+
* prompt: "The scene transitions into evening with golden hour light",
|
|
519
|
+
* referenceImage: {
|
|
520
|
+
* source: "data:image/jpeg;base64,...",
|
|
521
|
+
* strength: 0.6, // more creative freedom
|
|
522
|
+
* },
|
|
523
|
+
* durationSeconds: 5,
|
|
524
|
+
* });
|
|
292
525
|
*/
|
|
293
526
|
video(options: GenerateVideoOptions): Promise<GenerateVideoResult>;
|
|
294
527
|
/**
|
|
295
528
|
* Generate text embeddings — one float vector per input string.
|
|
529
|
+
* Use Google's Gemini embedding or local Ollama embedding models.
|
|
530
|
+
*
|
|
531
|
+
* **Supported Models:**
|
|
532
|
+
* - Google: `"gemini-embedding-001"` (3072 dimensions)
|
|
533
|
+
* - Ollama: `"ollama:nomic-embed-text"` (768 dims), `"ollama:all-minilm"` (384 dims)
|
|
296
534
|
*
|
|
297
535
|
* @example
|
|
536
|
+
* // Cloud model
|
|
298
537
|
* const { embeddings } = await ai.embedding({
|
|
299
538
|
* model: "gemini-embedding-001",
|
|
300
539
|
* input: ["cat", "dog", "automobile"],
|
|
301
540
|
* });
|
|
302
|
-
*
|
|
541
|
+
*
|
|
542
|
+
* // Local model
|
|
543
|
+
* const { embeddings } = await ai.embedding({
|
|
544
|
+
* model: "ollama:nomic-embed-text",
|
|
545
|
+
* input: "semantic search example",
|
|
546
|
+
* });
|
|
303
547
|
*/
|
|
304
548
|
embedding(options: GenerateEmbeddingOptions): Promise<GenerateEmbeddingResult>;
|
|
305
549
|
/**
|
|
@@ -328,32 +572,73 @@ export declare class ClefbaseAI {
|
|
|
328
572
|
/**
|
|
329
573
|
* Generate text or code. Sugar for `ai.text(options)`.
|
|
330
574
|
*
|
|
575
|
+
* Supports vision/multimodal analysis by passing images in the `images` option.
|
|
576
|
+
*
|
|
331
577
|
* @example
|
|
332
578
|
* const { content } = await generateText(ai, {
|
|
333
579
|
* model: "claude-sonnet-4-5",
|
|
334
580
|
* prompt: "What is the capital of France?",
|
|
335
581
|
* });
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* // With vision: analyze an image
|
|
585
|
+
* const { content } = await generateText(ai, {
|
|
586
|
+
* model: "claude-sonnet-4-5",
|
|
587
|
+
* prompt: "Describe what you see in this image",
|
|
588
|
+
* images: [{ source: "https://example.com/photo.jpg" }],
|
|
589
|
+
* });
|
|
336
590
|
*/
|
|
337
591
|
export declare function generateText(ai: ClefbaseAI, options: GenerateTextOptions): Promise<GenerateTextResult>;
|
|
338
592
|
/**
|
|
339
593
|
* Generate images. Sugar for `ai.image(options)`.
|
|
340
594
|
*
|
|
595
|
+
* Supports image-to-image generation by providing a `referenceImage` for style
|
|
596
|
+
* transfer, upscaling, inpainting, and controlled variations.
|
|
597
|
+
*
|
|
341
598
|
* @example
|
|
599
|
+
* // Text-to-image
|
|
342
600
|
* const { files } = await generateImage(ai, {
|
|
343
601
|
* model: "imagen-4.0-generate-001",
|
|
344
602
|
* prompt: "A calm ocean at sunset",
|
|
345
603
|
* });
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* // Image-to-image: style transfer
|
|
607
|
+
* const { files } = await generateImage(ai, {
|
|
608
|
+
* model: "imagen-4.0-generate-001",
|
|
609
|
+
* prompt: "Transform into oil painting style",
|
|
610
|
+
* referenceImage: {
|
|
611
|
+
* source: "https://example.com/photo.jpg",
|
|
612
|
+
* strength: 0.7,
|
|
613
|
+
* },
|
|
614
|
+
* });
|
|
346
615
|
*/
|
|
347
616
|
export declare function generateImage(ai: ClefbaseAI, options: GenerateImageOptions): Promise<GenerateImageResult>;
|
|
348
617
|
/**
|
|
349
618
|
* Generate a video. Sugar for `ai.video(options)`.
|
|
350
619
|
*
|
|
620
|
+
* Supports image-to-video generation by providing a `referenceImage` for
|
|
621
|
+
* animating photos, creating camera movements, or temporal extensions.
|
|
622
|
+
*
|
|
351
623
|
* @example
|
|
624
|
+
* // Text-to-video
|
|
352
625
|
* const { files } = await generateVideo(ai, {
|
|
353
626
|
* model: "veo-3.1-generate-preview",
|
|
354
627
|
* prompt: "A timelapse of clouds over a mountain",
|
|
355
628
|
* durationSeconds: 6,
|
|
356
629
|
* });
|
|
630
|
+
*
|
|
631
|
+
* @example
|
|
632
|
+
* // Image-to-video: animate a photo
|
|
633
|
+
* const { files } = await generateVideo(ai, {
|
|
634
|
+
* model: "veo-3.1-generate-preview",
|
|
635
|
+
* prompt: "The subject starts moving gracefully",
|
|
636
|
+
* referenceImage: {
|
|
637
|
+
* source: "https://example.com/portrait.jpg",
|
|
638
|
+
* strength: 0.8,
|
|
639
|
+
* },
|
|
640
|
+
* durationSeconds: 4,
|
|
641
|
+
* });
|
|
357
642
|
*/
|
|
358
643
|
export declare function generateVideo(ai: ClefbaseAI, options: GenerateVideoOptions): Promise<GenerateVideoResult>;
|
|
359
644
|
/**
|
package/dist/ai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAKpC,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAC3D,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAA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