Skip to main content

Chat syntax

JSON

The messages of middlebop follow a simple structure and the response from the any supported model will follow the same syntax

[
{
"role": "system",
"content": {
"type": "text",
"text": "You are a helpful assistant called beep-boop",
},
},
{
"role": "user",
"content": {
"type": "text",
"text": "Hello, who are you?",
},
},
{
"role": "assistant",
"content": {
"type": "text",
"text": "Hello! I'm beep-boop, a helpful AI assistant. How can I help you today?",
},
},
];

Typescript

The npm client also exports a Typescript type to make it easier to create message arrays in the correct syntax.

import { MiddlebopChatMessage } from "@middlebop/client";

const messages: MiddlebopChatMessage[] = [
{
role: "system",
content: {
type: "text",
text: "You are a helpful assistant called beep-boop",
},
},
{
role: "user",
content: {
type: "text",
text: "Hello, who are you?",
},
},
{
role: "assistant",
content: {
type: "text",
text: "Hello! I'm beep-boop, a helpful AI assistant. How can I help you today?",
},
},
];