@absolutejs/ai 0.4.1 → 0.5.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 +11 -0
- package/changelog.json +38 -0
- package/dist/ai/index.js +59 -34
- package/dist/ai/index.js.map +14 -13
- package/dist/ai/providers/anthropic.js +5 -2
- package/dist/ai/providers/anthropic.js.map +3 -3
- package/dist/ai/providers/gemini.js +5 -2
- package/dist/ai/providers/gemini.js.map +3 -3
- package/dist/ai/providers/ollama.js +3 -1
- package/dist/ai/providers/ollama.js.map +3 -3
- package/dist/ai/providers/openai.js +19 -5
- package/dist/ai/providers/openai.js.map +4 -4
- package/dist/ai/providers/openaiCompatible.js +19 -5
- package/dist/ai/providers/openaiCompatible.js.map +4 -4
- package/dist/ai/providers/openaiResponses.js +5 -2
- package/dist/ai/providers/openaiResponses.js.map +3 -3
- package/dist/ai/providers/openrouter.js +23 -6
- package/dist/ai/providers/openrouter.js.map +5 -5
- package/dist/ai/tools/index.js +6 -1
- package/dist/ai/tools/index.js.map +3 -3
- package/dist/ai/tools/untrusted.js +6 -1
- package/dist/ai/tools/untrusted.js.map +3 -3
- package/dist/angular/ai/index.js +7 -9
- package/dist/angular/ai/index.js.map +2 -2
- package/dist/src/ai/index.d.ts +1 -0
- package/dist/src/ai/toolOutput.d.ts +8 -0
- package/dist/types/ai.d.ts +11 -1
- package/package.json +1 -1
|
@@ -870,7 +870,10 @@ var convertToolBlock = (block) => {
|
|
|
870
870
|
if (block.type === "tool_result") {
|
|
871
871
|
return {
|
|
872
872
|
call_id: block.tool_use_id,
|
|
873
|
-
output:
|
|
873
|
+
output: block.images?.length ? [
|
|
874
|
+
{ text: block.content, type: "input_text" },
|
|
875
|
+
...block.images.map((source) => mapBlockToResponsesFormat({ source, type: "image" }))
|
|
876
|
+
] : block.content,
|
|
874
877
|
type: "function_call_output"
|
|
875
878
|
};
|
|
876
879
|
}
|
|
@@ -1400,6 +1403,7 @@ var NOT_FOUND = -1;
|
|
|
1400
1403
|
var isRecord2 = (value) => typeof value === "object" && value !== null;
|
|
1401
1404
|
var isRecordArray2 = (value) => Array.isArray(value) && value.length > 0 && isRecord2(value[0]);
|
|
1402
1405
|
var hasArrayContent = (msg) => typeof msg.content !== "string" && Array.isArray(msg.content);
|
|
1406
|
+
var imageUrl = (source) => source.type === "url" ? source.url : `data:${source.media_type};base64,${source.data}`;
|
|
1403
1407
|
var buildToolMessages = (blocks) => {
|
|
1404
1408
|
const toolUseBlocks = blocks.filter((block) => block.type === "tool_use");
|
|
1405
1409
|
const toolResultBlocks = blocks.filter((block) => block.type === "tool_result");
|
|
@@ -1425,6 +1429,18 @@ var buildToolMessages = (blocks) => {
|
|
|
1425
1429
|
tool_call_id: result.tool_use_id
|
|
1426
1430
|
});
|
|
1427
1431
|
}
|
|
1432
|
+
const images = toolResultBlocks.flatMap((result) => result.images ?? []);
|
|
1433
|
+
if (images.length > 0)
|
|
1434
|
+
messages.push({
|
|
1435
|
+
content: [
|
|
1436
|
+
{ text: "Images returned by the tool calls above:", type: "text" },
|
|
1437
|
+
...images.map((source) => ({
|
|
1438
|
+
image_url: { url: imageUrl(source) },
|
|
1439
|
+
type: "image_url"
|
|
1440
|
+
}))
|
|
1441
|
+
],
|
|
1442
|
+
role: "user"
|
|
1443
|
+
});
|
|
1428
1444
|
return messages;
|
|
1429
1445
|
};
|
|
1430
1446
|
var mapToolDefinitions = (tools) => tools.map((tool) => ({
|
|
@@ -1438,9 +1454,7 @@ var mapToolDefinitions = (tools) => tools.map((tool) => ({
|
|
|
1438
1454
|
var mapContentBlockToOpenAI = (block) => {
|
|
1439
1455
|
if (block.type === "image") {
|
|
1440
1456
|
return {
|
|
1441
|
-
image_url: {
|
|
1442
|
-
url: block.source.type === "url" ? block.source.url : `data:${block.source.media_type};base64,${block.source.data}`
|
|
1443
|
-
},
|
|
1457
|
+
image_url: { url: imageUrl(block.source) },
|
|
1444
1458
|
type: "image_url"
|
|
1445
1459
|
};
|
|
1446
1460
|
}
|
|
@@ -1994,5 +2008,5 @@ export {
|
|
|
1994
2008
|
xai
|
|
1995
2009
|
};
|
|
1996
2010
|
|
|
1997
|
-
//# debugId=
|
|
2011
|
+
//# debugId=6049DF044C994A4864756E2164756E21
|
|
1998
2012
|
//# sourceMappingURL=openaiCompatible.js.map
|