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

69 lines (68 loc) 1.81 kB
var m = Object.defineProperty; var i = (t, a, e) => a in t ? m(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e; var l = (t, a, e) => i(t, typeof a != "symbol" ? a + "" : a, e); class d { constructor(a) { l(this, "apiKey"); this.apiKey = a; } getOptionsDescription() { return { model: { type: "list", label: "Model", options: [ "mistral-large", "mistral-small", "mistral-nemo", "mistral-large-24.11", "mistral-large-2407" ], default: "mistral-large" }, maxTokens: { type: "number", label: "Max Tokens", default: 100 }, temperature: { type: "number", label: "Temperature", default: 0.7 }, topK: { type: "number", label: "Top K", default: 50 }, repetitionPenalty: { type: "number", label: "Repetition Penalty", default: 1 } }; } async generateText(a, e) { const r = await fetch("https://api.mistral.ai/v1/completions", { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.apiKey}` }, body: JSON.stringify({ model: (e == null ? void 0 : e.model) || "mistral-large", prompt: a, max_tokens: (e == null ? void 0 : e.maxTokens) || 100, temperature: (e == null ? void 0 : e.temperature) || 0.7, top_k: (e == null ? void 0 : e.topK) || 50, repetition_penalty: (e == null ? void 0 : e.repetitionPenalty) || 1 }) }); if (!r.ok) throw new Error("Failed to generate text with Mistral"); return (await r.json()).choices[0].text; } } export { d as MistralDriver };