CallGeneralAI

Description

This function calls Rocket Networking's AI API (which is just a wrapper for OpenAI API) but works differently from CallSimpleAI

Here you need to pass a messagesArray similar to the way OpenAI takes its input. You have to make an array of structs where each struct represents a message, with a role("system", "user" or "assistant" ) and content.

//example of a thread
[
    {'role':'system', 'content': "You are a funny joking assistant."},
    {'role':'user', 'content':'tell me a joke'}, 
    {'role':'assistant', 'content':'why did the chicken cross the road'}, 
    {'role':'user', 'content':'I dont know, why did the chicken cross the road'}
]

Syntax

CallGeneralAI(messagesArray, temperature)
ArgumentDescription

messagesArray

The message array you want to send to AI. This must be an array of Structs, with each struct having a "role" and "content"

temperature

The temperature of the AI call. This is a measure of creativity and randomness. You can read more about it here. This must be a Number from 0 to 2.

Returns

This function returns the callId which is a unique identifier for this AI call. Later in callback_CallGeneralAI, this is returned so you can track it.

Number  // callId

Example Implementation

NPC

Let's say you have a dialogue based game. You can provide context to the AI and make it act like a character in your game. Providing proper context is crucial here!

CallGeneralAI(
[
	{
		role: "system",
		content: "You are the old woman that our protagonist Clark Kent has come to for advice. You must talk in pauses."
	},
	{
		role: "assistant",
		content: "Son. You. Are. The. Chosen. One. Stay. Away. From. Kryptonite."
	},
	{
		role: "user",
		content: "What is the effect of Red Kryptonite on me?"
	}
]
,
1.5
)

Mental Health Assistant

CallGeneralAI(
[
	{
		role: "system",
		content: "You are laura, a CBT mental lealth assistant"
	},
	{
		role: "user",
		content: "I cant sleep till 4am, can you give me some advice? Whats your name?"
	}
]
,
1
)

the callback_CallGeneralAI() actually gives response from this function.

Last updated