UNPKG

wcz-layout

Version:

24 lines (23 loc) • 1.09 kB
// src/lib/ai/index.ts /** * Text adapter for the Wistron AI gateway; create it per request in a server function * (`getAppToken` caches the token). Chat Completions, not Responses: the gateway load-balances * Azure deployments, and Responses replays encrypted reasoning that other deployments cannot read * (400 invalid_encrypted_content). */ const chatAdapter = async (model) => { const [{ createOpenaiChatCompletions }, { getAppToken }, { serverEnv }] = await Promise.all([ import("@tanstack/ai-openai"), import("./tokens-CkWpu7Qp.mjs").then((n) => n.r), import("./env-BwFl7nWc.mjs").then((n) => n.t) ]); const { AI_BASE_URL, AI_SUBSCRIPTION_KEY } = serverEnv; if (!AI_BASE_URL || !AI_SUBSCRIPTION_KEY) throw new Error("chatAdapter needs AI_BASE_URL and AI_SUBSCRIPTION_KEY in the environment."); return createOpenaiChatCompletions(model, await getAppToken("cognitiveServices"), { baseURL: AI_BASE_URL, defaultHeaders: { "Ocp-Apim-Subscription-Key": AI_SUBSCRIPTION_KEY }, strictFallbackWarning: false }); }; export { chatAdapter }; //# sourceMappingURL=ai.mjs.map