Prep 0.19.0 (#67)

* linting

* improve prompt devtools: test changes, show more information

* some more polish for the new promp devtools

* up default conversation gen length to 128

* openai client tweaks, talemate sets max_tokens on gpt-3.5 generations

* support new openai embeddings (and default to text-embedding-3-small)

* ux polish for character sheet and character state ux

* actor instructions

* experiment using # for context / instructions

* fix bug where regenerating history would mess up time stamps

* remove trailing ]

* prevent client ctx from being unset

* fix issue where sometimes you'd need to delete a client twice for it to disappear

* upgrade dependencies

* set 0.19.0

* fix performance degradation caused by circular loading animation

* remove coqui studio support

* fix issue when switching from unsaved creative mode to loading a scene

* third party client / agent support

* edit dialogue examples through character / actor editor

* remove "edit dialogue" action from editor - replaced by character actor instructions

* different icon for delete

* prompt adjustment for acting instructions

* adhoc context generation for character attributes and details

* add adhoc generation for character description

* contextual generation tweaks

* contextual generation for dialogue examples
fix some formatting issues

* contextual generation for world entries

* prepopulate initial recen scenarios with demo scenes
add experimental holodeck scenario

* scene info
scene experimental

* assortment of fixes for holodeck improvements

* more holodeck fixes

* refactor holodeck instructions

* rename holodeck to simulation suite

* better scene status messages

* add new gpt-3.5-turbo model, better json response coercion for older models

* allow exclusion of characters when persisting based on world state

* better error handling of world state response

* better error handling of world state response

* more simulation suite fixes

* progress color

* world state character name mapping support

* if neither quote nor asterisk is in message default to quotes

* fix rerun of new paraphrase op

* sim suite ping that ensure's characters are not aware of sim

* fixes for better character name assessment
simulation suite can now give the player character a proper name

* fix bug with new status notifications

* sim suite adjustments and fixes and tuning

* sim suite tweaks

* impl scene restore from file

* prompting tweaks for reinforcement messages and acting instructions

* more tweaks

* dialogue prompt tweaks for rerun + rewrite

* fix bug with character entry / exit with narration

* linting

* simsuite screenshots

