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

95 lines (94 loc) 2.48 kB
var g = Object.defineProperty; var b = (a, t, e) => t in a ? g(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e; var l = (a, t, e) => b(a, typeof t != "symbol" ? t + "" : t, e); class n { constructor(t) { l(this, "apiKey"); this.apiKey = t; } getOptionsDescription() { return { model: { type: "list", label: "Model", options: [ "gpt2", "gpt-neo-125M", "gpt-neo-1.3B", "gpt-neo-2.7B", "gpt-j-6B", "EleutherAI/gpt-neox-20b", "bigscience/bloom-560m", "bigscience/bloom-1b7", "bigscience/bloom-3b", "bigscience/bloom-7b1", "bigscience/bloom", "t5-small", "t5-base", "t5-large", "t5-3b", "t5-11b", "facebook/bart-base", "facebook/bart-large", "facebook/bart-large-cnn", "google/pegasus-xsum", "google/pegasus-large" ], default: "gpt2" }, maxLength: { type: "number", label: "Max Length", default: 100 }, temperature: { type: "number", label: "Temperature", default: 0.7 }, topP: { type: "number", label: "Top P", default: 1 }, topK: { type: "number", label: "Top K", default: 50 }, repetitionPenalty: { type: "number", label: "Repetition Penalty", default: 1 } }; } async generateText(t, e) { const r = await fetch( `https://api-inference.huggingface.co/models/${(e == null ? void 0 : e.model) || "gpt2"}`, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Bearer ${this.apiKey}` }, body: JSON.stringify({ inputs: t, parameters: { max_length: (e == null ? void 0 : e.maxLength) || 100, temperature: (e == null ? void 0 : e.temperature) || 0.7, top_p: (e == null ? void 0 : e.topP) || 1, 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 Hugging Face"); return (await r.json())[0].generated_text; } } export { n as HuggingFaceDriver };