This neat demo is a year old now, it was first released in July 2023.<p>Source code and prompt here: <a href="https://github.com/Calvin-LL/CalcGPT.io/blob/main/netlify/functions/math.ts">https://github.com/Calvin-LL/CalcGPT.io/blob/main/netlify/fu...</a><p><pre><code> const prompt = `1+1=2\n5-2=3\n2*4=8\n9/3=3\n10/3=3.33333333333\n${math}=`;
let response: Response;
try {
const openAI = new OpenAI();
response = await openAI.completions
.create({
model: "babbage-002",
temperature,
top_p: topP,
stop: "\n",
prompt,
stream: true,
})
.asResponse();
} catch (error) {
return new Response("api error", {
status: 500,
});
}
return new Response(response.body, {
headers: {
"content-type": "text/event-stream",
},
});
</code></pre>
It's using the old babbage-002 model with a completion (not chat) prompt, which is more readable like this:<p><pre><code> 1+1=2
5-2=3
2*4=8
9/3=3
10/3=3.33333333333
${math}=</code></pre>