@ljoukov/llm 4.0.10 → 4.0.11
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/index.cjs +18 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
FinishReason,
|
|
7
7
|
FunctionCallingConfigMode,
|
|
8
8
|
ThinkingLevel,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
createPartFromBase64,
|
|
10
|
+
createPartFromFunctionResponse,
|
|
11
|
+
createPartFromUri
|
|
12
12
|
} from "@google/genai";
|
|
13
13
|
import { zodToJsonSchema } from "@alcyone-labs/zod-to-json-schema";
|
|
14
14
|
import { z as z3 } from "zod";
|
|
@@ -4643,12 +4643,12 @@ function buildGeminiToolOutputMediaPart(item) {
|
|
|
4643
4643
|
if (!parsed) {
|
|
4644
4644
|
return null;
|
|
4645
4645
|
}
|
|
4646
|
-
return
|
|
4646
|
+
return createPartFromBase64(parsed.dataBase64, parsed.mimeType);
|
|
4647
4647
|
}
|
|
4648
4648
|
if (item.type === "input_file") {
|
|
4649
4649
|
const dataUrl = typeof item.file_url === "string" ? parseDataUrlPayload(item.file_url) : null;
|
|
4650
4650
|
if (dataUrl) {
|
|
4651
|
-
const part =
|
|
4651
|
+
const part = createPartFromBase64(dataUrl.dataBase64, dataUrl.mimeType);
|
|
4652
4652
|
const displayName = item.filename?.trim();
|
|
4653
4653
|
if (displayName && part.inlineData) {
|
|
4654
4654
|
part.inlineData.displayName = displayName;
|
|
@@ -4657,7 +4657,7 @@ function buildGeminiToolOutputMediaPart(item) {
|
|
|
4657
4657
|
}
|
|
4658
4658
|
const inferredMimeType = inferToolOutputMimeTypeFromFilename(item.filename);
|
|
4659
4659
|
if (typeof item.file_data === "string" && item.file_data.trim().length > 0 && inferredMimeType) {
|
|
4660
|
-
const part =
|
|
4660
|
+
const part = createPartFromBase64(item.file_data, inferredMimeType);
|
|
4661
4661
|
const displayName = item.filename?.trim();
|
|
4662
4662
|
if (displayName && part.inlineData) {
|
|
4663
4663
|
part.inlineData.displayName = displayName;
|
|
@@ -4665,7 +4665,7 @@ function buildGeminiToolOutputMediaPart(item) {
|
|
|
4665
4665
|
return part;
|
|
4666
4666
|
}
|
|
4667
4667
|
if (typeof item.file_url === "string" && item.file_url.trim().length > 0 && inferredMimeType) {
|
|
4668
|
-
const part =
|
|
4668
|
+
const part = createPartFromUri(item.file_url, inferredMimeType);
|
|
4669
4669
|
const displayName = item.filename?.trim();
|
|
4670
4670
|
if (displayName && part.fileData) {
|
|
4671
4671
|
part.fileData.displayName = displayName;
|
|
@@ -4699,41 +4699,35 @@ function toGeminiToolOutputPlaceholder(item) {
|
|
|
4699
4699
|
media: dataUrl || typeof item.file_data === "string" && item.file_data.trim().length > 0 ? "attached-inline-data" : typeof item.file_url === "string" && item.file_url.trim().length > 0 ? "attached-file-data" : void 0
|
|
4700
4700
|
};
|
|
4701
4701
|
}
|
|
4702
|
-
function
|
|
4702
|
+
function buildGeminiFunctionResponseParts(options) {
|
|
4703
4703
|
const outputItems = toGeminiToolOutputItems(options.outputPayload);
|
|
4704
4704
|
if (!outputItems) {
|
|
4705
4705
|
const responsePayload2 = isPlainRecord(options.outputPayload) ? sanitiseLogValue(options.outputPayload) : { output: sanitiseLogValue(options.outputPayload) };
|
|
4706
4706
|
if (options.callId) {
|
|
4707
|
-
return createPartFromFunctionResponse(options.callId, options.toolName, responsePayload2);
|
|
4707
|
+
return [createPartFromFunctionResponse(options.callId, options.toolName, responsePayload2)];
|
|
4708
4708
|
}
|
|
4709
|
-
return
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4709
|
+
return [
|
|
4710
|
+
{
|
|
4711
|
+
functionResponse: {
|
|
4712
|
+
name: options.toolName,
|
|
4713
|
+
response: responsePayload2
|
|
4714
|
+
}
|
|
4713
4715
|
}
|
|
4714
|
-
|
|
4716
|
+
];
|
|
4715
4717
|
}
|
|
4716
4718
|
const responseOutput = outputItems.map((item) => toGeminiToolOutputPlaceholder(item));
|
|
4717
|
-
const
|
|
4719
|
+
const responseParts = outputItems.flatMap((item) => {
|
|
4718
4720
|
const mediaPart = buildGeminiToolOutputMediaPart(item);
|
|
4719
4721
|
return mediaPart ? [mediaPart] : [];
|
|
4720
4722
|
});
|
|
4721
4723
|
const responsePayload = { output: responseOutput };
|
|
4722
|
-
|
|
4723
|
-
return createPartFromFunctionResponse(
|
|
4724
|
-
options.callId,
|
|
4725
|
-
options.toolName,
|
|
4726
|
-
responsePayload,
|
|
4727
|
-
responseMediaParts
|
|
4728
|
-
);
|
|
4729
|
-
}
|
|
4730
|
-
return {
|
|
4724
|
+
const functionResponsePart = options.callId ? createPartFromFunctionResponse(options.callId, options.toolName, responsePayload) : {
|
|
4731
4725
|
functionResponse: {
|
|
4732
4726
|
name: options.toolName,
|
|
4733
|
-
response:
|
|
4734
|
-
...responseMediaParts.length > 0 ? { parts: responseMediaParts } : {}
|
|
4727
|
+
response: responsePayload
|
|
4735
4728
|
}
|
|
4736
4729
|
};
|
|
4730
|
+
return [functionResponsePart, ...responseParts];
|
|
4737
4731
|
}
|
|
4738
4732
|
function parseOpenAiToolArguments(raw) {
|
|
4739
4733
|
const trimmed = raw.trim();
|
|
@@ -7561,7 +7555,7 @@ async function runToolLoop(request) {
|
|
|
7561
7555
|
durationMs: result.durationMs
|
|
7562
7556
|
});
|
|
7563
7557
|
responseParts.push(
|
|
7564
|
-
|
|
7558
|
+
...buildGeminiFunctionResponseParts({
|
|
7565
7559
|
toolName: entry.toolName,
|
|
7566
7560
|
callId: entry.call.id,
|
|
7567
7561
|
outputPayload
|