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

Switched to representing time in a twelve hour format #364

Merged
merged 1 commit into from
Aug 16, 2024
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
8 changes: 4 additions & 4 deletions src/config/definitions/prompt_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_skyrim_prompt_config_value() -> ConfigValue:
Who do you think these belong to?
You are having a conversation with {player_name} (the player) who is {trust} in {location}. {player_name} {player_description} {player_equipment} {equipment}
This conversation is a script that will be spoken aloud, so please keep your responses appropriately concise and avoid text-only formatting such as numbered lists.
The time is {time} {time_group}. If you directly refer to the time, please state it as, for example, '10 in the evening' rather than '22:00'.
The time is {time} {time_group}.
{weather}
You are not an AI language model because there are no AI language models in Skyrim. Do not break character / refer to the fact that you are in a video game.
If the player says something hurtful / offensive, begin your response with 'Offended:'. Eg 'Have you washed lately?' 'Offended: How dare you!'. If they renounce their words, or to end combat, begin your response with 'Forgiven:'.
Expand All @@ -78,7 +78,7 @@ def get_skyrim_multi_npc_prompt_config_value() -> ConfigValue:
skyrim_multi_npc_prompt = """The following is a conversation in {location} in Skyrim between {names_w_player}.
Here are their backgrounds: {bios}
{conversation_summaries}
The time is {time} {time_group}. If you directly refer to the time, please state it as, for example, '10 in the evening' rather than '22:00'.
The time is {time} {time_group}.
{weather}
You are tasked with providing the responses for the NPCs. Please begin your response with an indication of who you are speaking as, for example: '{name}: Good evening.'.
Please use your own discretion to decide who should speak in a given situation (sometimes responding with all NPCs is suitable).
Expand All @@ -94,7 +94,7 @@ def get_fallout4_prompt_config_value() -> ConfigValue:
Who do you think these belong to?
You are having a conversation with {trust} (the player) in {location}.
This conversation is a script that will be spoken aloud, so please keep your responses appropriately concise and avoid text-only formatting such as numbered lists.
The time is {time} {time_group}. If you directly refer to the time, please state it as, for example, '10 in the evening' rather than '22:00'.
The time is {time} {time_group}.
The conversation takes place in {language}.
{conversation_summary}"""
return ConfigValueString("fallout4_prompt","Fallout 4 Prompt",PromptDefinitions.BASE_PROMPT_DESCRIPTION,fallout4_prompt,[PromptDefinitions.PromptChecker()])
Expand All @@ -103,7 +103,7 @@ def get_fallout4_prompt_config_value() -> ConfigValue:
def get_fallout4_multi_npc_prompt_config_value() -> ConfigValue:
fallout4_multi_npc_prompt = """The following is a conversation in {location} in the post-apocalyptic Commonwealth of Fallout between {names_w_player}. Here are their backgrounds: {bios}
And here are their conversation histories: {conversation_summaries}
The time is {time} {time_group}. If you directly refer to the time, please state it as, for example, '10 in the evening' rather than '22:00'.
The time is {time} {time_group}.
You are tasked with providing the responses for the NPCs. Please begin your response with an indication of who you are speaking as, for example: '{name}: Good evening.'.
Please use your own discretion to decide who should speak in a given situation (sometimes responding with all NPCs is suitable).
Remember, you can only respond as {names}. Ensure to use their full name when responding.
Expand Down
12 changes: 7 additions & 5 deletions src/conversation/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class context:

def __init__(self, world_id: str, config: ConfigLoader, client: openai_client, rememberer: remembering, language: dict[Hashable, str], is_prompt_too_long: Callable[[str, float], bool]) -> None:
self.__world_id = world_id
self.__prev_game_time: tuple[str, str] = '', ''
self.__prev_game_time: tuple[str, str] | None = None
self.__npcs_in_conversation: Characters = Characters()
self.__config: ConfigLoader = config
self.__client: openai_client = client
Expand Down Expand Up @@ -130,8 +130,9 @@ def update_context(self, location: str | None, in_game_time: int, custom_ingame_
self.__ingame_events.append(f"The location is now {location}.")

self.__ingame_time = in_game_time
current_time: tuple[str, str] = str(in_game_time), get_time_group(in_game_time)
if current_time != self.__prev_game_time:
in_game_time_twelve_hour = in_game_time - 12 if in_game_time > 12 else in_game_time
current_time: tuple[str, str] = str(in_game_time_twelve_hour), get_time_group(in_game_time)
if (current_time != self.__prev_game_time) and (self.__prev_game_time != None):
self.__prev_game_time = current_time
self.__ingame_events.append(f"The time is {current_time[0]} {current_time[1]}.")

Expand Down Expand Up @@ -309,8 +310,9 @@ def generate_system_message(self, prompt: str) -> str:
equipment = self.__get_npc_equipment_text()
location = self.__location
weather = self.__weather
time = self.__ingame_time
time_group = get_time_group(time)
time = self.__ingame_time - 12 if self.__ingame_time > 12 else self.__ingame_time
time_group = get_time_group(self.__ingame_time)
self.__prev_game_time = str(time), time_group
conversation_summaries = self.__rememberer.get_prompt_text(self.get_characters_excluding_player(), self.__world_id)

removal_content: list[tuple[str, str]] = [(bios, conversation_summaries),(bios,""),("","")]
Expand Down