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

//#region src/utils/AI/autocomplete/index.ts
const CHAT_GPT_PROMPT = require__utils_asset.readAsset("./PROMPT.md");
const aiDefaultOptions = {
	provider: require_utils_AI_aiSdk.AIProvider.OPENAI,
	model: "gpt-4o-mini",
	temperature: .7
};
/**
* Autocompletes a content declaration file by constructing a prompt for AI models.
* The prompt includes details about the project's locales, file paths of content declarations,
* and requests for identifying issues or inconsistencies.
*/
const autocomplete = async ({ text, aiConfig, applicationContext, contextBefore, currentLine, contextAfter }) => {
	const prompt = CHAT_GPT_PROMPT.replace("{{applicationContext}}", applicationContext ?? "").replace("{{contextBefore}}", contextBefore ?? "").replace("{{currentLine}}", currentLine ?? "").replace("{{contextAfter}}", contextAfter ?? "");
	const { text: newContent, usage } = await (0, ai.generateText)({
		...aiConfig,
		messages: [{
			role: "system",
			content: prompt
		}, {
			role: "assistant",
			content: text
		}]
	});
	require_logger_index.logger.info(`${usage?.totalTokens ?? 0} tokens used in the request`);
	return {
		autocompletion: newContent,
		tokenUsed: usage?.totalTokens ?? 0
	};
};

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