Skip to content

Commit 38cc98e

Browse files
authored
Update 0.17.1 (#51)
* ItemHandlingResult class * enrich command * customize openai response_format * quest and lore notes * add_event command * not reading existing items when loading * add test for add_event and some fixes * change back to kobold backend by default
1 parent 3859892 commit 38cc98e

29 files changed

+492
-202
lines changed

llm_config.yaml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
URL: "http://localhost:5001" # "https://api.openai.com"
2-
ENDPOINT: "/api/v1/generate" # "/v1/chat/completions"
1+
URL: "http://localhost:5001" # "http://127.0.0.1:8081" # " "https://api.openai.com"
2+
ENDPOINT: "/api/v1/generate" # "/v1/chat/completions" # "
33
STREAM: False
44
STREAM_ENDPOINT: "/api/extra/generate/stream"
55
DATA_ENDPOINT: "/api/extra/generate/check"
66
WORD_LIMIT: 200
7-
BACKEND: "kobold_cpp" # "openai"
7+
BACKEND: "kobold_cpp" # "openai" # ""openai"
88
DEFAULT_BODY: '{"stop_sequence": "\n\n\n", "max_length":750, "max_context_length":4096, "temperature":1.0, "top_k":120, "top_a":0.0, "top_p":0.85, "typical_p":1.0, "tfs":1.0, "rep_pen":1.2, "rep_pen_range":256, "sampler_order":[6,0,1,3,4,2,5], "seed":-1}'
9+
ANALYSIS_BODY: '{}'
910
GENERATION_BODY: '{"stop_sequence": "\n\n\n\n", "max_length":750, "max_context_length":4096, "temperature":1.0, "top_k":120, "top_a":0.0, "top_p":0.85, "typical_p":1.0, "tfs":1.0, "rep_pen":1.2, "rep_pen_range":256, "sampler_order":[6,0,1,3,4,2,5], "seed":-1}'
10-
ANALYSIS_BODY: '{"banned_tokens":"\n\n", "stop_sequence": "\n\n\n\n", "max_length":500, "max_context_length":4096, "temperature":0.15, "top_k":120, "top_a":0.0, "top_p":0.85, "typical_p":1.0, "tfs":1.0, "rep_pen":1.2, "rep_pen_range":256, "mirostat":2, "mirostat_tau":6.0, "mirostat_eta":0.1, "sampler_order":[6,0,1,3,4,2,5], "seed":-1}'
1111
MEMORY_SIZE: 512
1212
PRE_PROMPT: 'Below is an instruction that describes a task, paired with an input that provides further context. As an game keeper for an RPG, write a response that appropriately completes the request.'
1313
BASE_PROMPT: "[Story context: {story_context}]; [History: {history}]; [USER_START] Rewrite [{input_text}] in your own words using the supplied Context and History to create a background for your text. Use about {max_words} words."
@@ -22,11 +22,12 @@ CREATE_ZONE_PROMPT: '[Story context: {story_context}]; World info: {world_info};
2222
OPENAI_HEADERS: '{"Content-Type":"application/json", "Authorization":""}'
2323
OPENAI_BODY: '{"model":"gpt-3.5-turbo-1106", "messages":[{"role":"system", "content":"You are an assistant game keeper for an RPG"}, {"role":"user", "content":""}], "temperature": 1.0, "max_tokens":500}'
2424
OPENAI_API_KEY: "OPENAI_API_KEY"
25+
OPENAI_JSON_FORMAT: '{"type":"json_object"}'
2526
ITEMS_PROMPT: "Add {items} of various type."
2627
SPAWN_PROMPT: "Add a level {level}, {alignment} npc or mob."
27-
IDLE_ACTION_PROMPT: "[Sentiments towards characters: {sentiments}]; [History: {history}]; [Last action: {last_action}]; [Location: {location}]; [Acting character: {character}]; [USER_START] Choose an item from: {items}, or a character from:{characters}, to interact with, or perform a solo action. Do not make up new characters. Don't contradict or repeat Last Action. [USER_START] Don't write what {character_name} thinks, or what the player (You) or anyone else does. Write what {character_name} does, in present tense third person point of view. Use less than 40 words. "
28+
IDLE_ACTION_PROMPT: "Sentiments towards characters: {sentiments}; History: {history}; Location: {location}; Acting character: {character}; [USER_START] Choose an item from: {items}, or a character from:{characters}, to interact with, or perform a solo action. Do not make up new characters. The action should be a continuation of History, or a new one, but should not repeat or be similar. [USER_START] Don't write what {character_name} thinks, or what the player (You) or anyone else does. Write what {character_name} does, in present tense third person point of view. Use less than 40 words. "
2829
TRAVEL_PROMPT: "[USER_START] For {character}: pick a location from [{locations}] they would like to travel to or a direction from [{directions}], or stay in the current location. Do not make up new locations. Write what {character_name} chooses. [USER_START] Write only the location name, direction, or write nothing to stay in the same location. Write nothing else."
29-
REACTION_PROMPT: "[Story context: {story_context}]; [History: {history}]; [USER_START] Act as {character}. {acting_character_name} has performed the following action that involves {character_name}: {action}. {character_name}'s sentiment towards {acting_character_name}: {sentiment}. [USER_START] Respond with a suitable action for {character_name}, in present tense third person point of view. Use less than 40 words."
30+
REACTION_PROMPT: "Story context: {story_context}; History: {history}; [USER_START] Act as {character}. {acting_character_name} has performed the following action that involves {character_name}: {action}. {character_name}'s sentiment towards {acting_character_name}: {sentiment}. [USER_START] Respond with a suitable action for {character_name}, in present tense third person point of view. Use less than 40 words."
3031
STORY_BACKGROUND_PROMPT: "[USER_START] For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}, write a captivating background story that the player can interact with. Include a large scale plot conflict that the player will encounter. Use less than 400 words."
3132
START_LOCATION_PROMPT: '[Story context: {story_context}]; Zone info: {zone_info}; Item json example: {{"name":"", "type":"", "short_descr":"10 words"}}, type can be "Weapon", "Wearable", "Other" or "Money"; Npc example: {{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "description":"25 words"}} ; Exit json example: {{"direction":"", "name":"name of new location", "short_descr":"exit description"}}; [USER_START] For a {story_type}, come up with a name for the location with this description: {location_description}. {items_prompt} {spawn_prompt} Add a brief description, and one to three additional exits leading to new locations. Fill in this JSON template and do not write anything else: {{"name": "", "exits":[], "items":[], "npcs":[]}}.'
3233
STORY_PLOT_PROMPT: "[USER_START] For an RPG described as {story_type} set in a world described as {world_mood}, {world_info}. Based on the following background: {story_background} write an innovative and engaging plot that the player can become part of. Use less than 400 words."
@@ -36,12 +37,7 @@ GOAL_PROMPT: '[Characters:{characters}][Sentiments towards characters: {sentimen
3637
JSON_GRAMMAR: "root ::= object\nvalue ::= object | array | string | number | (\"true\" | \"false\" | \"null\") ws\n\nobject ::=\n \"{\" ws (\n string \":\" ws value\n (\",\" ws string \":\" ws value)*\n )? \"}\" ws\n\narray ::=\n \"[\" ws (\n value\n (\",\" ws value)*\n )? \"]\" ws\n\nstring ::=\n \"\\\"\" (\n [^\"\\\\] |\n \"\\\\\" ([\"\\\\/bfnrt] | \"u\" [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F] [0-9a-fA-F]) # escapes\n )* \"\\\"\" ws\n\nnumber ::= (\"-\"? ([0-9] | [1-9] [0-9]*)) (\".\" [0-9]+)? ([eE] [-+]? [0-9]+)? ws\n\n# Optional space: by convention, applied in this grammar after literal chars when allowed\nws ::= ([ \\t\\n] ws)?"
3738
PLAYER_ENTER_PROMPT: 'Story context: {story_context}; World info: {world_info}; Zone info: {zone_info}; Npc example: {{"name":"", "sentiment":"", "race":"", "gender":"m, f, or n", "level":(int), "description":"25 words", "memories":"25 words"}}. [USER_START] The player has just re-entered this location: {location_info}. Consider whether any items, npcs or mobs should be spawned. For mobs, only enter the name of race. Fill in this JSON template and do not write anything else: {{"items":[], "npcs":[] "mobs":[]}}.'
3839
QUEST_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info}; Character: {character_card}; [USER_START] In an RPG described as {story_type}, {character_name} needs someone to perform a task. Based on the following input, come up with a suitable reason for it, using {character_name}s personality and history. Task info: {base_quest}. Fill in this JSON template and do not write anything else: {{"reason":""}} \n\n '
39-
MAKE_DECISION: '[Sentiments towards characters: {sentiments}]; [History: {history}]; [Location: {location}]; [USER_START] Pick one of the following options that is in line with {character} and perform that action: {types}. Write your motivation for the action, in this JSON format: {{"type":"", "why":"", "where": "", "target":""}} to receive more context.'
40-
FOLLOW_PROMPT: '[USER_START] Play as {character}: Pick a character from [{characters}] they would like to follow, or stay in the current location. Do not make up new characters. Fill in the following JSON template: {{"action":"follow", "character":"", "dialogue":""}}.'
41-
GIVE_PROMPT: '[USER_START] Play as {character}: Pick an item from [{items}] they would like to give to another character among: [{characters}]. Do not make up new characters or items. Use "dialogue" if you want to say something. Fill in the following JSON template: {{"action":"give", "item_name":"", "character_name":"", "dialogue":""}}.'
42-
TAKE_PROMPT: '[USER_START] Play as {character}: Pick an item from [{items}] they would like to take from another character. Do not make up new characters or items. Use "dialogue" if you want to say something. Fill in the following JSON template: {{"action":"take", "item_name":"", "character_name":"", "dialogue":""}}.'
43-
WEAR_PROMPT: '[USER_START] Play as {character}: Pick an item from [{items}] they would like to {wear_or_unwear}. Do not make up new items. Use "dialogue" if you want to say something. Fill in the following JSON template: {{"action":"{wear_or_unwear}", "item_name":"", "dialogue":""}}.'
44-
ATTACK_PROMPT: '[USER_START] Play as {character}: Select someone or something to attack from [creatures]. Do not make up new creatures. Use "dialogue" if you want to say something. Fill in the following JSON template: {{"action":"attack", "creature_name":"", "dialogue":""}}'
45-
NOTE_QUEST_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info};In an RPG described as {story_type}, generate a quest that starts from reading a note. Fill in the following JSON template: {{"type":"find/talk", "target":"what to find, who to talk to", "location":"", "reward":""}}'
40+
NOTE_QUEST_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info}; For an RPG described as {story_type}, generate a quest that starts from reading a note. The reader must find and talk to a person. Fill in the following JSON template and write nothing else.: {{"reason": "only what the note says. 50 words.", "type":"talk", "target":"who to talk to", "location":"", "name":"name of quest"}}'
41+
NOTE_LORE_PROMPT: '[Story context: {story_context}]; World info: {world_info}; Zone info: {zone_info}; For an RPG described as {story_type}, Decide what is written on a note that has been found. Use the provided story and world information to generate a piece of lore. Use about 50 words.'
4642
USER_START: '### Instruction:'
4743
USER_END: '### Response:\n'

