chat history

async function run(model, prompt) {
const messages = [
{ role: 'system', content: 'You are a friendly assistant' },
{ role: 'user', content: prompt }
];

const response = await fetch(
`https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/${model}`,
{
headers: { Authorization: "Bearer {API_TOKEN}" },
method: "POST",
body: JSON.stringify({ messages }),
}
);
const result = await response.json();
return result;
}

run('@cf/meta/llama-2-7b-chat-int8', 'Tell me a story').then((response) => {
console.log(JSON.stringify(response));
});
async function run(model, prompt) {
const messages = [
{ role: 'system', content: 'You are a friendly assistant' },
{ role: 'user', content: prompt }
];

const response = await fetch(
`https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/${model}`,
{
headers: { Authorization: "Bearer {API_TOKEN}" },
method: "POST",
body: JSON.stringify({ messages }),
}
);
const result = await response.json();
return result;
}

run('@cf/meta/llama-2-7b-chat-int8', 'Tell me a story').then((response) => {
console.log(JSON.stringify(response));
});
can we make it remember our chat history? i tried appending user in messages but did not work
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server