ai.matey.frontend 0.2.0 → 0.3.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/CHANGELOG.md +40 -0
- package/dist/cjs/adapters/anthropic.js +156 -16
- package/dist/cjs/adapters/anthropic.js.map +1 -1
- package/dist/cjs/adapters/chrome-ai.js +58 -0
- package/dist/cjs/adapters/chrome-ai.js.map +1 -1
- package/dist/cjs/adapters/gemini.js +57 -0
- package/dist/cjs/adapters/gemini.js.map +1 -1
- package/dist/cjs/adapters/generic.js +56 -4
- package/dist/cjs/adapters/generic.js.map +1 -1
- package/dist/cjs/adapters/mistral.js +59 -0
- package/dist/cjs/adapters/mistral.js.map +1 -1
- package/dist/cjs/adapters/ollama.js +59 -0
- package/dist/cjs/adapters/ollama.js.map +1 -1
- package/dist/cjs/adapters/openai.js +199 -32
- package/dist/cjs/adapters/openai.js.map +1 -1
- package/dist/esm/adapters/anthropic.js +156 -16
- package/dist/esm/adapters/anthropic.js.map +1 -1
- package/dist/esm/adapters/chrome-ai.js +58 -0
- package/dist/esm/adapters/chrome-ai.js.map +1 -1
- package/dist/esm/adapters/gemini.js +57 -0
- package/dist/esm/adapters/gemini.js.map +1 -1
- package/dist/esm/adapters/generic.js +56 -4
- package/dist/esm/adapters/generic.js.map +1 -1
- package/dist/esm/adapters/mistral.js +59 -0
- package/dist/esm/adapters/mistral.js.map +1 -1
- package/dist/esm/adapters/ollama.js +59 -0
- package/dist/esm/adapters/ollama.js.map +1 -1
- package/dist/esm/adapters/openai.js +199 -32
- package/dist/esm/adapters/openai.js.map +1 -1
- package/dist/types/adapters/anthropic.d.ts +254 -8
- package/dist/types/adapters/anthropic.d.ts.map +1 -1
- package/dist/types/adapters/chrome-ai.d.ts +95 -0
- package/dist/types/adapters/chrome-ai.d.ts.map +1 -1
- package/dist/types/adapters/gemini.d.ts +170 -0
- package/dist/types/adapters/gemini.d.ts.map +1 -1
- package/dist/types/adapters/generic.d.ts +56 -4
- package/dist/types/adapters/generic.d.ts.map +1 -1
- package/dist/types/adapters/mistral.d.ts +143 -0
- package/dist/types/adapters/mistral.d.ts.map +1 -1
- package/dist/types/adapters/ollama.d.ts +132 -0
- package/dist/types/adapters/ollama.d.ts.map +1 -1
- package/dist/types/adapters/openai.d.ts +252 -8
- package/dist/types/adapters/openai.d.ts.map +1 -1
- package/package.json +2 -3
|
@@ -32,7 +32,27 @@ export class AnthropicFrontendAdapter {
|
|
|
32
32
|
},
|
|
33
33
|
};
|
|
34
34
|
/**
|
|
35
|
-
* Convert Anthropic request to Universal IR.
|
|
35
|
+
* Convert Anthropic Messages API request to Universal IR format.
|
|
36
|
+
*
|
|
37
|
+
* This method transforms an Anthropic-formatted request into the standardized
|
|
38
|
+
* Intermediate Representation (IR) format. It handles Anthropic's unique system
|
|
39
|
+
* message format (separate from messages array) by converting it to IR's
|
|
40
|
+
* in-messages format, and maps Anthropic-specific parameters like top_k.
|
|
41
|
+
*
|
|
42
|
+
* @param request - Anthropic Messages API request
|
|
43
|
+
* @returns Promise resolving to IR chat request
|
|
44
|
+
* @throws {AdapterConversionError} If conversion fails
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const adapter = new AnthropicFrontendAdapter();
|
|
49
|
+
* const irRequest = await adapter.toIR({
|
|
50
|
+
* model: 'claude-3-5-sonnet-20241022',
|
|
51
|
+
* max_tokens: 1024,
|
|
52
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
53
|
+
* system: 'You are a helpful assistant'
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
36
56
|
*/
|
|
37
57
|
toIR(request) {
|
|
38
58
|
try {
|
|
@@ -57,6 +77,12 @@ export class AnthropicFrontendAdapter {
|
|
|
57
77
|
topK: request.top_k,
|
|
58
78
|
stopSequences: request.stop_sequences,
|
|
59
79
|
},
|
|
80
|
+
tools: request.tools?.map((tool) => ({
|
|
81
|
+
name: tool.name,
|
|
82
|
+
description: tool.description ?? '',
|
|
83
|
+
parameters: tool.input_schema,
|
|
84
|
+
})),
|
|
85
|
+
toolChoice: this.convertToolChoiceToIR(request.tool_choice),
|
|
60
86
|
stream: request.stream ?? false,
|
|
61
87
|
metadata: {
|
|
62
88
|
requestId: crypto.randomUUID(),
|
|
@@ -83,7 +109,23 @@ export class AnthropicFrontendAdapter {
|
|
|
83
109
|
}
|
|
84
110
|
}
|
|
85
111
|
/**
|
|
86
|
-
* Convert Universal IR response to Anthropic format.
|
|
112
|
+
* Convert Universal IR response back to Anthropic Messages API format.
|
|
113
|
+
*
|
|
114
|
+
* This method transforms the standardized IR response into the format
|
|
115
|
+
* expected by Anthropic's Messages API. It handles message conversion,
|
|
116
|
+
* stop reason mapping, and usage statistics formatting specific to
|
|
117
|
+
* Anthropic's response structure.
|
|
118
|
+
*
|
|
119
|
+
* @param response - Universal IR chat response
|
|
120
|
+
* @returns Promise resolving to Anthropic Messages API response
|
|
121
|
+
* @throws {AdapterConversionError} If conversion fails
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const adapter = new AnthropicFrontendAdapter();
|
|
126
|
+
* const anthropicResponse = await adapter.fromIR(irResponse);
|
|
127
|
+
* console.log(anthropicResponse.content[0].text);
|
|
128
|
+
* ```
|
|
87
129
|
*/
|
|
88
130
|
fromIR(response) {
|
|
89
131
|
try {
|
|
@@ -118,12 +160,39 @@ export class AnthropicFrontendAdapter {
|
|
|
118
160
|
}
|
|
119
161
|
}
|
|
120
162
|
/**
|
|
121
|
-
* Convert Universal IR stream to Anthropic SSE format.
|
|
163
|
+
* Convert Universal IR stream to Anthropic Server-Sent Events (SSE) format.
|
|
164
|
+
*
|
|
165
|
+
* This async generator method transforms a stream of IR chunks into
|
|
166
|
+
* Anthropic-formatted streaming events. It handles stream mode conversion,
|
|
167
|
+
* tracks message metadata, and emits properly formatted SSE events
|
|
168
|
+
* compatible with Anthropic's streaming API including message_start,
|
|
169
|
+
* content_block_delta, and message_stop events.
|
|
170
|
+
*
|
|
171
|
+
* @param stream - Universal IR chat stream
|
|
172
|
+
* @param options - Optional stream conversion options (stream mode, etc.)
|
|
173
|
+
* @yields Anthropic-formatted streaming events
|
|
174
|
+
* @throws {AdapterConversionError} If stream conversion fails
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const adapter = new AnthropicFrontendAdapter();
|
|
179
|
+
* for await (const event of adapter.fromIRStream(irStream)) {
|
|
180
|
+
* if (event.type === 'content_block_delta') {
|
|
181
|
+
* console.log(event.delta.text);
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
* ```
|
|
122
185
|
*/
|
|
123
186
|
async *fromIRStream(stream, options) {
|
|
124
187
|
try {
|
|
125
188
|
// Apply stream mode conversion if options provided
|
|
126
189
|
const processedStream = options ? convertStreamMode(stream, options) : stream;
|
|
190
|
+
// Content blocks are opened lazily (a tool-only stream must not emit
|
|
191
|
+
// an empty text block) and closed when a different block starts.
|
|
192
|
+
let nextBlockIndex = 0;
|
|
193
|
+
let openBlockIndex = null;
|
|
194
|
+
let openTextBlockIndex = null;
|
|
195
|
+
const toolBlockIndexById = new Map();
|
|
127
196
|
for await (const chunk of processedStream) {
|
|
128
197
|
switch (chunk.type) {
|
|
129
198
|
case 'start':
|
|
@@ -137,27 +206,62 @@ export class AnthropicFrontendAdapter {
|
|
|
137
206
|
model: chunk.metadata.provenance?.backend || 'unknown',
|
|
138
207
|
},
|
|
139
208
|
};
|
|
140
|
-
// Emit content_block_start
|
|
141
|
-
yield {
|
|
142
|
-
type: 'content_block_start',
|
|
143
|
-
index: 0,
|
|
144
|
-
content_block: { type: 'text', text: '' },
|
|
145
|
-
};
|
|
146
209
|
break;
|
|
147
210
|
case 'content':
|
|
148
|
-
//
|
|
211
|
+
// Open a text block on first text delta (or after a tool block)
|
|
212
|
+
if (openTextBlockIndex === null) {
|
|
213
|
+
if (openBlockIndex !== null) {
|
|
214
|
+
yield { type: 'content_block_stop', index: openBlockIndex };
|
|
215
|
+
}
|
|
216
|
+
openTextBlockIndex = nextBlockIndex++;
|
|
217
|
+
openBlockIndex = openTextBlockIndex;
|
|
218
|
+
yield {
|
|
219
|
+
type: 'content_block_start',
|
|
220
|
+
index: openTextBlockIndex,
|
|
221
|
+
content_block: { type: 'text', text: '' },
|
|
222
|
+
};
|
|
223
|
+
}
|
|
149
224
|
yield {
|
|
150
225
|
type: 'content_block_delta',
|
|
151
|
-
index:
|
|
226
|
+
index: openTextBlockIndex,
|
|
152
227
|
delta: { type: 'text_delta', text: chunk.delta },
|
|
153
228
|
};
|
|
154
229
|
break;
|
|
230
|
+
case 'tool_use': {
|
|
231
|
+
let blockIndex = toolBlockIndexById.get(chunk.id);
|
|
232
|
+
// First chunk for this tool call: open its content block
|
|
233
|
+
if (blockIndex === undefined) {
|
|
234
|
+
if (openBlockIndex !== null) {
|
|
235
|
+
yield { type: 'content_block_stop', index: openBlockIndex };
|
|
236
|
+
if (openBlockIndex === openTextBlockIndex) {
|
|
237
|
+
openTextBlockIndex = null;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
blockIndex = nextBlockIndex++;
|
|
241
|
+
toolBlockIndexById.set(chunk.id, blockIndex);
|
|
242
|
+
openBlockIndex = blockIndex;
|
|
243
|
+
yield {
|
|
244
|
+
type: 'content_block_start',
|
|
245
|
+
index: blockIndex,
|
|
246
|
+
content_block: { type: 'tool_use', id: chunk.id, name: chunk.name, input: {} },
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
if (chunk.inputDelta) {
|
|
250
|
+
yield {
|
|
251
|
+
type: 'content_block_delta',
|
|
252
|
+
index: blockIndex,
|
|
253
|
+
delta: { type: 'input_json_delta', partial_json: chunk.inputDelta },
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
155
258
|
case 'done': {
|
|
156
|
-
//
|
|
157
|
-
|
|
158
|
-
type: 'content_block_stop',
|
|
159
|
-
|
|
160
|
-
|
|
259
|
+
// Close the open content block (if any)
|
|
260
|
+
if (openBlockIndex !== null) {
|
|
261
|
+
yield { type: 'content_block_stop', index: openBlockIndex };
|
|
262
|
+
openBlockIndex = null;
|
|
263
|
+
openTextBlockIndex = null;
|
|
264
|
+
}
|
|
161
265
|
// Emit message_delta with stop reason
|
|
162
266
|
const stopReason = this.mapFinishReason(chunk.finishReason);
|
|
163
267
|
yield {
|
|
@@ -202,6 +306,24 @@ export class AnthropicFrontendAdapter {
|
|
|
202
306
|
// ==========================================================================
|
|
203
307
|
// Private Helper Methods
|
|
204
308
|
// ==========================================================================
|
|
309
|
+
/**
|
|
310
|
+
* Convert Anthropic tool_choice to IR toolChoice.
|
|
311
|
+
*/
|
|
312
|
+
convertToolChoiceToIR(toolChoice) {
|
|
313
|
+
if (toolChoice === undefined) {
|
|
314
|
+
return undefined;
|
|
315
|
+
}
|
|
316
|
+
switch (toolChoice.type) {
|
|
317
|
+
case 'auto':
|
|
318
|
+
return 'auto';
|
|
319
|
+
case 'any':
|
|
320
|
+
return 'required';
|
|
321
|
+
case 'none':
|
|
322
|
+
return 'none';
|
|
323
|
+
case 'tool':
|
|
324
|
+
return { name: toolChoice.name };
|
|
325
|
+
}
|
|
326
|
+
}
|
|
205
327
|
/**
|
|
206
328
|
* Convert Anthropic message to IR message.
|
|
207
329
|
*/
|
|
@@ -256,6 +378,15 @@ export class AnthropicFrontendAdapter {
|
|
|
256
378
|
name: block.name,
|
|
257
379
|
input: block.input,
|
|
258
380
|
};
|
|
381
|
+
case 'tool_result':
|
|
382
|
+
return {
|
|
383
|
+
type: 'tool_result',
|
|
384
|
+
toolUseId: block.tool_use_id,
|
|
385
|
+
content: typeof block.content === 'string'
|
|
386
|
+
? block.content
|
|
387
|
+
: block.content.map((text) => ({ type: 'text', text: text.text })),
|
|
388
|
+
isError: block.is_error,
|
|
389
|
+
};
|
|
259
390
|
default:
|
|
260
391
|
// Unknown block type, convert to text
|
|
261
392
|
return {
|
|
@@ -299,6 +430,15 @@ export class AnthropicFrontendAdapter {
|
|
|
299
430
|
name: block.name,
|
|
300
431
|
input: block.input,
|
|
301
432
|
};
|
|
433
|
+
case 'tool_result':
|
|
434
|
+
return {
|
|
435
|
+
type: 'tool_result',
|
|
436
|
+
tool_use_id: block.toolUseId,
|
|
437
|
+
content: typeof block.content === 'string'
|
|
438
|
+
? block.content
|
|
439
|
+
: block.content.map((text) => ({ type: 'text', text: text.text })),
|
|
440
|
+
is_error: block.isError,
|
|
441
|
+
};
|
|
302
442
|
default:
|
|
303
443
|
// Fallback to text
|
|
304
444
|
return { type: 'text', text: JSON.stringify(block) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/adapters/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/adapters/anthropic.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH,OAAO,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAwRnD,+EAA+E;AAC/E,6BAA6B;AAC7B,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,wBAAwB;IAK1B,QAAQ,GAAoB;QACnC,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,IAAI;YACX,gBAAgB,EAAE,MAAM;YACxB,qBAAqB,EAAE,oBAAoB;YAC3C,8BAA8B,EAAE,KAAK,EAAE,4CAA4C;YACnF,mBAAmB,EAAE,IAAI;YACzB,YAAY,EAAE,IAAI;YAClB,YAAY,EAAE,IAAI;SACnB;KACF,CAAC;IAEF;;;;;;;;;;;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CAAC,IAAI;6BACxB;yBACF,CAAC;oBACJ,CAAC;gBAEH,KAAK,UAAU;oBACb,OAAO;wBACL,IAAI,EAAE,UAAU;wBAChB,EAAE,EAAE,KAAK,CAAC,EAAE;wBACZ,IAAI,EAAE,KAAK,CAAC,IAAI;wBAChB,KAAK,EAAE,KAAK,CAAC,KAAK;qBACnB,CAAC;gBAEJ,KAAK,aAAa;oBAChB,OAAO;wBACL,IAAI,EAAE,aAAa;wBACnB,WAAW,EAAE,KAAK,CAAC,SAAS;wBAC5B,OAAO,EACL,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;4BAC/B,CAAC,CAAC,KAAK,CAAC,OAAO;4BACf,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;wBAC/E,QAAQ,EAAE,KAAK,CAAC,OAAO;qBACxB,CAAC;gBAEJ;oBACE,mBAAmB;oBACnB,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,eAAe,CACrB,YAAoB;QAEpB,QAAQ,YAAY,EAAE,CAAC;YACrB,KAAK,MAAM;gBACT,OAAO,UAAU,CAAC;YACpB,KAAK,QAAQ;gBACX,OAAO,YAAY,CAAC;YACtB,KAAK,YAAY;gBACf,OAAO,UAAU,CAAC;YACpB;gBACE,OAAO,IAAI,CAAC;QAChB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -19,6 +19,27 @@ export class ChromeAIFrontendAdapter {
|
|
|
19
19
|
supportsMultipleSystemMessages: false,
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Convert Chrome AI request to Universal IR format.
|
|
24
|
+
*
|
|
25
|
+
* This method transforms a Chrome AI-formatted request into the standardized
|
|
26
|
+
* Intermediate Representation (IR) format. Chrome AI uses a simple prompt-based
|
|
27
|
+
* format, so this converts the single prompt string into a user message within
|
|
28
|
+
* the IR message array structure.
|
|
29
|
+
*
|
|
30
|
+
* @param request - Chrome AI request with prompt and optional parameters
|
|
31
|
+
* @returns Promise resolving to IR chat request
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const adapter = new ChromeAIFrontendAdapter();
|
|
36
|
+
* const irRequest = await adapter.toIR({
|
|
37
|
+
* prompt: 'What is the capital of France?',
|
|
38
|
+
* temperature: 0.7,
|
|
39
|
+
* topK: 40
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
22
43
|
toIR(request) {
|
|
23
44
|
return Promise.resolve({
|
|
24
45
|
messages: [{ role: 'user', content: request.prompt }],
|
|
@@ -33,11 +54,48 @@ export class ChromeAIFrontendAdapter {
|
|
|
33
54
|
},
|
|
34
55
|
});
|
|
35
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Convert Universal IR response back to Chrome AI format.
|
|
59
|
+
*
|
|
60
|
+
* This method transforms the standardized IR response into the format
|
|
61
|
+
* expected by Chrome AI's interface. It extracts the text content from
|
|
62
|
+
* the IR message and returns it in Chrome AI's simple `{ text }` format.
|
|
63
|
+
*
|
|
64
|
+
* @param response - Universal IR chat response
|
|
65
|
+
* @returns Promise resolving to Chrome AI response
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const adapter = new ChromeAIFrontendAdapter();
|
|
70
|
+
* const chromeResponse = await adapter.fromIR(irResponse);
|
|
71
|
+
* console.log(chromeResponse.text);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
36
74
|
fromIR(response) {
|
|
37
75
|
return Promise.resolve({
|
|
38
76
|
text: typeof response.message.content === 'string' ? response.message.content : '',
|
|
39
77
|
});
|
|
40
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Convert Universal IR stream to Chrome AI streaming format.
|
|
81
|
+
*
|
|
82
|
+
* This async generator method transforms a stream of IR chunks into
|
|
83
|
+
* Chrome AI's simple text streaming format. It yields raw text strings
|
|
84
|
+
* (no JSON wrapping, no SSE format) and supports stream mode conversion
|
|
85
|
+
* through options (delta, full, or text-only modes).
|
|
86
|
+
*
|
|
87
|
+
* @param stream - Universal IR chat stream
|
|
88
|
+
* @param options - Optional stream conversion options (stream mode, etc.)
|
|
89
|
+
* @yields Raw text strings
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const adapter = new ChromeAIFrontendAdapter();
|
|
94
|
+
* for await (const textChunk of adapter.fromIRStream(irStream)) {
|
|
95
|
+
* console.log(textChunk); // Raw text like "Hello" or " world"
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
41
99
|
async *fromIRStream(stream, options) {
|
|
42
100
|
// Apply stream mode conversion if options provided
|
|
43
101
|
const processedStream = options ? convertStreamMode(stream, options) : stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chrome-ai.js","sourceRoot":"","sources":["../../../src/adapters/chrome-ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"chrome-ai.js","sourceRoot":"","sources":["../../../src/adapters/chrome-ai.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAmDnD,MAAM,OAAO,uBAAuB;IACzB,QAAQ,GAAoB;QACnC,IAAI,EAAE,oBAAoB;QAC1B,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,WAAW;QACrB,YAAY,EAAE;YACZ,SAAS,EAAE,IAAI;YACf,UAAU,EAAE,KAAK;YACjB,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,KAAK,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -19,6 +19,26 @@ export class GeminiFrontendAdapter {
|
|
|
19
19
|
supportsMultipleSystemMessages: false,
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* Convert Google Gemini API request to Universal IR format.
|
|
24
|
+
*
|
|
25
|
+
* This method transforms a Gemini-formatted request into the standardized
|
|
26
|
+
* Intermediate Representation (IR) format. It handles Gemini's unique
|
|
27
|
+
* content structure (parts array), converts 'model' role to 'assistant',
|
|
28
|
+
* and adjusts temperature values (Gemini uses 0-1, IR uses 0-2).
|
|
29
|
+
*
|
|
30
|
+
* @param request - Google Gemini API request
|
|
31
|
+
* @returns Promise resolving to IR chat request
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* const adapter = new GeminiFrontendAdapter();
|
|
36
|
+
* const irRequest = await adapter.toIR({
|
|
37
|
+
* contents: [{ role: 'user', parts: [{ text: 'Hello!' }] }],
|
|
38
|
+
* generationConfig: { temperature: 0.7 }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
22
42
|
toIR(request) {
|
|
23
43
|
const messages = request.contents.map((c) => ({
|
|
24
44
|
role: c.role === 'model' ? 'assistant' : 'user',
|
|
@@ -50,6 +70,24 @@ export class GeminiFrontendAdapter {
|
|
|
50
70
|
},
|
|
51
71
|
});
|
|
52
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Convert Universal IR response back to Google Gemini API format.
|
|
75
|
+
*
|
|
76
|
+
* This method transforms the standardized IR response into the format
|
|
77
|
+
* expected by Gemini's API. It converts 'assistant' role back to 'model',
|
|
78
|
+
* structures content as parts array, and maps finish reasons to Gemini's
|
|
79
|
+
* specific format (STOP, MAX_TOKENS, OTHER).
|
|
80
|
+
*
|
|
81
|
+
* @param response - Universal IR chat response
|
|
82
|
+
* @returns Promise resolving to Gemini API response
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const adapter = new GeminiFrontendAdapter();
|
|
87
|
+
* const geminiResponse = await adapter.fromIR(irResponse);
|
|
88
|
+
* console.log(geminiResponse.candidates[0].content.parts[0].text);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
53
91
|
fromIR(response) {
|
|
54
92
|
return Promise.resolve({
|
|
55
93
|
candidates: [
|
|
@@ -78,6 +116,25 @@ export class GeminiFrontendAdapter {
|
|
|
78
116
|
: undefined,
|
|
79
117
|
});
|
|
80
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* Convert Universal IR stream to Google Gemini Server-Sent Events format.
|
|
121
|
+
*
|
|
122
|
+
* This async generator method transforms a stream of IR chunks into
|
|
123
|
+
* Gemini-formatted SSE responses. It yields Server-Sent Event strings
|
|
124
|
+
* with the "data: " prefix containing JSON candidates with parts array.
|
|
125
|
+
*
|
|
126
|
+
* @param stream - Universal IR chat stream
|
|
127
|
+
* @param _options - Optional stream conversion options (currently unused)
|
|
128
|
+
* @yields Server-Sent Event formatted strings
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const adapter = new GeminiFrontendAdapter();
|
|
133
|
+
* for await (const sseData of adapter.fromIRStream(irStream)) {
|
|
134
|
+
* console.log(sseData); // "data: {...}\n\n"
|
|
135
|
+
* }
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
81
138
|
async *fromIRStream(stream, _options) {
|
|
82
139
|
for await (const chunk of stream) {
|
|
83
140
|
if (chunk.type === 'content') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/adapters/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"gemini.js","sourceRoot":"","sources":["../../../src/adapters/gemini.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmKH,MAAM,OAAO,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C,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,CAAC,YAAY,CACjB,MAAqC,EACrC,QAAkC;QAElC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC7B,MAAM,QAAQ;oBACZ,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;oBACjF,MAAM,CAAC;YACX,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -77,9 +77,26 @@ export class GenericFrontendAdapter {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* Pass through IR request
|
|
80
|
+
* Pass through Universal IR request without conversion.
|
|
81
81
|
*
|
|
82
|
-
*
|
|
82
|
+
* This method accepts an IR request and returns it directly, as this is
|
|
83
|
+
* a passthrough adapter. When provenance tracking is enabled (default),
|
|
84
|
+
* it adds the frontend adapter name to the provenance metadata for
|
|
85
|
+
* tracking purposes, but otherwise performs no transformations.
|
|
86
|
+
*
|
|
87
|
+
* @param request - Universal IR chat request
|
|
88
|
+
* @returns Promise resolving to the same IR request (with optional provenance)
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const adapter = new GenericFrontendAdapter();
|
|
93
|
+
* const irRequest = await adapter.toIR({
|
|
94
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
95
|
+
* parameters: { model: 'gpt-4', temperature: 0.7 },
|
|
96
|
+
* metadata: { requestId: 'req_123', timestamp: Date.now(), provenance: {} }
|
|
97
|
+
* });
|
|
98
|
+
* // Returns the same request with provenance.frontend = 'generic-frontend'
|
|
99
|
+
* ```
|
|
83
100
|
*/
|
|
84
101
|
toIR(request) {
|
|
85
102
|
// Optionally add provenance
|
|
@@ -98,13 +115,48 @@ export class GenericFrontendAdapter {
|
|
|
98
115
|
return Promise.resolve(request);
|
|
99
116
|
}
|
|
100
117
|
/**
|
|
101
|
-
* Pass through IR response
|
|
118
|
+
* Pass through Universal IR response without conversion.
|
|
119
|
+
*
|
|
120
|
+
* This method accepts an IR response and returns it directly without
|
|
121
|
+
* any transformation. Since this is a passthrough adapter, the response
|
|
122
|
+
* remains in IR format, allowing applications to work directly with
|
|
123
|
+
* the universal format.
|
|
124
|
+
*
|
|
125
|
+
* @param response - Universal IR chat response
|
|
126
|
+
* @returns Promise resolving to the same IR response
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const adapter = new GenericFrontendAdapter();
|
|
131
|
+
* const irResponse = await adapter.fromIR(irResponse);
|
|
132
|
+
* // Returns the exact same response unchanged
|
|
133
|
+
* console.log(irResponse.message.content);
|
|
134
|
+
* ```
|
|
102
135
|
*/
|
|
103
136
|
fromIR(response) {
|
|
104
137
|
return Promise.resolve(response);
|
|
105
138
|
}
|
|
106
139
|
/**
|
|
107
|
-
* Pass through IR stream chunks
|
|
140
|
+
* Pass through Universal IR stream chunks without conversion.
|
|
141
|
+
*
|
|
142
|
+
* This async generator method accepts an IR stream and yields each chunk
|
|
143
|
+
* directly without any transformation. Unlike other frontend adapters that
|
|
144
|
+
* convert to provider-specific formats (SSE, JSON, etc.), this maintains
|
|
145
|
+
* the raw IR chunk structure for direct consumption.
|
|
146
|
+
*
|
|
147
|
+
* @param stream - Universal IR chat stream
|
|
148
|
+
* @param _options - Optional stream conversion options (currently unused)
|
|
149
|
+
* @yields IR stream chunks unchanged
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const adapter = new GenericFrontendAdapter();
|
|
154
|
+
* for await (const chunk of adapter.fromIRStream(irStream)) {
|
|
155
|
+
* if (chunk.type === 'content') {
|
|
156
|
+
* console.log(chunk.delta); // Access IR structure directly
|
|
157
|
+
* }
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
108
160
|
*/
|
|
109
161
|
async *fromIRStream(stream, _options) {
|
|
110
162
|
for await (const chunk of stream) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAiDH,+EAA+E;AAC/E,2BAA2B;AAC3B,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,sBAAsB;IAKxB,QAAQ,CAAkB;IAClB,MAAM,CAAwB;IAE/C,YAAY,SAAgC,EAAE;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,kBAAkB;YACvC,OAAO,EAAE,OAAO;YAChB,QAAQ,EAAE,SAAS;YACnB,YAAY,EAAE;gBACZ,SAAS,EAAE,IAAI;gBACf,UAAU,EAAE,IAAI;gBAChB,KAAK,EAAE,IAAI;gBACX,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,qBAAqB,EAAE,aAAa;gBACpC,8BAA8B,EAAE,IAAI;gBACpC,mBAAmB,EAAE,IAAI;gBACzB,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,IAAI;gBAClB,YAAY,EAAE,IAAI;gBAClB,wBAAwB,EAAE,IAAI;gBAC9B,uBAAuB,EAAE,IAAI;aAC9B;SACF,CAAC;IACJ,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../src/adapters/generic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAiDH,+EAA+E;AA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ED,+EAA+E;AAC/E,iBAAiB;AACjB,+EAA+E;AAE/E,eAAe,sBAAsB,CAAC"}
|
|
@@ -18,6 +18,27 @@ export class MistralFrontendAdapter {
|
|
|
18
18
|
supportsMultipleSystemMessages: false,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Convert Mistral API request to Universal IR format.
|
|
23
|
+
*
|
|
24
|
+
* This method transforms a Mistral-formatted request into the standardized
|
|
25
|
+
* Intermediate Representation (IR) format. Since Mistral's format is similar
|
|
26
|
+
* to OpenAI and close to IR, this is largely a pass-through adapter with
|
|
27
|
+
* field name mapping (e.g., random_seed → seed).
|
|
28
|
+
*
|
|
29
|
+
* @param request - Mistral API request
|
|
30
|
+
* @returns Promise resolving to IR chat request
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const adapter = new MistralFrontendAdapter();
|
|
35
|
+
* const irRequest = await adapter.toIR({
|
|
36
|
+
* model: 'mistral-small',
|
|
37
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
38
|
+
* temperature: 0.7
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
21
42
|
toIR(request) {
|
|
22
43
|
const messages = request.messages.map((msg) => ({
|
|
23
44
|
role: msg.role,
|
|
@@ -40,6 +61,24 @@ export class MistralFrontendAdapter {
|
|
|
40
61
|
stream: request.stream,
|
|
41
62
|
});
|
|
42
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Convert Universal IR response back to Mistral API format.
|
|
66
|
+
*
|
|
67
|
+
* This method transforms the standardized IR response into the format
|
|
68
|
+
* expected by Mistral's API. It handles message conversion, finish reason
|
|
69
|
+
* mapping (stop, length, model_length), and usage statistics formatting
|
|
70
|
+
* specific to Mistral's response structure.
|
|
71
|
+
*
|
|
72
|
+
* @param response - Universal IR chat response
|
|
73
|
+
* @returns Promise resolving to Mistral API response
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const adapter = new MistralFrontendAdapter();
|
|
78
|
+
* const mistralResponse = await adapter.fromIR(irResponse);
|
|
79
|
+
* console.log(mistralResponse.choices[0].message.content);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
43
82
|
fromIR(response) {
|
|
44
83
|
return Promise.resolve({
|
|
45
84
|
id: `mistral-${Date.now()}`,
|
|
@@ -69,6 +108,26 @@ export class MistralFrontendAdapter {
|
|
|
69
108
|
: { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 },
|
|
70
109
|
});
|
|
71
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Convert Universal IR stream to Mistral Server-Sent Events format.
|
|
113
|
+
*
|
|
114
|
+
* This async generator method transforms a stream of IR chunks into
|
|
115
|
+
* Mistral-formatted SSE responses. It yields Server-Sent Event strings
|
|
116
|
+
* with the "data: " prefix containing JSON with delta content, and
|
|
117
|
+
* emits "data: [DONE]" when the stream completes.
|
|
118
|
+
*
|
|
119
|
+
* @param stream - Universal IR chat stream
|
|
120
|
+
* @param _options - Optional stream conversion options (currently unused)
|
|
121
|
+
* @yields Server-Sent Event formatted strings
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* const adapter = new MistralFrontendAdapter();
|
|
126
|
+
* for await (const sseData of adapter.fromIRStream(irStream)) {
|
|
127
|
+
* console.log(sseData); // "data: {...}\n\n" or "data: [DONE]\n\n"
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
72
131
|
async *fromIRStream(stream, _options) {
|
|
73
132
|
for await (const chunk of stream) {
|
|
74
133
|
if (chunk.type === 'content') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mistral.js","sourceRoot":"","sources":["../../../src/adapters/mistral.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"mistral.js","sourceRoot":"","sources":["../../../src/adapters/mistral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