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)

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