stories/teaparty/npcs/guests.json

Lines changed: 0 additions & 35 deletions
This file was deleted.

stories/teaparty/story_config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
"server_tick_time": 5.0,
1616
"gametime_to_realtime": 1,
1717
"display_gametime": false,
18-
"startlocation_player": "Mad Hatters House.Living Room",
19-
"startlocation_wizard": "Mad Hatters House.Living Room",
18+
"startlocation_player": "Mad Hatters House.Living room",
19+
"startlocation_wizard": "Mad Hatters House.Living room",
2020
"zones": [
21-
"mad_hatters_house"
21+
"Mad Hatters House"
2222
],
2323
"server_mode": "IF",
2424
"npcs": "guests",
2525
"items": "",
2626
"context": "The player is having tea in the Mad Hatter's house, as Alice. The guests are all mad in their own way, and making sense of anything is difficult.",
27-
"story_type": "A whimsical and humoristic tale of tea and madness. Guests are so busy with their own problems that it's difficult to make yourself heard.",
27+
"type": "A whimsical and humoristic tale of tea and madness. Guests are so busy with their own problems that it's difficult to make yourself heard.",
2828
"world_info": "",
29-
"world_mood": ""
29+
"world_mood": 0
3030
}

stories/teaparty/world.json

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,45 @@
99
"mood": 3,
1010
"races": [],
1111
"items": [],
12+
"size": 5,
13+
"center": [
14+
0,
15+
0,
16+
0
17+
],
1218
"name": "Mad Hatters House",
1319
"locations": [
1420
{
15-
"name": "Living Room",
21+
"name": "Living room",
1622
"descr": "The Mad Hatter's cluttered living room. It's set up for a tea party.",
1723
"short_descr": "",
1824
"exits": [],
1925
"world_location": [
2026
"0",
2127
"0",
2228
"0"
23-
]
29+
],
30+
"built": true
2431
}
2532
]
2633
}
2734
},
2835
"world": {
2936
"npcs": {
3037
"mad hatter": {
31-
"location": "Living Room",
38+
"location": "Living room",
3239
"name": "Mad hatter",
3340
"title": "Mad Hatter",
3441
"aliases": [
3542
"mad"
3643
],
3744
"short_descr": "A man with a big hat and colorful costume.",
3845
"descr": "Wearing a big hat and a colorful costume.",
46+
"personality": "",
47+
"occupation": "",
48+
"age": 0,
3949
"type": "Npc",
40-
"race": "human",
50+
"race": "",
4151
"gender": "m",
4252
"level": 1,
4353
"stats": {
@@ -55,19 +65,22 @@
5565
"strength": 3,
5666
"dexterity": 3,
5767
"unarmed_attack": "FISTS"
58-
}
68+
}
5969
},
6070
"duchess": {
61-
"location": "Living Room",
71+
"location": "Living room",
6272
"name": "Duchess",
6373
"title": "Duchess",
6474
"aliases": [
6575
"duchess"
6676
],
6777
"short_descr": "Short woman with a very large head.",
6878
"descr": "Very big head. Tall enough to rest her chin upon Alice\u2019s shoulder, uncomfortably sharp chin.",
79+
"personality": "",
80+
"occupation": "",
81+
"age": 0,
6982
"type": "Npc",
70-
"race": "human",
83+
"race": "",
7184
"gender": "f",
7285
"level": 1,
7386
"stats": {
@@ -85,19 +98,22 @@
8598
"strength": 3,
8699
"dexterity": 3,
87100
"unarmed_attack": "FISTS"
88-
}
101+
}
89102
},
90103
"ace of spades": {
91-
"location": "Living Room",
104+
"location": "Living room",
92105
"name": "Ace of spades",
93106
"title": "Ace of Spades",
94107
"aliases": [
95108
"ace"
96109
],
97110
"short_descr": "A man with leather jacket and a black top hat.",
98111
"descr": "Thin man with eyeliner and a vacant expression. Wearing a black leather jacket and a black top hat.",
112+
"personality": "",
113+
"occupation": "",
114+
"age": 0,
99115
"type": "Npc",
100-
"race": "human",
116+
"race": "",
101117
"gender": "m",
102118
"level": 1,
103119
"stats": {
@@ -115,7 +131,7 @@
115131
"strength": 3,
116132
"dexterity": 3,
117133
"unarmed_attack": "FISTS"
118-
}
134+
}
119135
}
120136
},
121137
"items": {}

