Hacker News new | ask | show | jobs
by simonw 697 days ago
This neat demo is a year old now, it was first released in July 2023.

Source code and prompt here: https://github.com/Calvin-LL/CalcGPT.io/blob/main/netlify/fu...

    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",
      },
    });
It's using the old babbage-002 model with a completion (not chat) prompt, which is more readable like this:

    1+1=2
    5-2=3
    2*4=8
    9/3=3
    10/3=3.33333333333
    ${math}=