const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
const require_logger_index = require('../../../logger/index.cjs');
const require__utils_asset = require('../../../_virtual/_utils_asset.cjs');
const require_utils_extractJSON = require('../../extractJSON.cjs');
let ai = require("ai");

//#region src/utils/AI/auditTag/index.ts
const CHAT_GPT_PROMPT = require__utils_asset.readAsset("./PROMPT.md");
const aiDefaultOptions = {};
/**
* Audits a tag by constructing a prompt for AI models.
* The prompt includes details about the tag and related dictionaries.
*/
const auditTag = async ({ dictionaries, tag, aiConfig, applicationContext }) => {
	const prompt = CHAT_GPT_PROMPT.replace("{{tag.description}}", tag.description ?? "").replace("{{tag.key}}", tag.key).replace("{{dictionaries}}", JSON.stringify(dictionaries, null, 2)).replace("{{applicationContext}}", applicationContext ?? "");
	const { text: newContent, usage } = await (0, ai.generateText)({
		...aiConfig,
		messages: [{
			role: "system",
			content: prompt
		}]
	});
	require_logger_index.logger.info(`${usage?.totalTokens ?? 0} tokens used in the request`);
	return {
		fileContent: require_utils_extractJSON.extractJson(newContent),
		tokenUsed: usage?.totalTokens ?? 0
	};
};

//#endregion
exports.aiDefaultOptions = aiDefaultOptions;
exports.auditTag = auditTag;
//# sourceMappingURL=index.cjs.map