import { d as getRequestId, r as requireAdmin, p as parseJsonBody, j as jsonBodyError, e as errorResponse, k as jsonResponse } from './helpers-kzwksNq1.js';
import { t as testEmbeddingSettings } from './akm-BRiRim0P.js';
import './src-CidJbygh.js';
import './chunk-CLZ62Ad-.js';
import 'node:module';
import './provider-constants-DPrj3yBX.js';
import './dist-DOFcG0Zp.js';
import 'node:fs';
import 'node:path';
import 'buffer';
import 'fs';
import 'path';
import 'node:child_process';
import 'node:url';
import 'node:crypto';
import 'events';
import 'node:events';
import 'node:stream';
import 'node:string_decoder';
import 'assert';
import 'zlib';
import 'node:assert';
import 'node:fs/promises';
import 'node:os';
import './endpoints-UdQGgKsR.js';
import './state-fxN45gBp.js';

//#region src/routes/admin/akm/embedding/test/+server.ts
var POST = async (event) => {
	const requestId = getRequestId(event);
	const authError = requireAdmin(event, requestId);
	if (authError) return authError;
	const parsed = await parseJsonBody(event.request);
	if ("error" in parsed) return jsonBodyError(parsed, requestId);
	const body = parsed.data;
	const endpoint = typeof body.endpoint === "string" ? body.endpoint : "";
	const model = typeof body.model === "string" ? body.model : "";
	const provider = typeof body.provider === "string" ? body.provider : "";
	const apiKey = typeof body.apiKey === "string" ? body.apiKey : "";
	const dimension = typeof body.dimension === "number" ? body.dimension : void 0;
	if (!endpoint.trim() || !model.trim()) return errorResponse(400, "bad_request", "Endpoint and model are required.", {}, requestId);
	const result = await testEmbeddingSettings({
		endpoint,
		model,
		provider,
		apiKey,
		dimension
	});
	if (!result.ok) return errorResponse(502, "embedding_test_failed", result.message, {}, requestId);
	return jsonResponse(200, result, requestId);
};

export { POST };
//# sourceMappingURL=_server.ts-DvVFuoZA.js.map