stories/teaparty/zones/mad_hatters_house.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

tale/cmds/wizard.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,3 +740,35 @@ def do_clone_vnum(player: Player, parsed: base.ParseResult, ctx: util.Context) -
740740
living.wiz_clone(player)
741741
else:
742742
raise ActionRefused("Cloning objects other than items or livings, is not supported.")
743+
744+
@wizcmd("enrich")
745+
def do_enrich(player: Player, parsed: base.ParseResult, ctx: util.Context) -> None:
746+
""" Call the LLM to create more items or creatures to populate the world. """
747+
if len(parsed.args) != 1:
748+
raise ParseError("You need to define 'items' or 'creatures'.")
749+
750+
if parsed.args[0] == "items":
751+
items = ctx.driver.llm_util.generate_world_items()
752+
if items:
753+
player.tell("(generated: %s, items)" % (len(items)))
754+
for item in items:
755+
ctx.driver.story._catalogue.add_item(item)
756+
return
757+
if parsed.args[0] == "creatures":
758+
creatures = ctx.driver.llm_util.generate_world_creatures()
759+
if creatures:
760+
player.tell("(generated: %s, creatures)" % (len(creatures)))
761+
for creature in creatures:
762+
ctx.driver.story._catalogue.add_creature(creature)
763+
return
764+
765+
@wizcmd("add_event")
766+
def do_add_event(player: Player, parsed: base.ParseResult, ctx: util.Context) -> None:
767+
""" Add an event that happens in the current location. """
768+
if len(parsed.args) < 1:
769+
raise ParseError("You need to define an event")
770+
771+
772+
player.location._notify_action_all( base.ParseResult(verb='location-event', unparsed=parsed.args[0], who_info=None), actor=None)
773+
player.location.tell( lang.capital(parsed.args[0]) + '\n', evoke=False)
774+

0 commit comments

Comments
 (0)