Files
2026-07-28 01:06:53 +03:00

335 lines
17 KiB
JavaScript

/* Metro module 971; source: unknown; dependencies: [77, 966, 972] */
import * as Module00077Module from './module-00077.js'; /* Metro dependency 77 */
import * as Module00966Module from './module-00966.js'; /* Metro dependency 966 */
function _fun10212(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#10212, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:6, offset: 0x00d817a4, size: 281 bytes, params: 8, frame: 21
const env0_0 = require;
const getOperationName2 = getOperationName;
const setTokenUsageAttributes_102142 = setTokenUsageAttributes_10214;
const setCommonResponseAttributes2 = setCommonResponseAttributes;
const Object = global.Object;
const defineProperty = Object.defineProperty;
const Symbol = global.Symbol;
Reflect.apply(defineProperty, Object, [exports, Symbol.toStringTag, {value: 'Module'}]);
exports.addChatCompletionAttributes = addChatCompletionAttributes;
exports.addConversationAttributes = addConversationAttributes;
exports.addEmbeddingsAttributes = addEmbeddingsAttributes;
exports.addResponsesApiAttributes = addResponsesApiAttributes;
exports.buildMethodPath = function(a0, a1) {
var value = a1;
return a0 ? '' + a0 + '.' + value : value;
};
exports.extractRequestParameters = extractRequestParameters;
exports.getOperationName = getOperationName2;
exports.getSpanOperation = getSpanOperation_10227;
exports.isChatCompletionChunk = function(a0) {
return a0 !== null && typeof a0 === 'object' && 'object' in a0 && a0.object === 'chat.completion.chunk';
};
exports.isChatCompletionResponse = function(a0) {
return a0 !== null && typeof a0 === 'object' && 'object' in a0 && a0.object === 'chat.completion';
};
exports.isConversationResponse = function(a0) {
return a0 !== null && typeof a0 === 'object' && 'object' in a0 && a0.object === 'conversation';
};
exports.isEmbeddingsResponse = function(a0) {
var r0;
var value;
if (a0 !== null) {
if (typeof a0 !== 'object') {
return false;
}
if ('object' in a0) {
value = a0.object === 'list';
r0 = value && typeof a0.model === 'string';
if (r0) {
value = a0.model.toLowerCase();
value = value.includes('embedding');
r0 = value;
}
return r0;
}
}
return false;
};
exports.isResponsesApiResponse = function(a0) {
return a0 !== null && typeof a0 === 'object' && 'object' in a0 && a0.object === 'response';
};
exports.isResponsesApiStreamEvent = function(a0) {
var r0;
r0 = a0 !== null && typeof a0 === 'object' && 'type' in a0;
r0 = r0 && typeof a0.type === 'string' && a0.type.startsWith('response.');
return r0;
};
exports.setCommonResponseAttributes = setCommonResponseAttributes2;
exports.setTokenUsageAttributes = setTokenUsageAttributes_102142;
exports.shouldInstrument = function(a0) {
var INSTRUMENTED_METHODS = require(dependencyMap[2]).INSTRUMENTED_METHODS;
return INSTRUMENTED_METHODS.includes(a0);
};
function getOperationName(a0) { // fn#10213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:44, offset: 0x00d818bd, size: 270 bytes, params: 2, frame: 12
var r0;
var value;
const OPENAI_OPERATIONS = (Module00966Module).OPENAI_OPERATIONS;
if (a0.includes('chat.completions')) {
r0 = OPENAI_OPERATIONS.CHAT;
} else if (a0.includes('responses')) {
r0 = OPENAI_OPERATIONS.RESPONSES;
} else if (a0.includes('embeddings')) {
r0 = OPENAI_OPERATIONS.EMBEDDINGS;
} else if (a0.includes('conversations')) {
r0 = OPENAI_OPERATIONS.CONVERSATIONS;
} else {
value = a0.split('.');
value = value.pop();
r0 = value || 'unknown';
}
return r0;
}
function setTokenUsageAttributes_10214(a0, a1, a2, a3) { // fn#10214, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:362, offset: 0x00d819cb, size: 231 bytes, params: 5, frame: 22
var setAttributes;
var binding;
if (a1 !== undefined) {
setAttributes = a0.setAttributes;
binding = Module00077Module;
Reflect.apply(setAttributes, a0, [binding(binding({},
(require(966) /* metro dependency 966 */).OPENAI_USAGE_PROMPT_TOKENS_ATTRIBUTE, a1),
(require(966) /* metro dependency 966 */).GEN_AI_USAGE_INPUT_TOKENS_ATTRIBUTE, a1)]);
}
if (a2 !== undefined) {
setAttributes = a0.setAttributes;
binding = Module00077Module;
Reflect.apply(setAttributes, a0, [binding(binding({},
(require(966) /* metro dependency 966 */).OPENAI_USAGE_COMPLETION_TOKENS_ATTRIBUTE, a2),
(require(966) /* metro dependency 966 */).GEN_AI_USAGE_OUTPUT_TOKENS_ATTRIBUTE, a2)]);
}
if (a3 !== undefined) {
a0.setAttributes(Module00077Module({}, (require(966) /* metro dependency 966 */).GEN_AI_USAGE_TOTAL_TOKENS_ATTRIBUTE, a3));
}
}
function setCommonResponseAttributes(a0, a1, a2, a3) { // fn#10215, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:752, offset: 0x00d81ab2, size: 239 bytes, params: 5, frame: 22
let setAttributes = a0.setAttributes;
let binding = Module00077Module;
const OPENAI_RESPONSE_ID_ATTRIBUTE = (Module00966Module).OPENAI_RESPONSE_ID_ATTRIBUTE;
const value2 = binding({}, OPENAI_RESPONSE_ID_ATTRIBUTE, a1);
const GEN_AI_RESPONSE_ID_ATTRIBUTE = (Module00966Module).GEN_AI_RESPONSE_ID_ATTRIBUTE;
Reflect.apply(setAttributes, a0, [binding(value2, GEN_AI_RESPONSE_ID_ATTRIBUTE, a1)]);
setAttributes = a0.setAttributes;
binding = Module00077Module;
const OPENAI_RESPONSE_MODEL_ATTRIBUTE = (Module00966Module).OPENAI_RESPONSE_MODEL_ATTRIBUTE;
const value3 = binding({}, OPENAI_RESPONSE_MODEL_ATTRIBUTE, a2);
const GEN_AI_RESPONSE_MODEL_ATTRIBUTE = (Module00966Module).GEN_AI_RESPONSE_MODEL_ATTRIBUTE;
Reflect.apply(setAttributes, a0, [binding(value3, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, a2)]);
setAttributes = a0.setAttributes;
binding = Module00077Module;
const OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE = (Module00966Module).OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE;
const Date = global.Date;
const value = 1000 * a3;
let date = new Date();
date = date.toISOString();
Reflect.apply(setAttributes, a0, [binding({}, OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE, date)]);
}
function addChatCompletionAttributes(a0, a1, a2) { // fn#10216, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:1200, offset: 0x00d81ba1, size: 378 bytes, params: 4, frame: 24
var setTokenUsageAttributes_10214Binding;
var prompt_tokens;
var completion_tokens;
var value3;
var value7;
setCommonResponseAttributes(a0, a1.id, a1.model, a1.created);
let usage = a1.usage;
if (usage) {
setTokenUsageAttributes_10214Binding = setTokenUsageAttributes_10214;
usage = a1.usage;
prompt_tokens = usage.prompt_tokens;
usage = a1.usage;
completion_tokens = usage.completion_tokens;
usage = a1.usage;
setTokenUsageAttributes_10214Binding(a0, prompt_tokens, completion_tokens, usage.total_tokens);
}
const Array = global.Array;
if (Array.isArray(a1.choices)) {
value3 = a1.choices.map(function(a0) {
return a0.finish_reason;
}).filter(_fun10218);
if (value3.length > 0) {
a0.setAttributes(Module00077Module({},
(require(966) /* metro dependency 966 */).GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,
global.JSON.stringify(value3)));
}
if (a2) {
value7 = a1.choices.map(_fun10219).filter(_fun10220).flat();
if (value7.length > 0) {
a0.setAttributes(Module00077Module({},
(require(966) /* metro dependency 966 */).GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,
global.JSON.stringify(value7)));
}
}
}
}
function addConversationAttributes(a0, {id, created_at}) { // fn#10221, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:1922, offset: 0x00d81d71, size: 216 bytes, params: 3, frame: 22
var OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE;
var Date;
var date;
let setAttributes = a0.setAttributes;
var value;
let binding = Module00077Module;
const OPENAI_RESPONSE_ID_ATTRIBUTE = (require(966) /* metro dependency 966 */).OPENAI_RESPONSE_ID_ATTRIBUTE;
const value2 = binding({}, OPENAI_RESPONSE_ID_ATTRIBUTE, id);
const GEN_AI_RESPONSE_ID_ATTRIBUTE = (require(966) /* metro dependency 966 */).GEN_AI_RESPONSE_ID_ATTRIBUTE;
const value3 = binding(value2, GEN_AI_RESPONSE_ID_ATTRIBUTE, id);
const GEN_AI_CONVERSATION_ID_ATTRIBUTE = (require(966) /* metro dependency 966 */).GEN_AI_CONVERSATION_ID_ATTRIBUTE;
Reflect.apply(setAttributes, a0, [binding(value3, GEN_AI_CONVERSATION_ID_ATTRIBUTE, id)]);
if (created_at) {
setAttributes = a0.setAttributes;
binding = Module00077Module;
OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE = (require(966) /* metro dependency 966 */).OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE;
Date = global.Date;
value = 1000 * created_at;
date = new Date();
date = date.toISOString();
Reflect.apply(setAttributes, a0, [binding({}, OPENAI_RESPONSE_TIMESTAMP_ATTRIBUTE, date)]);
}
}
function addEmbeddingsAttributes(a0, a1) { // fn#10222, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:2265, offset: 0x00d81e49, size: 145 bytes, params: 3, frame: 23
var setTokenUsageAttributes_10214Binding;
var prompt_tokens;
const setAttributes = a0.setAttributes;
const OPENAI_RESPONSE_MODEL_ATTRIBUTE = (Module00966Module).OPENAI_RESPONSE_MODEL_ATTRIBUTE;
const value2 = Module00077Module({}, OPENAI_RESPONSE_MODEL_ATTRIBUTE, a1.model);
const GEN_AI_RESPONSE_MODEL_ATTRIBUTE = (Module00966Module).GEN_AI_RESPONSE_MODEL_ATTRIBUTE;
Reflect.apply(setAttributes, a0, [Module00077Module(value2, GEN_AI_RESPONSE_MODEL_ATTRIBUTE, a1.model)]);
let usage = a1.usage;
if (usage) {
setTokenUsageAttributes_10214Binding = setTokenUsageAttributes_10214;
usage = a1.usage;
prompt_tokens = usage.prompt_tokens;
usage = a1.usage;
setTokenUsageAttributes_10214Binding(a0, prompt_tokens, undefined, usage.total_tokens);
}
}
function addResponsesApiAttributes(a0, a1, a2) { // fn#10223, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:2540, offset: 0x00d81eda, size: 343 bytes, params: 4, frame: 22
var setAttributes;
var binding;
var GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE;
var JSON;
var setTokenUsageAttributes_10214Binding;
var input_tokens;
var output_tokens;
var Array;
var value3;
setCommonResponseAttributes(a0, a1.id, a1.model, a1.created_at);
if (a1.status) {
setAttributes = a0.setAttributes;
binding = Module00077Module;
GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE = (require(966) /* metro dependency 966 */).GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE;
JSON = global.JSON;
Reflect.apply(setAttributes, a0, [binding({}, GEN_AI_RESPONSE_FINISH_REASONS_ATTRIBUTE,
JSON.stringify([a1.status]))]);
}
let usage = a1.usage;
if (usage) {
setTokenUsageAttributes_10214Binding = setTokenUsageAttributes_10214;
usage = a1.usage;
input_tokens = usage.input_tokens;
usage = a1.usage;
output_tokens = usage.output_tokens;
usage = a1.usage;
setTokenUsageAttributes_10214Binding(a0, input_tokens, output_tokens, usage.total_tokens);
}
if (a2) {
Array = global.Array;
if (Array.isArray(a1.output)) {
if (a1.output.length > 0) {
value3 = a1.output.filter(function(a0) {
return typeof a0 === 'object' && a0 !== null && a0.type === 'function_call';
});
if (value3.length > 0) {
a0.setAttributes(Module00077Module({},
(require(966) /* metro dependency 966 */).GEN_AI_RESPONSE_TOOL_CALLS_ATTRIBUTE,
global.JSON.stringify(value3)));
}
}
}
}
}
function extractRequestParameters(a0) { // fn#10226, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:3208, offset: 0x00d8205c, size: 487 bytes, params: 2, frame: 19
var previous_response_id;
const value2 = undefined;
const GEN_AI_REQUEST_MODEL_ATTRIBUTE = (require(966) /* metro dependency 966 */).GEN_AI_REQUEST_MODEL_ATTRIBUTE;
let r2 = a0.model ?? 'unknown';
const value4 = Module00077Module({}, GEN_AI_REQUEST_MODEL_ATTRIBUTE, r2);
if ('temperature' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE] = a0.temperature;
}
if ('top_p' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_TOP_P_ATTRIBUTE] = a0.top_p;
}
if ('frequency_penalty' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_FREQUENCY_PENALTY_ATTRIBUTE] = a0.frequency_penalty;
}
if ('presence_penalty' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_PRESENCE_PENALTY_ATTRIBUTE] = a0.presence_penalty;
}
if ('stream' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_STREAM_ATTRIBUTE] = a0.stream;
}
if ('encoding_format' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_ENCODING_FORMAT_ATTRIBUTE] = a0.encoding_format;
}
if ('dimensions' in a0) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_REQUEST_DIMENSIONS_ATTRIBUTE] = a0.dimensions;
}
if ('conversation' in a0) {
if (typeof a0.conversation === 'string') {
r2 = a0.conversation;
} else {
if ('previous_response_id' in a0) {
previous_response_id = a0.previous_response_id;
previous_response_id = typeof previous_response_id !== 'string' ? value2 : a0.previous_response_id;
} else {
previous_response_id = value2;
}
r2 = previous_response_id;
}
} else {
if ('previous_response_id' in a0) {
previous_response_id = a0.previous_response_id;
previous_response_id = typeof previous_response_id !== 'string' ? value2 : a0.previous_response_id;
} else {
previous_response_id = value2;
}
r2 = previous_response_id;
}
if (r2) {
value4[(require(966) /* metro dependency 966 */).GEN_AI_CONVERSATION_ID_ATTRIBUTE] = r2;
}
return value4;
}
function getSpanOperation_10227(a0) { // fn#10227, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:4249, offset: 0x00d800fd, size: 43 bytes, params: 2, frame: 11
return 'gen_ai.' + getOperationName(a0);
}
}
function _fun10218(a0) { // fn#10218, offset: 0x00d81d26, size: 11 bytes, params: 2, frame: 2
return a0 !== null;
}
function _fun10219({message}) { // fn#10219, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:1659, offset: 0x00d81d31, size: 27 bytes, params: 2, frame: 3
return message?.tool_calls;
}
function _fun10220(a0) { // fn#10220, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1098:1735, offset: 0x00d81d4c, size: 37 bytes, params: 2, frame: 11
const Array = global.Array;
return Array.isArray(a0) && a0.length > 0;
}
global.__d(_fun10212, 971, [77, 966, 972]) /* metro module 971, dependencies: [77, 966, 972] */;