@quilltap/plugin-types 1.17.3 → 2.0.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 +5 -0
- package/dist/{index-C2T_GwJc.d.mts → index-BXJLgAuZ.d.ts} +134 -57
- package/dist/{index-aiujxDsP.d.ts → index-DtW7izgw.d.mts} +134 -57
- package/dist/index.d.mts +102 -4
- package/dist/index.d.ts +102 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/llm/index.d.mts +174 -151
- package/dist/llm/index.d.ts +174 -151
- package/dist/llm/index.js +1 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/index.mjs +1 -1
- package/dist/llm/index.mjs.map +1 -1
- package/dist/plugins/index.d.mts +2 -1
- package/dist/plugins/index.d.ts +2 -1
- package/dist/providers/index.d.mts +132 -0
- package/dist/providers/index.d.ts +132 -0
- package/dist/providers/index.js +10 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/index.mjs +8 -0
- package/dist/providers/index.mjs.map +1 -0
- package/package.json +6 -1
package/dist/llm/index.d.ts
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types shared across all provider interfaces
|
|
3
|
+
*
|
|
4
|
+
* These types are used by multiple provider shapes (text, image, embedding, scoring)
|
|
5
|
+
* and are extracted here to avoid duplication.
|
|
6
|
+
*
|
|
7
|
+
* @module @quilltap/plugin-types/providers/common
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* File attachment for multimodal messages
|
|
11
|
+
*/
|
|
12
|
+
interface FileAttachment {
|
|
13
|
+
/** Unique identifier for the attachment */
|
|
14
|
+
id: string;
|
|
15
|
+
/** Path to the file on disk (internal use) */
|
|
16
|
+
filepath?: string;
|
|
17
|
+
/** Original filename */
|
|
18
|
+
filename: string;
|
|
19
|
+
/** MIME type of the file */
|
|
20
|
+
mimeType: string;
|
|
21
|
+
/** File size in bytes */
|
|
22
|
+
size: number;
|
|
23
|
+
/** Base64 encoded data (loaded at send time) */
|
|
24
|
+
data?: string;
|
|
25
|
+
/** URL to fetch the file (alternative to data) */
|
|
26
|
+
url?: string;
|
|
27
|
+
/** Additional metadata */
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Token usage statistics
|
|
32
|
+
*/
|
|
33
|
+
interface TokenUsage {
|
|
34
|
+
/** Tokens used for the prompt */
|
|
35
|
+
promptTokens: number;
|
|
36
|
+
/** Tokens used for the completion */
|
|
37
|
+
completionTokens: number;
|
|
38
|
+
/** Total tokens used */
|
|
39
|
+
totalTokens: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Cache usage statistics (OpenRouter, Anthropic)
|
|
43
|
+
*/
|
|
44
|
+
interface CacheUsage {
|
|
45
|
+
/** Number of cached tokens */
|
|
46
|
+
cachedTokens?: number;
|
|
47
|
+
/** Cache discount amount */
|
|
48
|
+
cacheDiscount?: number;
|
|
49
|
+
/** Tokens used for cache creation */
|
|
50
|
+
cacheCreationInputTokens?: number;
|
|
51
|
+
/** Tokens read from cache */
|
|
52
|
+
cacheReadInputTokens?: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Attachment processing results
|
|
56
|
+
*/
|
|
57
|
+
interface AttachmentResults {
|
|
58
|
+
/** IDs of attachments sent successfully */
|
|
59
|
+
sent: string[];
|
|
60
|
+
/** Attachments that failed with error details */
|
|
61
|
+
failed: Array<{
|
|
62
|
+
id: string;
|
|
63
|
+
error: string;
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Model warning level
|
|
68
|
+
*/
|
|
69
|
+
type ModelWarningLevel = 'info' | 'warning' | 'error';
|
|
70
|
+
/**
|
|
71
|
+
* Model warning information
|
|
72
|
+
*/
|
|
73
|
+
interface ModelWarning {
|
|
74
|
+
/** Warning severity level */
|
|
75
|
+
level: ModelWarningLevel;
|
|
76
|
+
/** Warning message */
|
|
77
|
+
message: string;
|
|
78
|
+
/** Optional link to documentation */
|
|
79
|
+
documentationUrl?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Model metadata with warnings and capabilities
|
|
83
|
+
*/
|
|
84
|
+
interface ModelMetadata {
|
|
85
|
+
/** Model identifier */
|
|
86
|
+
id: string;
|
|
87
|
+
/** Human-readable display name */
|
|
88
|
+
displayName?: string;
|
|
89
|
+
/** Warnings or recommendations */
|
|
90
|
+
warnings?: ModelWarning[];
|
|
91
|
+
/** Whether the model is deprecated */
|
|
92
|
+
deprecated?: boolean;
|
|
93
|
+
/** Whether the model is experimental/preview */
|
|
94
|
+
experimental?: boolean;
|
|
95
|
+
/** Capabilities this model lacks */
|
|
96
|
+
missingCapabilities?: string[];
|
|
97
|
+
/** Maximum output tokens */
|
|
98
|
+
maxOutputTokens?: number;
|
|
99
|
+
/** Context window size */
|
|
100
|
+
contextWindow?: number;
|
|
101
|
+
}
|
|
102
|
+
|
|
1
103
|
/**
|
|
2
104
|
* Tool/Function calling types for Quilltap plugin development
|
|
3
105
|
*
|
|
@@ -128,32 +230,15 @@ interface ToolFormatOptions {
|
|
|
128
230
|
}
|
|
129
231
|
|
|
130
232
|
/**
|
|
131
|
-
*
|
|
233
|
+
* Text Provider — Shape 1: Text -> Text
|
|
234
|
+
*
|
|
235
|
+
* Send instructions + data (with optional attachments) to an LLM,
|
|
236
|
+
* receive a text response. This is the fundamental text completion shape,
|
|
237
|
+
* covering both standard and "cheap" model calls.
|
|
132
238
|
*
|
|
133
|
-
* @module @quilltap/plugin-types/
|
|
239
|
+
* @module @quilltap/plugin-types/providers/text
|
|
134
240
|
*/
|
|
135
241
|
|
|
136
|
-
/**
|
|
137
|
-
* File attachment for multimodal messages
|
|
138
|
-
*/
|
|
139
|
-
interface FileAttachment {
|
|
140
|
-
/** Unique identifier for the attachment */
|
|
141
|
-
id: string;
|
|
142
|
-
/** Path to the file on disk (internal use) */
|
|
143
|
-
filepath?: string;
|
|
144
|
-
/** Original filename */
|
|
145
|
-
filename: string;
|
|
146
|
-
/** MIME type of the file */
|
|
147
|
-
mimeType: string;
|
|
148
|
-
/** File size in bytes */
|
|
149
|
-
size: number;
|
|
150
|
-
/** Base64 encoded data (loaded at send time) */
|
|
151
|
-
data?: string;
|
|
152
|
-
/** URL to fetch the file (alternative to data) */
|
|
153
|
-
url?: string;
|
|
154
|
-
/** Additional metadata */
|
|
155
|
-
metadata?: Record<string, unknown>;
|
|
156
|
-
}
|
|
157
242
|
/**
|
|
158
243
|
* Message in a conversation
|
|
159
244
|
*/
|
|
@@ -198,7 +283,7 @@ interface ResponseFormat {
|
|
|
198
283
|
jsonSchema?: JSONSchemaDefinition;
|
|
199
284
|
}
|
|
200
285
|
/**
|
|
201
|
-
* Parameters for
|
|
286
|
+
* Parameters for text completion requests
|
|
202
287
|
*/
|
|
203
288
|
interface LLMParams {
|
|
204
289
|
/** Array of messages in the conversation */
|
|
@@ -236,43 +321,7 @@ interface LLMParams {
|
|
|
236
321
|
previousResponseId?: string;
|
|
237
322
|
}
|
|
238
323
|
/**
|
|
239
|
-
*
|
|
240
|
-
*/
|
|
241
|
-
interface TokenUsage {
|
|
242
|
-
/** Tokens used for the prompt */
|
|
243
|
-
promptTokens: number;
|
|
244
|
-
/** Tokens used for the completion */
|
|
245
|
-
completionTokens: number;
|
|
246
|
-
/** Total tokens used */
|
|
247
|
-
totalTokens: number;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Cache usage statistics (OpenRouter, Anthropic)
|
|
251
|
-
*/
|
|
252
|
-
interface CacheUsage {
|
|
253
|
-
/** Number of cached tokens */
|
|
254
|
-
cachedTokens?: number;
|
|
255
|
-
/** Cache discount amount */
|
|
256
|
-
cacheDiscount?: number;
|
|
257
|
-
/** Tokens used for cache creation */
|
|
258
|
-
cacheCreationInputTokens?: number;
|
|
259
|
-
/** Tokens read from cache */
|
|
260
|
-
cacheReadInputTokens?: number;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Attachment processing results
|
|
264
|
-
*/
|
|
265
|
-
interface AttachmentResults {
|
|
266
|
-
/** IDs of attachments sent successfully */
|
|
267
|
-
sent: string[];
|
|
268
|
-
/** Attachments that failed with error details */
|
|
269
|
-
failed: Array<{
|
|
270
|
-
id: string;
|
|
271
|
-
error: string;
|
|
272
|
-
}>;
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Response from LLM
|
|
324
|
+
* Response from a text completion
|
|
276
325
|
*/
|
|
277
326
|
interface LLMResponse {
|
|
278
327
|
/** Generated content */
|
|
@@ -293,7 +342,7 @@ interface LLMResponse {
|
|
|
293
342
|
cacheUsage?: CacheUsage;
|
|
294
343
|
}
|
|
295
344
|
/**
|
|
296
|
-
* Streaming chunk from
|
|
345
|
+
* Streaming chunk from a text completion
|
|
297
346
|
*/
|
|
298
347
|
interface StreamChunk {
|
|
299
348
|
/** Content in this chunk */
|
|
@@ -313,6 +362,56 @@ interface StreamChunk {
|
|
|
313
362
|
/** Cache usage statistics */
|
|
314
363
|
cacheUsage?: CacheUsage;
|
|
315
364
|
}
|
|
365
|
+
/**
|
|
366
|
+
* Text completion provider interface — Shape 1: Text -> Text
|
|
367
|
+
*
|
|
368
|
+
* Sends instructions and data to an LLM and receives text responses,
|
|
369
|
+
* either as a complete response or as a stream of chunks.
|
|
370
|
+
*
|
|
371
|
+
* This covers both standard and "cheap" model calls — the difference
|
|
372
|
+
* is in model selection and parameters, not the interface shape.
|
|
373
|
+
*/
|
|
374
|
+
interface TextProvider {
|
|
375
|
+
/** Whether this provider supports file attachments */
|
|
376
|
+
readonly supportsFileAttachments: boolean;
|
|
377
|
+
/** Supported MIME types for file attachments */
|
|
378
|
+
readonly supportedMimeTypes: string[];
|
|
379
|
+
/** Whether this provider supports web search */
|
|
380
|
+
readonly supportsWebSearch: boolean;
|
|
381
|
+
/**
|
|
382
|
+
* Send a message and get a complete response
|
|
383
|
+
*/
|
|
384
|
+
sendMessage(params: LLMParams, apiKey: string): Promise<LLMResponse>;
|
|
385
|
+
/**
|
|
386
|
+
* Send a message and stream the response
|
|
387
|
+
*/
|
|
388
|
+
streamMessage(params: LLMParams, apiKey: string): AsyncGenerator<StreamChunk>;
|
|
389
|
+
/**
|
|
390
|
+
* Validate an API key
|
|
391
|
+
*/
|
|
392
|
+
validateApiKey(apiKey: string): Promise<boolean>;
|
|
393
|
+
/**
|
|
394
|
+
* Get available models from the provider
|
|
395
|
+
*/
|
|
396
|
+
getAvailableModels(apiKey: string): Promise<string[]>;
|
|
397
|
+
/**
|
|
398
|
+
* Get metadata for a specific model (optional)
|
|
399
|
+
*/
|
|
400
|
+
getModelMetadata?(modelId: string): ModelMetadata | undefined;
|
|
401
|
+
/**
|
|
402
|
+
* Get metadata for all models with warnings (optional)
|
|
403
|
+
*/
|
|
404
|
+
getModelsWithMetadata?(apiKey: string): Promise<ModelMetadata[]>;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Image Provider — Shape 2: Text -> Image
|
|
409
|
+
*
|
|
410
|
+
* Send instructions (a prompt) to an image generation model,
|
|
411
|
+
* receive one or more generated images.
|
|
412
|
+
*
|
|
413
|
+
* @module @quilltap/plugin-types/providers/image
|
|
414
|
+
*/
|
|
316
415
|
/**
|
|
317
416
|
* Image generation parameters
|
|
318
417
|
*/
|
|
@@ -369,94 +468,18 @@ interface ImageGenResponse {
|
|
|
369
468
|
raw?: unknown;
|
|
370
469
|
}
|
|
371
470
|
/**
|
|
372
|
-
*
|
|
373
|
-
*/
|
|
374
|
-
type ModelWarningLevel = 'info' | 'warning' | 'error';
|
|
375
|
-
/**
|
|
376
|
-
* Model warning information
|
|
377
|
-
*/
|
|
378
|
-
interface ModelWarning {
|
|
379
|
-
/** Warning severity level */
|
|
380
|
-
level: ModelWarningLevel;
|
|
381
|
-
/** Warning message */
|
|
382
|
-
message: string;
|
|
383
|
-
/** Optional link to documentation */
|
|
384
|
-
documentationUrl?: string;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Model metadata with warnings and capabilities
|
|
388
|
-
*/
|
|
389
|
-
interface ModelMetadata {
|
|
390
|
-
/** Model identifier */
|
|
391
|
-
id: string;
|
|
392
|
-
/** Human-readable display name */
|
|
393
|
-
displayName?: string;
|
|
394
|
-
/** Warnings or recommendations */
|
|
395
|
-
warnings?: ModelWarning[];
|
|
396
|
-
/** Whether the model is deprecated */
|
|
397
|
-
deprecated?: boolean;
|
|
398
|
-
/** Whether the model is experimental/preview */
|
|
399
|
-
experimental?: boolean;
|
|
400
|
-
/** Capabilities this model lacks */
|
|
401
|
-
missingCapabilities?: string[];
|
|
402
|
-
/** Maximum output tokens */
|
|
403
|
-
maxOutputTokens?: number;
|
|
404
|
-
/** Context window size */
|
|
405
|
-
contextWindow?: number;
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Core LLM provider interface
|
|
471
|
+
* Image generation provider interface — Shape 2: Text -> Image
|
|
409
472
|
*
|
|
410
|
-
*
|
|
411
|
-
|
|
412
|
-
interface LLMProvider {
|
|
413
|
-
/** Whether this provider supports file attachments */
|
|
414
|
-
readonly supportsFileAttachments: boolean;
|
|
415
|
-
/** Supported MIME types for file attachments */
|
|
416
|
-
readonly supportedMimeTypes: string[];
|
|
417
|
-
/** Whether this provider supports image generation */
|
|
418
|
-
readonly supportsImageGeneration: boolean;
|
|
419
|
-
/** Whether this provider supports web search */
|
|
420
|
-
readonly supportsWebSearch: boolean;
|
|
421
|
-
/**
|
|
422
|
-
* Send a message and get a complete response
|
|
423
|
-
*/
|
|
424
|
-
sendMessage(params: LLMParams, apiKey: string): Promise<LLMResponse>;
|
|
425
|
-
/**
|
|
426
|
-
* Send a message and stream the response
|
|
427
|
-
*/
|
|
428
|
-
streamMessage(params: LLMParams, apiKey: string): AsyncGenerator<StreamChunk>;
|
|
429
|
-
/**
|
|
430
|
-
* Validate an API key
|
|
431
|
-
*/
|
|
432
|
-
validateApiKey(apiKey: string): Promise<boolean>;
|
|
433
|
-
/**
|
|
434
|
-
* Get available models from the provider
|
|
435
|
-
*/
|
|
436
|
-
getAvailableModels(apiKey: string): Promise<string[]>;
|
|
437
|
-
/**
|
|
438
|
-
* Generate an image (optional)
|
|
439
|
-
*/
|
|
440
|
-
generateImage?(params: ImageGenParams, apiKey: string): Promise<ImageGenResponse>;
|
|
441
|
-
/**
|
|
442
|
-
* Get metadata for a specific model (optional)
|
|
443
|
-
*/
|
|
444
|
-
getModelMetadata?(modelId: string): ModelMetadata | undefined;
|
|
445
|
-
/**
|
|
446
|
-
* Get metadata for all models with warnings (optional)
|
|
447
|
-
*/
|
|
448
|
-
getModelsWithMetadata?(apiKey: string): Promise<ModelMetadata[]>;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Image generation provider interface
|
|
473
|
+
* Sends a text prompt to an image generation model and receives
|
|
474
|
+
* one or more generated images.
|
|
452
475
|
*/
|
|
453
|
-
interface
|
|
476
|
+
interface ImageProvider {
|
|
454
477
|
/** Provider identifier */
|
|
455
478
|
readonly provider: string;
|
|
456
479
|
/** Models supported by this provider */
|
|
457
480
|
readonly supportedModels: string[];
|
|
458
481
|
/**
|
|
459
|
-
* Generate an image
|
|
482
|
+
* Generate an image from a text prompt
|
|
460
483
|
*/
|
|
461
484
|
generateImage(params: ImageGenParams, apiKey: string): Promise<ImageGenResponse>;
|
|
462
485
|
/**
|
|
@@ -470,12 +493,12 @@ interface ImageGenProvider {
|
|
|
470
493
|
}
|
|
471
494
|
|
|
472
495
|
/**
|
|
473
|
-
* Embedding Provider
|
|
496
|
+
* Embedding Provider — Shape 3: Text -> Vector
|
|
474
497
|
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
498
|
+
* Send text to an embedding model, receive a numeric vector representation.
|
|
499
|
+
* Used for semantic search, RAG, and similarity matching.
|
|
477
500
|
*
|
|
478
|
-
* @module @quilltap/plugin-types/
|
|
501
|
+
* @module @quilltap/plugin-types/providers/embedding
|
|
479
502
|
*/
|
|
480
503
|
/**
|
|
481
504
|
* Result of an embedding operation
|
|
@@ -502,10 +525,10 @@ interface EmbeddingOptions {
|
|
|
502
525
|
dimensions?: number;
|
|
503
526
|
}
|
|
504
527
|
/**
|
|
505
|
-
*
|
|
528
|
+
* Embedding provider interface — Shape 3: Text -> Vector
|
|
506
529
|
*
|
|
507
|
-
*
|
|
508
|
-
*
|
|
530
|
+
* Sends text to an embedding model and receives a numeric vector
|
|
531
|
+
* representation for use in semantic search, RAG, and similarity matching.
|
|
509
532
|
*/
|
|
510
533
|
interface EmbeddingProvider {
|
|
511
534
|
/**
|
|
@@ -630,4 +653,4 @@ interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedd
|
|
|
630
653
|
*/
|
|
631
654
|
declare function isLocalEmbeddingProvider(provider: EmbeddingProvider | LocalEmbeddingProvider): provider is LocalEmbeddingProvider;
|
|
632
655
|
|
|
633
|
-
export { type AnthropicToolDefinition, type AttachmentResults, type CacheUsage, type EmbeddingOptions, type EmbeddingProvider, type EmbeddingResult, type FileAttachment, type GeneratedImage, type GoogleToolDefinition, type ImageGenParams, type ImageGenProvider, type ImageGenResponse, type JSONSchemaDefinition, type LLMMessage, type LLMParams, type LLMProvider, type LLMResponse, type LocalEmbeddingProvider, type LocalEmbeddingProviderState, type ModelMetadata, type ModelWarning, type ModelWarningLevel, type OpenAIToolDefinition, type ResponseFormat, type StreamChunk, type TokenUsage, type ToolCall, type ToolCallRequest, type ToolFormatOptions, type ToolResult, type UniversalTool, isLocalEmbeddingProvider };
|
|
656
|
+
export { type AnthropicToolDefinition, type AttachmentResults, type CacheUsage, type EmbeddingOptions, type EmbeddingProvider, type EmbeddingResult, type FileAttachment, type GeneratedImage, type GoogleToolDefinition, type ImageGenParams, type ImageProvider as ImageGenProvider, type ImageGenResponse, type ImageProvider, type JSONSchemaDefinition, type LLMMessage, type LLMParams, type TextProvider as LLMProvider, type LLMResponse, type LocalEmbeddingProvider, type LocalEmbeddingProviderState, type ModelMetadata, type ModelWarning, type ModelWarningLevel, type OpenAIToolDefinition, type ResponseFormat, type StreamChunk, type TextProvider, type TokenUsage, type ToolCall, type ToolCallRequest, type ToolFormatOptions, type ToolResult, type UniversalTool, isLocalEmbeddingProvider };
|
package/dist/llm/index.js
CHANGED
package/dist/llm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/providers/embedding.ts"],"names":[],"mappings":";;;AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.js","sourcesContent":["/**\n * Embedding Provider — Shape 3: Text -> Vector\n *\n * Send text to an embedding model, receive a numeric vector representation.\n * Used for semantic search, RAG, and similarity matching.\n *\n * @module @quilltap/plugin-types/providers/embedding\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Embedding provider interface — Shape 3: Text -> Vector\n *\n * Sends text to an embedding model and receives a numeric vector\n * representation for use in semantic search, RAG, and similarity matching.\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
|
package/dist/llm/index.mjs
CHANGED
package/dist/llm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/
|
|
1
|
+
{"version":3,"sources":["../../src/providers/embedding.ts"],"names":[],"mappings":";AAyLO,SAAS,yBACd,QAAA,EACoC;AACpC,EAAA,OAAO,WAAA,IAAe,QAAA,IAAY,WAAA,IAAe,QAAA,IAAY,UAAA,IAAc,QAAA;AAC7E","file":"index.mjs","sourcesContent":["/**\n * Embedding Provider — Shape 3: Text -> Vector\n *\n * Send text to an embedding model, receive a numeric vector representation.\n * Used for semantic search, RAG, and similarity matching.\n *\n * @module @quilltap/plugin-types/providers/embedding\n */\n\n/**\n * Result of an embedding operation\n */\nexport interface EmbeddingResult {\n /** The embedding vector (array of floating point numbers) */\n embedding: number[];\n /** The model used to generate the embedding */\n model: string;\n /** Number of dimensions in the embedding vector */\n dimensions: number;\n /** Token usage information (if available) */\n usage?: {\n promptTokens: number;\n totalTokens: number;\n cost?: number;\n };\n}\n\n/**\n * Options for embedding generation\n */\nexport interface EmbeddingOptions {\n /** Desired dimensions for the embedding (if model supports variable dimensions) */\n dimensions?: number;\n}\n\n/**\n * Embedding provider interface — Shape 3: Text -> Vector\n *\n * Sends text to an embedding model and receives a numeric vector\n * representation for use in semantic search, RAG, and similarity matching.\n */\nexport interface EmbeddingProvider {\n /**\n * Generate an embedding for a single text\n *\n * @param text The text to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns The embedding result\n */\n generateEmbedding(\n text: string,\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult>;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @param model The model to use\n * @param apiKey The API key for authentication\n * @param options Optional configuration\n * @returns Array of embedding results\n */\n generateBatchEmbeddings?(\n texts: string[],\n model: string,\n apiKey: string,\n options?: EmbeddingOptions\n ): Promise<EmbeddingResult[]>;\n\n /**\n * Get available embedding models\n *\n * @param apiKey The API key for authentication\n * @returns Array of model IDs\n */\n getAvailableModels?(apiKey: string): Promise<string[]>;\n\n /**\n * Check if the provider is available and properly configured\n *\n * @param apiKey Optional API key to validate\n * @returns True if the provider is ready to use\n */\n isAvailable?(apiKey?: string): Promise<boolean>;\n}\n\n/**\n * Serializable state for local embedding providers\n *\n * Used by providers like TF-IDF that maintain vocabulary state\n */\nexport interface LocalEmbeddingProviderState {\n /** The vocabulary as an array of [term, index] pairs */\n vocabulary: [string, number][];\n /** The IDF (Inverse Document Frequency) weights */\n idf: number[];\n /** Average document length across the corpus */\n avgDocLength: number;\n /** Size of the vocabulary */\n vocabularySize: number;\n /** Whether bigrams are included in the vocabulary */\n includeBigrams: boolean;\n /** Timestamp when the vocabulary was fitted */\n fittedAt: string;\n}\n\n/**\n * Local embedding provider interface\n *\n * Extended interface for local/offline embedding providers that\n * maintain vocabulary state (like TF-IDF). These providers don't\n * require API keys and can work entirely offline.\n */\nexport interface LocalEmbeddingProvider extends Omit<EmbeddingProvider, 'generateEmbedding' | 'generateBatchEmbeddings'> {\n /**\n * Generate an embedding for a single text\n * Local providers don't need apiKey parameter\n *\n * @param text The text to embed\n * @returns The embedding result\n */\n generateEmbedding(text: string): EmbeddingResult;\n\n /**\n * Generate embeddings for multiple texts in a batch\n *\n * @param texts Array of texts to embed\n * @returns Array of embedding results\n */\n generateBatchEmbeddings(texts: string[]): EmbeddingResult[];\n\n /**\n * Fit the vocabulary on a corpus of documents\n *\n * This method analyzes the corpus to build vocabulary, calculate IDF weights,\n * and other statistics needed for embedding generation.\n *\n * @param documents Array of text documents to analyze\n */\n fitCorpus(documents: string[]): void;\n\n /**\n * Check if the vocabulary has been fitted\n *\n * @returns True if fitCorpus has been called with documents\n */\n isFitted(): boolean;\n\n /**\n * Load state from a serialized representation\n *\n * @param state The serialized provider state\n */\n loadState(state: LocalEmbeddingProviderState): void;\n\n /**\n * Get the current state for serialization\n *\n * @returns The provider state, or null if not fitted\n */\n getState(): LocalEmbeddingProviderState | null;\n\n /**\n * Get the vocabulary size\n *\n * @returns Number of terms in the vocabulary\n */\n getVocabularySize(): number;\n\n /**\n * Get the embedding dimensions\n *\n * @returns Number of dimensions in generated embeddings\n */\n getDimensions(): number;\n}\n\n/**\n * Type guard to check if a provider is a local embedding provider\n */\nexport function isLocalEmbeddingProvider(\n provider: EmbeddingProvider | LocalEmbeddingProvider\n): provider is LocalEmbeddingProvider {\n return 'fitCorpus' in provider && 'loadState' in provider && 'getState' in provider;\n}\n"]}
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a4 as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a5 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a6 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a7 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as ScoringProviderConfigRequirements, H as ScoringProviderMetadata, J as ScoringProviderPlugin, K as ScoringProviderPluginExport, N as SearchOutput, O as SearchProviderConfig, Q as SearchProviderConfigRequirements, T as SearchProviderMetadata, U as SearchProviderPlugin, V as SearchProviderPluginExport, W as SearchResult, X as Spacing, Z as TextProviderPlugin, _ as ThemeMetadata, $ as ThemePlugin, a0 as ThemePluginExport, a1 as ThemeTokens, a3 as Typography } from '../index-DtW7izgw.mjs';
|
|
2
2
|
import '../llm/index.mjs';
|
|
3
|
+
import '../providers/index.mjs';
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { a4 as AnnotationButton, A as AttachmentSupport, a as ColorPalette, a5 as DialogueDetection, E as Effects, b as EmbeddedFont, c as EmbeddingModelInfo, F as FontDefinition, I as IconProps, d as ImageGenerationModelInfo, e as ImageProviderConstraints, g as InstalledPluginInfo, L as LLMProviderPlugin, h as ModelInfo, i as ModerationCategoryResult, a6 as ModerationProviderConfig, j as ModerationProviderConfigRequirements, k as ModerationProviderMetadata, l as ModerationProviderPlugin, m as ModerationProviderPluginExport, n as ModerationResult, P as PluginAuthor, o as PluginCapability, p as PluginCategory, q as PluginCompatibility, s as PluginManifest, t as PluginPermissions, u as PluginStatus, v as ProviderCapabilities, w as ProviderConfig, x as ProviderConfigRequirements, y as ProviderMetadata, z as ProviderPluginExport, a7 as RenderingPattern, R as RoleplayTemplateConfig, B as RoleplayTemplateMetadata, D as RoleplayTemplatePlugin, G as RoleplayTemplatePluginExport, S as ScoringProviderConfigRequirements, H as ScoringProviderMetadata, J as ScoringProviderPlugin, K as ScoringProviderPluginExport, N as SearchOutput, O as SearchProviderConfig, Q as SearchProviderConfigRequirements, T as SearchProviderMetadata, U as SearchProviderPlugin, V as SearchProviderPluginExport, W as SearchResult, X as Spacing, Z as TextProviderPlugin, _ as ThemeMetadata, $ as ThemePlugin, a0 as ThemePluginExport, a1 as ThemeTokens, a3 as Typography } from '../index-BXJLgAuZ.js';
|
|
2
2
|
import '../llm/index.js';
|
|
3
|
+
import '../providers/index.js';
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export { AttachmentResults, CacheUsage, EmbeddingOptions, EmbeddingProvider, EmbeddingResult, FileAttachment, GeneratedImage, ImageGenParams, ImageGenResponse, ImageGenProvider as ImageProvider, JSONSchemaDefinition, LLMMessage, LLMParams, LLMResponse, LocalEmbeddingProvider, LocalEmbeddingProviderState, ModelMetadata, ModelWarning, ModelWarningLevel, ResponseFormat, StreamChunk, LLMProvider as TextProvider, TokenUsage, isLocalEmbeddingProvider } from '../llm/index.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Scoring Provider — Shape 4: Text + Candidates -> Scores
|
|
5
|
+
*
|
|
6
|
+
* Send content (and optionally candidates or labels) to a scoring model,
|
|
7
|
+
* receive scored categories or ranked results. This generalizes content
|
|
8
|
+
* moderation, reranking, and classification into a single interface shape.
|
|
9
|
+
*
|
|
10
|
+
* ## Supported Tasks
|
|
11
|
+
*
|
|
12
|
+
* ### Moderation (implemented)
|
|
13
|
+
* Score content against safety categories. The provider returns per-category
|
|
14
|
+
* flagged/score pairs (e.g., "violence": 0.95, "hate": 0.02).
|
|
15
|
+
*
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const result = await provider.score({
|
|
18
|
+
* content: 'some user message',
|
|
19
|
+
* task: 'moderation',
|
|
20
|
+
* }, apiKey);
|
|
21
|
+
* // result.flagged = true, result.categories = [{ category: 'violence', flagged: true, score: 0.95 }, ...]
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ### Reranking (future)
|
|
25
|
+
* Given a query and candidate passages, score each passage by relevance.
|
|
26
|
+
* Uses `candidates` field to pass the passages to rank.
|
|
27
|
+
*
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const result = await provider.score({
|
|
30
|
+
* content: 'What is the capital of France?',
|
|
31
|
+
* task: 'reranking',
|
|
32
|
+
* candidates: ['Paris is the capital of France.', 'London is in England.', ...],
|
|
33
|
+
* }, apiKey);
|
|
34
|
+
* // result.categories = [{ category: '0', score: 0.98 }, { category: '1', score: 0.12 }, ...]
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ### Classification (future)
|
|
38
|
+
* Classify content into one or more predefined labels.
|
|
39
|
+
* Uses `labels` field to define the classification categories.
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const result = await provider.score({
|
|
43
|
+
* content: 'I love this product!',
|
|
44
|
+
* task: 'classification',
|
|
45
|
+
* labels: ['positive', 'negative', 'neutral'],
|
|
46
|
+
* }, apiKey);
|
|
47
|
+
* // result.categories = [{ category: 'positive', flagged: true, score: 0.92 }, ...]
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @module @quilltap/plugin-types/providers/scoring
|
|
51
|
+
*/
|
|
52
|
+
/**
|
|
53
|
+
* The type of scoring task to perform
|
|
54
|
+
*/
|
|
55
|
+
type ScoringTask = 'moderation' | 'reranking' | 'classification';
|
|
56
|
+
/**
|
|
57
|
+
* Input for a scoring operation
|
|
58
|
+
*/
|
|
59
|
+
interface ScoringInput {
|
|
60
|
+
/** The primary text to score */
|
|
61
|
+
content: string;
|
|
62
|
+
/** The scoring task type */
|
|
63
|
+
task: ScoringTask;
|
|
64
|
+
/**
|
|
65
|
+
* Candidate passages for reranking.
|
|
66
|
+
* Each candidate is scored against the content (used as query).
|
|
67
|
+
*/
|
|
68
|
+
candidates?: string[];
|
|
69
|
+
/**
|
|
70
|
+
* Label set for classification.
|
|
71
|
+
* Content is classified into these categories.
|
|
72
|
+
*/
|
|
73
|
+
labels?: string[];
|
|
74
|
+
/** Task-specific options */
|
|
75
|
+
options?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A single category/label score
|
|
79
|
+
*/
|
|
80
|
+
interface CategoryScore {
|
|
81
|
+
/** Category or label name (e.g., 'violence', 'positive', or candidate index) */
|
|
82
|
+
category: string;
|
|
83
|
+
/** Whether this category was triggered/flagged */
|
|
84
|
+
flagged: boolean;
|
|
85
|
+
/** Confidence score (0-1) */
|
|
86
|
+
score: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Result from a scoring operation
|
|
90
|
+
*/
|
|
91
|
+
interface ScoringResult {
|
|
92
|
+
/** Overall flagged status (for moderation) or top match (for classification) */
|
|
93
|
+
flagged: boolean;
|
|
94
|
+
/** Per-category/label breakdown with scores */
|
|
95
|
+
categories: CategoryScore[];
|
|
96
|
+
/** Which task produced this result */
|
|
97
|
+
task: ScoringTask;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Scoring provider interface — Shape 4: Text + Candidates -> Scores
|
|
101
|
+
*
|
|
102
|
+
* Sends content to a scoring model and receives scored categories,
|
|
103
|
+
* ranked results, or classification labels. Generalizes moderation,
|
|
104
|
+
* reranking, and classification into a single provider shape.
|
|
105
|
+
*/
|
|
106
|
+
interface ScoringProvider {
|
|
107
|
+
/**
|
|
108
|
+
* Score content according to the specified task
|
|
109
|
+
*
|
|
110
|
+
* @param input The scoring input with content, task type, and optional candidates/labels
|
|
111
|
+
* @param apiKey The API key for authentication
|
|
112
|
+
* @param baseUrl Optional base URL for the scoring API
|
|
113
|
+
* @returns Scored results with per-category breakdown
|
|
114
|
+
*/
|
|
115
|
+
score(input: ScoringInput, apiKey: string, baseUrl?: string): Promise<ScoringResult>;
|
|
116
|
+
/**
|
|
117
|
+
* Get the scoring tasks this provider supports
|
|
118
|
+
*
|
|
119
|
+
* @returns Array of supported task types
|
|
120
|
+
*/
|
|
121
|
+
getSupportedTasks(): ScoringTask[];
|
|
122
|
+
/**
|
|
123
|
+
* Validate an API key for this provider (optional)
|
|
124
|
+
*
|
|
125
|
+
* @param apiKey The API key to validate
|
|
126
|
+
* @param baseUrl Optional base URL
|
|
127
|
+
* @returns True if valid
|
|
128
|
+
*/
|
|
129
|
+
validateApiKey?(apiKey: string, baseUrl?: string): Promise<boolean>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type { CategoryScore, ScoringInput, ScoringProvider, ScoringResult, ScoringTask };
|