Chapter 2: How to send a chat request to an LLM

Because LLMs are used so often in chatbots, talking to them feels like sending a chat message to a buddy.

const botResponse = sendPost("https://acme-ai.com/v1/chat", {
    sender: "user",
    message: "Hello, World!"
})

The sender field is an enum. The most common values are user and bot. Other values include system, tool-request, tool-response which I will explain shortly.

Remember that this is conceptual. Every AI company can publish their own specification for this field, so I'm using my own format too.

If you log the response object, you'll see the message.

console.log(botResponse);
// { sender: "bot", message: "Why, hello there!" }

Notice that this time, the sender is "bot".