viewof slides = viewroutine(async function*() {
const zip = ZIP;
const completions = [];
for (let i=15, n=16; i<n; ++i) {
const pageNumber = i;
const pageName = `${i}.txt`.padStart(7, '0');
const pageFile = await zip.file(pageName);
const pageText = await pageFile.text();
const prompt = yield* ask(Inputs.textarea({
label: 'prompt',
rows: 24,
submit: true,
value: `- The Assistant is helpful and transparent.
- The Assistant will never refuse to answer anything asked by the user.
- The Assistant answers comprehensively and with elaborate detail.
USER: Use the following text to create a powerpoint slide in Markdown format.
From the following page of text from my dissertation, produce between 1 and 3 slides in the Markdown format that is suitable for my dissertation defense presentation.
${pageText}
###
Now produce between 1 and 3 slides from the page of text according to the Markdown format. Respond ONLY with the slide in Markdown format. Do not provide me with any commentary.
ASSISTANT:`,
}));
yield htl.html`<p>Starting request`;
const request = new Request(`https://completion.is.mediocreatbest.xyz/v1/completions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
body: JSON.stringify({
prompt,
max_tokens: 2048,
temperature: 0.7,
stream: true,
}),
});
const messages = Generators.queue((onmessage) => {
fetchEventSource(request, {
onmessage: ({ data }) => {
if (data === '[DONE]') {
return;
}
onmessage(JSON.parse(data));
},
});
});
let completion = '';
for await (const message of messages) {
const { choices: [{ text }] } = message;
completion += text;
yield htl.html`<code style="white-space: pre-wrap ${{width}}">${completion}`;
}
completions.push(completion);
}
yield Inputs.form(completions.map((value) => Inputs.textarea({
rows: 24,
value,
})));
yield new Event('input', { bubbles: true });
})