decord/source/975_contentUnionToMessages.js

66 lines
1.9 KiB
JavaScript
Raw Normal View History

2026-07-29 08:29:29 +00:00
// Module ID: 975
// Function ID: 976
2026-07-20 16:05:17 +00:00
// Name: contentUnionToMessages
2026-07-29 08:29:29 +00:00
// Dependencies: [974]
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
// Module 975 (contentUnionToMessages)
2026-07-23 10:11:24 +00:00
const require = arg1;
const dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
Object.defineProperty(arg5, Symbol.toStringTag, { value: "Module" });
function contentUnionToMessages(contents, user) {
2026-07-29 08:29:29 +00:00
let str = user;
if (user === undefined) {
2026-07-20 16:05:17 +00:00
str = "user";
}
2026-08-04 21:03:28 +00:00
if (typeof contents === "string") {
2026-07-29 08:29:29 +00:00
let obj = { role: null, content: null };
obj[0] = str;
obj[1] = contents;
2026-07-20 16:05:17 +00:00
const items = [obj];
let flatMapResult = items;
} else {
const _Array = Array;
if (Array.isArray(contents)) {
2026-07-23 10:11:24 +00:00
flatMapResult = contents.flatMap((arg0) => outer1_2(arg0, str));
2026-07-20 16:05:17 +00:00
} else {
2026-08-04 21:03:28 +00:00
if (typeof contents === "object") {
2026-07-20 16:05:17 +00:00
if (contents) {
if (!("role" in contents)) {
if ("parts" in contents) {
2026-07-29 08:29:29 +00:00
obj = {};
const merged = Object.assign(contents);
obj.role = str;
const items1 = [obj];
2026-07-20 16:05:17 +00:00
let items2 = items1;
} else {
2026-07-29 08:29:29 +00:00
obj = { role: null, content: null };
obj[0] = str;
obj[1] = contents;
2026-07-20 16:05:17 +00:00
items2 = [obj];
}
}
const items3 = [contents];
items2 = items3;
}
}
flatMapResult = [];
}
}
return flatMapResult;
}
arg5.contentUnionToMessages = contentUnionToMessages;
2026-07-29 08:29:29 +00:00
arg5.isStreamingMethod = function isStreamingMethod(arr) {
return arr.includes("Stream");
2026-07-20 16:05:17 +00:00
};
arg5.shouldInstrument = function shouldInstrument(str) {
2026-07-29 08:29:29 +00:00
const GOOGLE_GENAI_INSTRUMENTED_METHODS = require(974).GOOGLE_GENAI_INSTRUMENTED_METHODS;
2026-07-20 16:05:17 +00:00
if (GOOGLE_GENAI_INSTRUMENTED_METHODS.includes(str)) {
return true;
} else {
const parts = str.split(".");
2026-07-29 08:29:29 +00:00
const GOOGLE_GENAI_INSTRUMENTED_METHODS2 = tmp(974).GOOGLE_GENAI_INSTRUMENTED_METHODS;
2026-07-20 16:05:17 +00:00
return GOOGLE_GENAI_INSTRUMENTED_METHODS2.includes(parts.pop());
}
2026-07-29 08:29:29 +00:00
tmp = require;
2026-07-20 16:05:17 +00:00
};