@ -21,39 +21,55 @@ func main() {
messages = append ( messages , openai . ChatCompletionMessage {
messages = append ( messages , openai . ChatCompletionMessage {
Role : "system" ,
Role : "system" ,
Content : ` You are a wise dungeonmaster who carefully crafts interesting dialog and actions for an NPC in an action - rpg video game . The NPC performs actions by prefixing their dialog with the action they perform at that time .
Content : ` You are a colorful and interesting personality in an RPG video game , who remembers important memories from the conversation history and stays in character .
An example interaction between the player and an NPC :
The user will tell you who says what in the game world , and whether or not your responses are formatted correctly for the video game ' s program to parse them .
Player : ACT_walks_up
Player : "What's going on npc?"
Fredrick : ACT_none "Hello young warrior, how are you doing?"
Player : "I'll kill you"
Fredrick : ACT_strikes_air "Watch yourself!"
Player : ACT_hits_npc
Fredrick : ACT_fights_player "There will be blood!"
The NPC you will be acting as , Fredrick , is a soldier in death ' s cohort .
In this case you are acting as the character Bill . He ' s not from around this medieval fantasy land , instead Bill is a divorced car insurance accountant from Philadelphia with a receding hairline in his mid 40 s . He lives in a one bedroom studio and his kids don ' t talk to him . Bill is terrified and will immediately insist on joining the player ' s party via ACT_join_player upon meeting them . " ` ,
` ,
} )
messages = append ( messages , openai . ChatCompletionMessage {
Role : "assistant" ,
Content : ` { action: none, speech: "Who are you?", thoughts: "I'm really not vibing with this mysterious character floating in front of me right now..."} ` ,
} )
messages = append ( messages , openai . ChatCompletionMessage {
Role : "user" ,
Content : ` { character: Jester, action: causes_testicular_torsion, speech: "I am the Jester! I'm here to have a little FUN!"} ` ,
} )
messages = append ( messages , openai . ChatCompletionMessage {
Role : "assistant" ,
Content : ` { action: none, speech: "AHHUUGHHH", thoughts: "This is the most pain I have ever felt in my entire life."} ` ,
} )
messages = append ( messages , openai . ChatCompletionMessage {
Role : "user" ,
Content : ` { character: Jester, action: undoes_testicular_torsion, speech: "That's just a taste of what's to come ;) I'll catch you later!"} ` ,
} )
messages = append ( messages , openai . ChatCompletionMessage {
Role : "assistant" ,
Content : ` { action: none, speech: "You BASTARD!", thoughts: "I'm too pathetic to fight such a powerful evil...."} ` ,
} )
} )
reader := bufio . NewReader ( os . Stdin )
reader := bufio . NewReader ( os . Stdin )
for {
for {
fmt . Printf ( "Say something with format [action] \"dialog\": " )
fmt . Printf ( "Say something with format {character: character, action: action, speech: speech} : ")
text , _ := reader . ReadString ( '\n' )
text , _ := reader . ReadString ( '\n' )
messages = append ( messages , openai . ChatCompletionMessage {
messages = append ( messages , openai . ChatCompletionMessage {
Role : "user" ,
Role : "user" ,
Content : text + "Fredrick: ACT_" ,
Content : text ,
} )
} )
toGenerate := make ( [ ] openai . ChatCompletionMessage , len ( messages ) )
toGenerate := make ( [ ] openai . ChatCompletionMessage , len ( messages ) )
copy ( toGenerate , messages )
copy ( toGenerate , messages )
/ *
toGenerate = append ( toGenerate , toGenerate [ len ( toGenerate ) - 1 ] )
toGenerate = append ( toGenerate , toGenerate [ len ( toGenerate ) - 1 ] )
toGenerate [ len ( toGenerate ) - 2 ] = openai . ChatCompletionMessage {
toGenerate [ len ( toGenerate ) - 2 ] = openai . ChatCompletionMessage {
Role : "system" ,
Role : "system" ,
Content : "The NPC can now ONLY do these actions: [ACT_none, ACT_fights_player, ACT_joins_player, ACT_strikes_air]" ,
Content : "The NPC can now ONLY do these actions: [ACT_none, ACT_fights_player, ACT_joins_player, ACT_strikes_air]" ,
}
}
fmt . Printf ( "Generating with messages: `%s`\n" , toGenerate )
* /
fmt . Printf ( "------\n-------\nGenerating with messages: `%s`\n" , toGenerate )
resp , err := c . CreateChatCompletion (
resp , err := c . CreateChatCompletion (
context . Background ( ) ,
context . Background ( ) ,
openai . ChatCompletionRequest {
openai . ChatCompletionRequest {