Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 0.17.1 #51

Merged
merged 11 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions llm_config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
URL: "http://localhost:5001" # "https://api.openai.com"
ENDPOINT: "/api/v1/generate" # "/v1/chat/completions"
URL: "http://localhost:5001" # "http://127.0.0.1:8081" # " "https://api.openai.com"
ENDPOINT: "/api/v1/generate" # "/v1/chat/completions" # "
STREAM: False
STREAM_ENDPOINT: "/api/extra/generate/stream"
DATA_ENDPOINT: "/api/extra/generate/check"
WORD_LIMIT: 200
BACKEND: "kobold_cpp" # "openai"
BACKEND: "kobold_cpp" # "openai" # ""openai"
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}'
ANALYSIS_BODY: '{}'
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}'
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}'
MEMORY_SIZE: 512
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.'
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."
Expand All @@ -22,11 +22,12 @@ CREATE_ZONE_PROMPT: '[Story context: {story_context}]; World info: {world_info};
OPENAI_HEADERS: '{"Content-Type":"application/json", "Authorization":""}'
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}'
OPENAI_API_KEY: "OPENAI_API_KEY"
OPENAI_JSON_FORMAT: '{"type":"json_object"}'
ITEMS_PROMPT: "Add {items} of various type."
SPAWN_PROMPT: "Add a level {level}, {alignment} npc or mob."
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. "
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. "
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."
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."
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."
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."
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":[]}}.'
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."
Expand All @@ -36,12 +37,7 @@ GOAL_PROMPT: '[Characters:{characters}][Sentiments towards characters: {sentimen
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)?"
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":[]}}.'
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 '
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.'
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":""}}.'
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":""}}.'
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":""}}.'
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":""}}.'
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":""}}'
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":""}}'
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"}}'
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.'
USER_START: '### Instruction:'
USER_END: '### Response:\n'
35 changes: 0 additions & 35 deletions stories/teaparty/npcs/guests.json

This file was deleted.

10 changes: 5 additions & 5 deletions stories/teaparty/story_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
"server_tick_time": 5.0,
"gametime_to_realtime": 1,
"display_gametime": false,
"startlocation_player": "Mad Hatters House.Living Room",
"startlocation_wizard": "Mad Hatters House.Living Room",
"startlocation_player": "Mad Hatters House.Living room",
"startlocation_wizard": "Mad Hatters House.Living room",
"zones": [
"mad_hatters_house"
"Mad Hatters House"
],
"server_mode": "IF",
"npcs": "guests",
"items": "",
"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.",
"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.",
"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.",
"world_info": "",
"world_mood": ""
"world_mood": 0
}
38 changes: 27 additions & 11 deletions stories/teaparty/world.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,45 @@
"mood": 3,
"races": [],
"items": [],
"size": 5,
"center": [
0,
0,
0
],
"name": "Mad Hatters House",
"locations": [
{
"name": "Living Room",
"name": "Living room",
"descr": "The Mad Hatter's cluttered living room. It's set up for a tea party.",
"short_descr": "",
"exits": [],
"world_location": [
"0",
"0",
"0"
]
],
"built": true
}
]
}
},
"world": {
"npcs": {
"mad hatter": {
"location": "Living Room",
"location": "Living room",
"name": "Mad hatter",
"title": "Mad Hatter",
"aliases": [
"mad"
],
"short_descr": "A man with a big hat and colorful costume.",
"descr": "Wearing a big hat and a colorful costume.",
"personality": "",
"occupation": "",
"age": 0,
"type": "Npc",
"race": "human",
"race": "",
"gender": "m",
"level": 1,
"stats": {
Expand All @@ -55,19 +65,22 @@
"strength": 3,
"dexterity": 3,
"unarmed_attack": "FISTS"
}
}
},
"duchess": {
"location": "Living Room",
"location": "Living room",
"name": "Duchess",
"title": "Duchess",
"aliases": [
"duchess"
],
"short_descr": "Short woman with a very large head.",
"descr": "Very big head. Tall enough to rest her chin upon Alice\u2019s shoulder, uncomfortably sharp chin.",
"personality": "",
"occupation": "",
"age": 0,
"type": "Npc",
"race": "human",
"race": "",
"gender": "f",
"level": 1,
"stats": {
Expand All @@ -85,19 +98,22 @@
"strength": 3,
"dexterity": 3,
"unarmed_attack": "FISTS"
}
}
},
"ace of spades": {
"location": "Living Room",
"location": "Living room",
"name": "Ace of spades",
"title": "Ace of Spades",
"aliases": [
"ace"
],
"short_descr": "A man with leather jacket and a black top hat.",
"descr": "Thin man with eyeliner and a vacant expression. Wearing a black leather jacket and a black top hat.",
"personality": "",
"occupation": "",
"age": 0,
"type": "Npc",
"race": "human",
"race": "",
"gender": "m",
"level": 1,
"stats": {
Expand All @@ -115,7 +131,7 @@
"strength": 3,
"dexterity": 3,
"unarmed_attack": "FISTS"
}
}
}
},
"items": {}
Expand Down
13 changes: 0 additions & 13 deletions stories/teaparty/zones/mad_hatters_house.json

This file was deleted.

32 changes: 32 additions & 0 deletions tale/cmds/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,35 @@ def do_clone_vnum(player: Player, parsed: base.ParseResult, ctx: util.Context) -
living.wiz_clone(player)
else:
raise ActionRefused("Cloning objects other than items or livings, is not supported.")

@wizcmd("enrich")
def do_enrich(player: Player, parsed: base.ParseResult, ctx: util.Context) -> None:
""" Call the LLM to create more items or creatures to populate the world. """
if len(parsed.args) != 1:
raise ParseError("You need to define 'items' or 'creatures'.")

if parsed.args[0] == "items":
items = ctx.driver.llm_util.generate_world_items()
if items:
player.tell("(generated: %s, items)" % (len(items)))
for item in items:
ctx.driver.story._catalogue.add_item(item)
return
if parsed.args[0] == "creatures":
creatures = ctx.driver.llm_util.generate_world_creatures()
if creatures:
player.tell("(generated: %s, creatures)" % (len(creatures)))
for creature in creatures:
ctx.driver.story._catalogue.add_creature(creature)
return

@wizcmd("add_event")
def do_add_event(player: Player, parsed: base.ParseResult, ctx: util.Context) -> None:
""" Add an event that happens in the current location. """
if len(parsed.args) < 1:
raise ParseError("You need to define an event")


player.location._notify_action_all( base.ParseResult(verb='location-event', unparsed=parsed.args[0], who_info=None), actor=None)
player.location.tell( lang.capital(parsed.args[0]) + '\n', evoke=False)

Loading