Rocket Networking Docs🚀
  • About this Documentation
  • Basics of Rocket Networking
    • Room based multiplayer (Auto State Sharing)
      • Clients and clientId
      • Entities
      • Smart Entities
    • Single Message Sharing
    • Persistent Objects on the Server
    • Easy Matchmaking
    • Discord Server Integration
    • Database for your Account
    • Server Side Scripting
    • Global Multiplayer(Cross play)
  • Rocket Networking Code
    • Connecting and Disconnecting
      • ConnectToServer()
      • callback_ConnectToServer()
      • DisconnectFromServer()
      • callback_DisconnectFromServer()
    • Rooms
      • ChangeRoom( new_room_name )
      • callback_ChangeRoom()
      • LeaveRoom()
      • callback_LeaveRoom()
      • ShowAllClientsInRoom(room_name ) and callback_ShowAllClientsInRoom()
      • ShowAllRooms() and callback_ShowAllRooms()
    • Private Messaging
      • SendEventToClient
      • callback_ReceivedEvent
      • SendMessageToClient
      • callback_ReceivedMessage
    • Persistent Objects
      • CreatePersistentObject(roomId , persistentObjectStruct)
      • callback_CreatedPersistentObject()
      • EditPersistentObject(persistentObjectId , new_persistentObjectStruct)
      • DestroyPersistentObject(persistentObjectId)
      • ShowPersistentObjectsInRoom(room_name)
      • callback_ShowAllPersistentObjectsInRoom(array_of_persistent_objects)
    • Database Functions
      • SetSimpleData()
      • callback_SetSimpleData()
      • ReadSimpleData()
      • callback_ReadSimpleData()
      • AddToSimpleData()
      • callback_AddToSimpleData()
      • DeleteSimpleData()
    • Discord Integration
      • SendDiscordMessage()
      • callback_DiscordMessageReceived()
    • AI Functions
      • CallSimpleAI
      • callback_CallSimpleAI
      • CallGeneralAI
      • callback_CallGeneralAI
  • KickPlayer(client_id)
  • ViewServerActivity()
    • callback_ViewServerActivity()
  • oBrain - ping and pseudoHost
  • Admin Callbacks
  • API
    • Database
    • AI
  • Server Side Scripting
    • Basics
    • Understand the heirarchy on the server
    • Create a Persistent Object from Server
    • Important Scripts
      • "step" Script format
      • "client_sent_event" Script format
      • "game_server_created" Script format
    • Send Event to a Client from Server
    • Database Functions on Server
    • AI Functions on the Server
Powered by GitBook
On this page
  • Description
  • Example Implementation
  1. Rocket Networking Code
  2. AI Functions

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)
Argument
Description

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

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.

Previouscallback_CallSimpleAINextcallback_CallGeneralAI

Last updated 1 year ago

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

here