AI Functions on the Server
Method Signature
async callAI(messagesArray: Array<{ role: string, content: string }>, temperature: number): Promise<any>Parameters
Returns
Usage
const messages = [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Tell me a joke." },
{ role: "assistant", content: "Why did the chicken cross the road?" }
];
const temperature = 0.7;
game.callAI(messages, temperature)
.then((response) => {
console.log("AI response data is:");
console.log(response);
if(response == "error"){
//error
}else{
// Handle the AI response here. response.message is the reply and response.creditsUsed is how many credits were used
}
})
Error Handling
Last updated