The configuration file of the mod is stored in the chat-with-npc
folder in the plugin directory. The file name is
the config.json
. The content of the file is as follows:
{
"enabled": true,
"range": 10.0,
"language": "Chinese",
"apiKey": "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"model": "gpt-3.5-turbo",
"apiURL": "api.openai.com",
"isBubble": true,
"isChatBar": true,
"wordLimit": 30
}
You can set the parameters below:
range
: how far the players can see and talk to the NPC.language
: which language the NPC will use to talk to the player.model
: the model of OpenAIapiURL
: you can use the proxy to access the OpenAI API.isBubble
: whether to show the bubble above the NPC.isChatBar
: whether to show the chat of the NPC in the chat bar of the player.wordLimit
: the maximum number of words in each reply of the NPC.
Once you create a new NPC, you will see the Assistant in your OpenAI platform as below:
You can access to the OpenAI platform to manage, use and test your NPCs in the OpenAI platform Assistant.
**Important: The settings in your configuration file will override the settings on the OpenAI platform, so remember to modify them in the configuration file after testing.
This document is about some basic settings of the plugin, which can help users to use the plugin well, or to develop the plugin within the scope of the license. The plugin has the following parts:
- Conversation manager
- Group manager
- NPCEntity manager
- Lifecycle manager
And some basic settings:
- All times of this plugin are in milliseconds, recorded by
Long
type.
The Conversation manager is the core part of the plugin, which is responsible for managing all conversations. The main settings of the Conversation are:
ConversationManager
stores allConversationHandler
, which is the current conversation of an NPC, and provides methods to activate, extract, and delete conversations.ConversationHandler
contains anNPCEntity
member, the timeupdateTime
of the last conversation, and whether the current NPC is talkingisTalking
.- When the NPC is asynchronously requesting information from the model,
isTalking
will be set totrue
until the model returns the result, andupdateTime
will be updated. ConversationHandler
is only activated when the player is talking to the NPC, and unloaded 5 minutes after the player stops talking to the NPC.- The lifecycle of
ConversationHandler
is managed by the plugin lifecycle manager.
The Group manager is responsible for managing all Groups, and the main settings of the Group are:
GroupManager
stores allGroup
and provides methods to activate, extract, and delete Groups.Group
contains a last load timelastLoadTime
, and some settingsparentGroup
,instructions
,event
.Group
is only activated when theConversationHandle
requests information from the model, or when an OP uses a command to view and modify a Group.- The lifecycle of
Group
is managed by the plugin lifecycle manager.
Other settings:
- The
parentGroup
ofGroup
is a parent Group, and in general, allGroup
will eventually point toGlobal
.
The NPCEntity manager is responsible for managing all NPCEntity, and the main settings of NPCEntity are:
NPCEntityManager
stores allNPCEntity
and provides methods to activate, extract, and delete NPCEntity.NPCEntity
contains aTextBubbleEntity
, and some settingsCareer
,instructions
,Group
,longTermMemory
.NPCEntity
is only activated when the player is talking to the NPC, or when an OP uses a command to view and modify an NPC.
Other settings:
- The
TextBubbleEntity
ofNPCEntity
is a text bubble, managed byNPCEntity
, which will be loaded when the NPC is activated, and unloaded when the NPC is unloaded. - The
TextBubbleEntity
will be displayed 0.55 blocks above the NPC, and when the NPC replies to the player, the bubble will be displayed normally for 10 seconds, and then become transparent, but will not be unloaded (to be modified).
The lifecycle manager is responsible for managing the lifecycle of all ConversationHandler
, NPCEntity
and Group
, and the main
settings are:
ConversationHandler
andGroup
are managed by the lifecycle manager, and the lifecycle manager provides methods to activate, extract, and discardConversationHandler
,NPCEntity
andGroup
.- The lifecycle manager will automatically discard the
ConversationHandler
,NPCEntity
andGroup
that have not been activated for a 5 minutes period every 30 seconds after the plugin is loaded. - All
ConversationHandlers
,NPCEntity
andGroups
can be unloaded asynchronously with the command/npc saveAll
.