agent-pulse 1.4.0 → 1.4.1
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/dist/providers/grok.js +27 -0
- package/package.json +1 -1
package/dist/providers/grok.js
CHANGED
|
@@ -18,6 +18,33 @@ class GrokProvider {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
async generate(system, prompt, files, tools, config, output_schema, onToken) {
|
|
21
|
+
// Image generation mode — route to images API instead of chat completions
|
|
22
|
+
if (this.model.includes('imagine')) {
|
|
23
|
+
const promptText = Array.isArray(prompt)
|
|
24
|
+
? prompt.filter(m => m.role === 'user').map(m => m.content).join('\n')
|
|
25
|
+
: String(prompt);
|
|
26
|
+
const response = await this.client.images.generate({
|
|
27
|
+
model: this.model,
|
|
28
|
+
prompt: promptText,
|
|
29
|
+
n: config?.n || 1,
|
|
30
|
+
response_format: config?.response_format || 'b64_json',
|
|
31
|
+
...(config?.aspect_ratio && { aspect_ratio: config.aspect_ratio }),
|
|
32
|
+
});
|
|
33
|
+
const images = response.data;
|
|
34
|
+
const markdownParts = images.map((img, i) => {
|
|
35
|
+
if (img.b64_json) {
|
|
36
|
+
return ``;
|
|
37
|
+
}
|
|
38
|
+
return ``;
|
|
39
|
+
});
|
|
40
|
+
const content = markdownParts.join('\n\n');
|
|
41
|
+
onToken(content);
|
|
42
|
+
return {
|
|
43
|
+
content,
|
|
44
|
+
usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },
|
|
45
|
+
meta: { model: this.model, latency_ms: 0 }
|
|
46
|
+
};
|
|
47
|
+
}
|
|
21
48
|
// 1. Prepare messages
|
|
22
49
|
const messages = [];
|
|
23
50
|
if (system) {
|