@just-every/ensemble 0.2.170 → 0.2.172
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 +78 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,6 +183,84 @@ Key configuration options:
|
|
|
183
183
|
- `maxToolCallRoundsPerTurn` - Limits sequential rounds where each round can have multiple parallel tool calls
|
|
184
184
|
- `modelSettings` - Provider-specific parameters like temperature, max_tokens, etc.
|
|
185
185
|
|
|
186
|
+
### Multimodal Input (Images)
|
|
187
|
+
|
|
188
|
+
For multimodal models, pass content as an array of typed parts. In addition to `input_text` and `input_image`, Ensemble now accepts a simpler `image` part that can take base64 data or a URL.
|
|
189
|
+
|
|
190
|
+
Supported image fields:
|
|
191
|
+
- `type: 'image'`
|
|
192
|
+
- `data`: base64 string **or** full `data:<mime>;base64,...` URL
|
|
193
|
+
- `url`: http(s) URL
|
|
194
|
+
- `file_id`: provider file reference (when supported)
|
|
195
|
+
- `mime_type`: image mime type (recommended when passing raw base64)
|
|
196
|
+
- `detail`: `high` | `low` | `auto` (for providers that support detail hints)
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import { ensembleRequest } from '@just-every/ensemble';
|
|
200
|
+
|
|
201
|
+
const messages = [
|
|
202
|
+
{
|
|
203
|
+
type: 'message',
|
|
204
|
+
role: 'user',
|
|
205
|
+
content: [
|
|
206
|
+
{ type: 'input_text', text: 'Describe this image.' },
|
|
207
|
+
{ type: 'image', data: myPngBase64, mime_type: 'image/png' }
|
|
208
|
+
// or: { type: 'image', url: 'https://example.com/cat.png' }
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
for await (const event of ensembleRequest(messages, { model: 'gemini-3-flash-preview' })) {
|
|
214
|
+
if (event.type === 'message_complete' && 'content' in event) {
|
|
215
|
+
console.log(event.content);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Structured JSON Output
|
|
221
|
+
|
|
222
|
+
Use `modelSettings.json_schema` to request a JSON-only response. The schema is validated by providers that support it.
|
|
223
|
+
|
|
224
|
+
The example below combines **image input** with **JSON output**:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { ensembleRequest, ensembleResult } from '@just-every/ensemble';
|
|
228
|
+
|
|
229
|
+
const agent = {
|
|
230
|
+
model: 'gemini-3-flash-preview',
|
|
231
|
+
modelSettings: {
|
|
232
|
+
temperature: 0.2,
|
|
233
|
+
json_schema: {
|
|
234
|
+
name: 'image_analysis',
|
|
235
|
+
type: 'json_schema',
|
|
236
|
+
schema: {
|
|
237
|
+
type: 'object',
|
|
238
|
+
properties: {
|
|
239
|
+
dominant_color: { type: 'string' },
|
|
240
|
+
confidence: { type: 'number' },
|
|
241
|
+
},
|
|
242
|
+
required: ['dominant_color', 'confidence'],
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
const messages = [
|
|
249
|
+
{
|
|
250
|
+
type: 'message',
|
|
251
|
+
role: 'user',
|
|
252
|
+
content: [
|
|
253
|
+
{ type: 'input_text', text: 'Analyze this image and return JSON.' },
|
|
254
|
+
{ type: 'image', data: myPngBase64, mime_type: 'image/png' },
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
];
|
|
258
|
+
|
|
259
|
+
const result = await ensembleResult(ensembleRequest(messages, agent));
|
|
260
|
+
const parsed = JSON.parse(result.message);
|
|
261
|
+
console.log(parsed.dominant_color, parsed.confidence);
|
|
262
|
+
```
|
|
263
|
+
|
|
186
264
|
### Advanced Features
|
|
187
265
|
|
|
188
266
|
- **Parallel Tool Execution** - Tools run concurrently by default within each round
|