UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

85 lines (84 loc) 2.24 kB
var u = Object.defineProperty; var c = (a, t, e) => t in a ? u(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e; var l = (a, t, e) => c(a, typeof t != "symbol" ? t + "" : t, e); class d { constructor(t) { l(this, "apiKey"); this.apiKey = t; } getOptionsDescription() { return { model: { type: "list", label: "Model", options: [ "gpt-4o", "gpt-4o-mini", "o1", "o1-mini", "gpt-3.5-turbo", "gpt-4", "gpt-4-turbo-preview", "gpt-4-32k", "gpt-4-vision-preview", "text-davinci-003", "text-curie-001", "text-babbage-001", "text-ada-001", "code-davinci-002", "code-cushman-001" ], default: "gpt-3.5-turbo" }, maxTokens: { type: "number", label: "Max Tokens", default: 100 }, temperature: { type: "number", label: "Temperature", default: 0.7 }, topP: { type: "number", label: "Top P", default: 1 }, frequencyPenalty: { type: "number", label: "Frequency Penalty", default: 0 }, presencePenalty: { type: "number", label: "Presence Penalty", default: 0 } }; } async generateText(t, e) { const r = await fetch("https://api.openai.com/v1/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.apiKey}` }, body: JSON.stringify({ model: (e == null ? void 0 : e.model) || "gpt-3.5-turbo", prompt: t, max_tokens: (e == null ? void 0 : e.maxTokens) || 100, temperature: (e == null ? void 0 : e.temperature) || 0.7, top_p: (e == null ? void 0 : e.topP) || 1, frequency_penalty: (e == null ? void 0 : e.frequencyPenalty) || 0, presence_penalty: (e == null ? void 0 : e.presencePenalty) || 0 }) }); if (!r.ok) throw new Error("Failed to generate text with OpenAI"); return (await r.json()).choices[0].text; } } export { d as OpenAIDriver };