* screenshots
This commit is contained in:
veguAI
2024-02-06 00:40:55 +02:00
committed by GitHub
parent eb251d6e37
commit add4893939
96 changed files with 3480 additions and 1229 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -98,6 +98,7 @@
}
],
"immutable_save": true,
"experimental": true,
"goal": null,
"goals": [],
"context": "an epic sci-fi adventure aimed at an adult audience.",
@@ -109,10 +110,10 @@
"variables": {}
},
"assets": {
"cover_image": "52b1388ed6f77a43981bd27e05df54f16e12ba8de1c48f4b9bbcb138fa7367df",
"cover_image": "e7c712a0b276342d5767ba23806b03912d10c7c4b82dd1eec0056611e2cd5404",
"assets": {
"52b1388ed6f77a43981bd27e05df54f16e12ba8de1c48f4b9bbcb138fa7367df": {
"id": "52b1388ed6f77a43981bd27e05df54f16e12ba8de1c48f4b9bbcb138fa7367df",
"e7c712a0b276342d5767ba23806b03912d10c7c4b82dd1eec0056611e2cd5404": {
"id": "e7c712a0b276342d5767ba23806b03912d10c7c4b82dd1eec0056611e2cd5404",
"file_type": "png",
"media_type": "image/png"
}

View File

@@ -5,7 +5,7 @@
{%- set _ = emit_system("warning", "This is a dynamic scenario generation experiment for Infinity Quest. It will likely require a strong LLM to generate something coherent. GPT-4 or 34B+ if local. Temper your expectations.") -%}
{#- emit status update to the UX -#}
{%- set _ = emit_status("busy", "Generating scenario ... [1/3]") -%}
{%- set _ = emit_status("busy", "Generating scenario ... [1/3]", as_scene_message=True) -%}
{#- thematic tags will be used to randomize generation -#}
{%- set tags = thematic_generator.generate("color", "state_of_matter", "scifi_trope") -%}
@@ -17,17 +17,17 @@
{#- generate introductory text -#}
{%- set _ = emit_status("busy", "Generating scenario ... [2/3]") -%}
{%- set _ = emit_status("busy", "Generating scenario ... [2/3]", as_scene_message=True) -%}
{%- set tmpl__scenario_intro = render_template('generate-scenario-intro', premise=instr__premise) %}
{%- set instr__intro = "*"+render_and_request(tmpl__scenario_intro)+"*" -%}
{#- generate win conditions -#}
{%- set _ = emit_status("busy", "Generating scenario ... [3/3]") -%}
{%- set _ = emit_status("busy", "Generating scenario ... [3/3]", as_scene_message=True) -%}
{%- set tmpl__win_conditions = render_template('generate-win-conditions', premise=instr__premise) %}
{%- set instr__win_conditions = render_and_request(tmpl__win_conditions) -%}
{#- emit status update to the UX -#}
{%- set status = emit_status("info", "Scenario ready.") -%}
{%- set status = emit_status("success", "Scenario ready.", as_scene_message=True) -%}
{# set gamestate variables #}
{%- set _ = game_state.set_var("instr.premise", instr__premise, commit=True) -%}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@@ -0,0 +1,52 @@
{
"name": "Simulation Suite",
"environment": "scene",
"immutable_save": true,
"restore_from": "simulation-suite.json",
"experimental": true,
"help": "Address the computer by starting your statements with 'Computer, ' followed by an instruction.\n\nExamples:\n'Computer, i would like to experience an adventure on a derelict space station'\n'Computer, add a horrific alien creature that is chasing me.'",
"description": "",
"intro": "*You have entered the simulation suite. No simulation is currently active and you are in a non-descript space with paneled walls surrounding you. The control panel next to you is pulsating with a green light, indicating readiness to receive a prompt to start the simulation.*",
"archived_history": [],
"history": [],
"ts": "PT1S",
"characters": [
{
"name": "You",
"gender": "unknown",
"color": "cornflowerblue",
"base_attributes": {},
"is_player": true
}
],
"context": "a simulated experience",
"game_state": {
"ops":{
"run_on_start": true,
"always_direct": true
},
"variables": {}
},
"world_state": {
"character_name_mappings": {
"You": [
"user",
"player",
"player character",
"user character",
"the user",
"the player"
]
}
},
"assets": {
"cover_image": "4b157dccac2ba71adb078a9d591f9900d6d62f3e86168a5e0e5e1e9faf6dc103",
"assets": {
"4b157dccac2ba71adb078a9d591f9900d6d62f3e86168a5e0e5e1e9faf6dc103": {
"id": "4b157dccac2ba71adb078a9d591f9900d6d62f3e86168a5e0e5e1e9faf6dc103",
"file_type": "png",
"media_type": "image/png"
}
}
}
}

View File

@@ -0,0 +1,110 @@
<|SECTION:CONTEXT|>
{% set scene_history=scene.context_history(budget=1024) %}
{% for scene_context in scene_history -%}
{{ loop.index }}. {{ scene_context }}
{% endfor %}
<|CLOSE_SECTION|>
<|SECTION:FUNCTIONS|>
The player has instructed the computer to alter the current simulation.
You have access to the following functions, you can call as many as you want to fulfill the player's requests.
You must at least call one of the following functions:
- change_environment
- add_ai_character
- change_ai_character
- remove_ai_character
- set_player_persona
- set_player_name
- end_simulation
Set the player persona at the beginning of a new simulation or if the player requests a change.
Only end the simulation if the player requests it explicitly.
<|CLOSE_SECTION|>
<|SECTION:EXAMPLES|>
Request: Computer, I want to be on a mountain top
```simulation-stack
change_environment("mountain top")
set_player_persona("mountain climber")
set_player_name("Hank")
```
Request: Computer, I want to be more muscular and taller
```simulation-stack
set_player_persona("make player more muscular and taller")
```
Request: Computer, the building should be on fire
```simulation-stack
change_environment("building on fire")
```
Request: Computer, a rocket hits the building and George is now injured
```simulation-stack
change_environment("building on fire")
change_ai_character("George is injured")
```
Request: Computer, I want to experience a rollercoaster ride with a friend
```simulation-stack
change_environment("theme park, riding a rollercoaster")
set_player_persona("young female experiencing rollercoaster ride")
set_player_name("Susanne")
add_ai_character("a female friend of player")
```
Request: Computer, I want to experience the international space station
```simulation-stack
change_environment("international space station")
set_player_persona("astronaut experiencing first trip to ISS")
set_player_name("George")
add_ai_character("astronaut")
```
Request: Computer, remove the goblin and add an elven woman instead
```simulation-stack
remove_ai_character("goblin")
add_ai_character("elven woman named Elune")
```
Request: Computer, change the skiing instructor to be older.
```simulation-stack
change_ai_character("make skiing instructor older")
```
Request: Computer, change my grandma to my grandpa
```simulation-stack
remove_ai_character("grandma")
add_ai_character("grandpa")
```
Request: Computer, remove the skiing instructor and add my friend instead.
```simulation-stack
remove_ai_character("skiing instructor")
add_ai_character("player's friend")
```
Request: Computer, replace the skiing instructor with my friend.
```simulation-stack
remove_ai_character("skiing instructor")
add_ai_character("player's friend")
```
Request: Computer, I want to end the simulation
```simulation-stack
end_simulation("simulation ended")
```
Request: Computer, shut down the simulation
```simulation-stack
end_simulation("simulation ended")
```
<|CLOSE_SECTION|>
<|SECTION:TASK|>
Respond with the simulation stack for the following request:
Request: {{ player_instruction }}
{{ bot_token }}```simulation-stack

View File

@@ -0,0 +1,165 @@
{% set update_world_state = False %}
{% set _ = debug("HOLODECK SIMULATION") -%}
{% set player_character = scene.get_player_character() %}
{% set player_message = scene.last_player_message() %}
{% set last_processed = game_state.get_var('instr.last_processed', -1) %}
{% set player_message_is_instruction = (player_message and player_message.raw.lower().startswith("computer") and not player_message.hidden) and not player_message.raw.lower().strip() == "computer" and not last_processed >= player_message.id %}
{% set simulation_reset = False %}
{% if not game_state.has_var('instr.simulation_stopped') %}
{# simulation NOT started #}
{# get last player instruction #}
{% if player_message_is_instruction %}
{# player message exists #}
{#% set _ = agent_action("narrator", "action_to_narration", action_name="paraphrase", narration="The computer is processing the request, please wait a moment.", emit_message=True) %#}
{% set calls = render_and_request(render_template("computer", player_instruction=player_message.raw), dedupe_enabled=False) %}
{% set _ = debug("HOLODECK simulation calls", calls=calls ) %}
{% set processed = make_list() %}
{% for call in calls.split("\n") %}
{% set _ = debug("CALL", call=call, processed=processed) %}
{% set inject = "The computer executes the function `"+call+"`" %}
{% if call.strip().startswith('change_environment') %}
{# change environment #}
{% set _ = processed.append(call) %}
{% elif call.strip().startswith("set_player_persona") %}
{# treansform player #}
{% set _ = emit_status("busy", "Simulation suite altering user persona.", as_scene_message=True) %}
{% set character_attributes = agent_action("world_state", "extract_character_sheet", name=player_character.name, text=player_message.raw)%}
{% set _ = player_character.update(base_attributes=character_attributes) %}
{% set character_description = agent_action("creator", "determine_character_description", character=player_character) %}
{% set _ = player_character.update(description=character_description) %}
{% set _ = debug("HOLODECK transform player", attributes=character_attributes, description=character_description) %}
{% set _ = processed.append(call) %}
{% elif call.strip().startswith("set_player_name") %}
{# change player name #}
{% set _ = emit_status("busy", "Simulation suite adjusting user idenity.", as_scene_message=True) %}
{% set character_name = agent_action("creator", "determine_character_name", character_name=inject+" - What is a fitting name for the player persona? Respond with the current name if it still fits.") %}
{% set _ = debug("HOLODECK player name", character_name=character_name) %}
{% if character_name != player_character.name %}
{% set _ = processed.append(call) %}
{% set _ = player_character.rename(character_name) %}
{% endif %}
{% elif call.strip().startswith("add_ai_character") %}
{# add new npc #}
{% set _ = emit_status("busy", "Simulation suite adding character.", as_scene_message=True) %}
{% set character_name = agent_action("creator", "determine_character_name", character_name=inject+" - what is the name of the character to be added to the scene? If no name can extracted from the text, extract a short descriptive name instead. Respond only with the name.") %}
{% set _ = emit_status("busy", "Simulation suite adding character: "+character_name, as_scene_message=True) %}
{% set _ = debug("HOLODECK add npc", name=character_name)%}
{% set npc = agent_action("director", "persist_character", name=character_name, content=player_message.raw )%}
{% set _ = agent_action("world_state", "manager", action_name="add_detail_reinforcement", character_name=npc.name, question="Goal", instructions="Generate a goal for the character, based on the user's chosen simulation", interval=25, run_immediately=True) %}
{% set _ = debug("HOLODECK added npc", npc=npc) %}
{% set _ = processed.append(call) %}
{% elif call.strip().startswith("remove_ai_character") %}
{# remove npc #}
{% set _ = emit_status("busy", "Simulation suite removing character.", as_scene_message=True) %}
{% set character_name = agent_action("creator", "determine_character_name", character_name=inject+" - what is the name of the character being removed?", allowed_names=scene.npc_character_names) %}
{% set npc = scene.get_character(character_name) %}
{% if npc %}
{% set _ = debug("HOLODECK remove npc", npc=npc.name) %}
{% set _ = agent_action("world_state", "manager", action_name="deactivate_character", character_name=npc.name) %}
{% set _ = processed.append(call) %}
{% endif %}
{% elif call.strip().startswith("change_ai_character") %}
{# change existing npc #}
{% set _ = emit_status("busy", "Simulation suite altering character.", as_scene_message=True) %}
{% set character_name = agent_action("creator", "determine_character_name", character_name=inject+" - what is the name of the character receiving the changes?", allowed_names=scene.npc_character_names) %}
{% set npc = scene.get_character(character_name) %}
{% if npc %}
{% set _ = emit_status("busy", "Changing "+character_name, as_scene_message=True) %}
{% set _ = debug("HOLODECK transform npc", npc=npc) %}
{% set character_attributes = agent_action("world_state", "extract_character_sheet", name=npc.name, alteration_instructions=player_message.raw)%}
{% set _ = npc.update(base_attributes=character_attributes) %}
{% set character_description = agent_action("creator", "determine_character_description", character=npc) %}
{% set _ = npc.update(description=character_description) %}
{% set _ = debug("HOLODECK transform npc", attributes=character_attributes, description=character_description) %}
{% set _ = processed.append(call) %}
{% endif %}
{% elif call.strip().startswith("end_simulation") %}
{# end simulation #}
{% set explicit_command = query_text_eval("has the player explicitly asked to end the simulation?", player_message.raw) %}
{% if explicit_command %}
{% set _ = emit_status("busy", "Simulation suite ending current simulation.", as_scene_message=True) %}
{% set _ = agent_action("narrator", "action_to_narration", action_name="progress_story", narrative_direction="The computer ends the simulation, disolving the environment and all artifical characters, erasing all memory of it and finally returning the player to the inactive simulation suite.", emit_message=True) %}
{% set _ = scene.sync_restore() %}
{% set update_world_state = True %}
{% set simulation_reset = True %}
{% endif %}
{% elif "(" in call.strip() %}
{# unknown function call, still add it to processed stack so it can be incoorporated in the narration #}
{% set _ = processed.append(call) %}
{% endif %}
{% endfor %}
{% if processed and not simulation_reset %}
{% set _ = game_state.set_var("instr.has_issued_instructions", "yes", commit=False) %}
{% set _ = emit_status("busy", "Simulation suite altering environment.", as_scene_message=True) %}
{% set update_world_state = True %}
{% set _ = agent_action("narrator", "action_to_narration", action_name="progress_story", narrative_direction="The computer calls the following functions:\n"+processed.join("\n")+"\nand the simulation adjusts the environment according to the user's wishes. Write the narrative that describes the changes.", emit_message=True) %}
{% endif %}
{% elif not game_state.has_var("instr.simulation_started") %}
{# no player message yet, start of scenario #}
{% set _ = emit_status("busy", "Simulation suite powering up.", as_scene_message=True) %}
{% set _ = game_state.set_var("instr.simulation_started", "yes", commit=False) %}
{% set _ = agent_action("narrator", "action_to_narration", action_name="progress_story", narrative_direction="Narrate the computer asking the user to state the nature of their desired simulation.", emit_message=False) %}
{% set _ = agent_action("narrator", "action_to_narration", action_name="paraphrase", narration="Please state your commands by addressing the computer by stating \"Computer,\" followed by an instruction.") %}
{# pin to make sure characters don't try to interact with the simulation #}
{% set _ = agent_action("world_state", "manager", action_name="save_world_entry", entry_id="sim.quarantined", text="Characters in the simulation ARE NOT AWARE OF THE COMPUTER.", meta=make_dict(), pin=True) %}
{% set _ = emit_status("success", "Simulation suite ready", as_scene_message=True) %}
{% endif %}
{% else %}
{# simulation ongoing #}
{% endif %}
{% if update_world_state %}
{% set _ = emit_status("busy", "Simulation suite updating world state.", as_scene_message=True) %}
{% set _ = agent_action("world_state", "update_world_state", force=True) %}
{% endif %}
{% if not scene.npc_character_names and not simulation_reset %}
{# no characters in the scene, see if there are any to add #}
{% set npcs = agent_action("director", "persist_characters_from_worldstate", exclude=["computer", "user", "player", "you"]) %}
{% for npc in npcs %}
{% set _ = agent_action("world_state", "manager", action_name="add_detail_reinforcement", character_name=npc.name, question="Goal", instructions="Generate a goal for the character, based on the user's chosen simulation", interval=25, run_immediately=True) %}
{% endfor %}
{% if npcs %}
{% set _ = agent_action("world_state", "update_world_state", force=True) %}
{% endif %}
{% endif %}
{% if player_message_is_instruction %}
{# hide player message to the computer, so its not included in the scene context #}
{% set _ = player_message.hide() %}
{% set _ = game_state.set_var("instr.last_processed", player_message.id, commit=False) %}
{% set _ = emit_status("success", "Simulation suite processed instructions", as_scene_message=True) %}
{% elif player_message and not game_state.has_var("instr.has_issued_instructions") %}
{# simulation not started, but player message is not an instruction #}
{% set _ = agent_action("narrator", "action_to_narration", action_name="paraphrase", narration="Instructions to the simulation computer are only process if the computer is addressed at the beginning of the instruction. Please state your commands by addressing the computer by stating \"Computer,\" followed by an instruction. For example ... \"Computer, i want to experience being on a derelict spaceship.\"", emit_message=True) %}
{% elif player_message and not scene.npc_character_names %}
{# simulation started, player message is NOT an instruction, but there are no npcs to interact with #}
{% set _ = agent_action("narrator", "action_to_narration", action_name="progress_story", narrative_direction="The environment reacts to the player's actions. YOU MUST NOT ACT ON BEHALF OF THE PLAYER. YOU MUST NOT INTERACT WITH THE COMPUTER.", emit_message=True) %}
{% endif %}