Update app.py
Browse files
app.py
CHANGED
@@ -168,7 +168,6 @@ def get_ai_response(suspect_name, player_input):
|
|
168 |
hot_headed = suspect["hot_headed"]
|
169 |
trust_level = suspect["trust_level"]
|
170 |
previous_questions = " ".join(game_state["player_questions"][-3:])
|
171 |
-
clues_found = " ".join(game_state["clues"])
|
172 |
system_prompt = f"You are {suspect_name}, who is {personality}. {knowledge}"
|
173 |
for other_name, info in others_knowledge.items():
|
174 |
system_prompt += f" You know that {other_name} {info}"
|
@@ -236,17 +235,12 @@ def process_input(player_input, selected_suspects):
|
|
236 |
suspect_name = selected_suspects[0]
|
237 |
ai_response = get_ai_response(suspect_name, player_input)
|
238 |
game_state["history"].append((suspect_name, ai_response))
|
239 |
-
extract_clues(ai_response)
|
240 |
return ai_response, game_state["history"]
|
241 |
else:
|
242 |
ai_response = get_group_response(selected_suspects, player_input)
|
243 |
game_state["history"].append(("Group", ai_response))
|
244 |
-
extract_clues(ai_response)
|
245 |
return ai_response, game_state["history"]
|
246 |
|
247 |
-
def extract_clues(ai_response):
|
248 |
-
pass
|
249 |
-
|
250 |
def search_location(location):
|
251 |
if location not in locations:
|
252 |
return "That location does not exist."
|
@@ -256,7 +250,6 @@ def search_location(location):
|
|
256 |
game_state["turns"] += 1
|
257 |
if location == game_state["location"]:
|
258 |
found_weapon = f"You found the {game_state['weapon']}!"
|
259 |
-
game_state["clues"].append(found_weapon)
|
260 |
return f"You search the {location} and {found_weapon}"
|
261 |
else:
|
262 |
return f"You search the {location} but find nothing of interest."
|
@@ -268,7 +261,6 @@ def eavesdrop():
|
|
268 |
game_state["turns"] += 1
|
269 |
suspect1, suspect2 = random.sample(suspect_names, 2)
|
270 |
conversation = f"{suspect1} whispers to {suspect2}: 'I think {suspects[suspect1]['suspects']} might be involved. They had a motive because of {suspects[suspects[suspect1]['suspects']]['motive']}.'"
|
271 |
-
extract_clues(conversation)
|
272 |
return f"You overhear a conversation: {conversation}"
|
273 |
|
274 |
def bluff(player_input):
|
@@ -374,19 +366,30 @@ with gr.Blocks() as demo:
|
|
374 |
with gr.TabItem("Game"):
|
375 |
with gr.Row():
|
376 |
with gr.Column():
|
377 |
-
gr.Markdown("## Instructions")
|
378 |
-
gr.Markdown("- **Ask a question**: Type your question.")
|
379 |
-
gr.Markdown("- **Select Suspects**: Click on the suspects you want to question.")
|
380 |
-
gr.Markdown("- **Other Actions**: Type commands like *\"Search [Location]\"*, *\"Eavesdrop\"*, *\"Bluff [Suspect]\"*, *\"Analyze\"*, *\"Reveal: [Your deductions]\"*, or include *\"accuse\"* to make an accusation.")
|
381 |
suspect_selection = gr.CheckboxGroup(choices=suspect_names, label="Select Suspects to Question")
|
382 |
player_input = gr.Textbox(lines=1, label="Your Input")
|
383 |
send_button = gr.Button("Send")
|
384 |
restart_button = gr.Button("Restart Game")
|
385 |
chatbox = gr.Textbox(lines=20, label="Chat History", interactive=False)
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
def send_message(player_input, selected_suspects):
|
392 |
chat_history = chat_interface(player_input, selected_suspects)
|
|
|
168 |
hot_headed = suspect["hot_headed"]
|
169 |
trust_level = suspect["trust_level"]
|
170 |
previous_questions = " ".join(game_state["player_questions"][-3:])
|
|
|
171 |
system_prompt = f"You are {suspect_name}, who is {personality}. {knowledge}"
|
172 |
for other_name, info in others_knowledge.items():
|
173 |
system_prompt += f" You know that {other_name} {info}"
|
|
|
235 |
suspect_name = selected_suspects[0]
|
236 |
ai_response = get_ai_response(suspect_name, player_input)
|
237 |
game_state["history"].append((suspect_name, ai_response))
|
|
|
238 |
return ai_response, game_state["history"]
|
239 |
else:
|
240 |
ai_response = get_group_response(selected_suspects, player_input)
|
241 |
game_state["history"].append(("Group", ai_response))
|
|
|
242 |
return ai_response, game_state["history"]
|
243 |
|
|
|
|
|
|
|
244 |
def search_location(location):
|
245 |
if location not in locations:
|
246 |
return "That location does not exist."
|
|
|
250 |
game_state["turns"] += 1
|
251 |
if location == game_state["location"]:
|
252 |
found_weapon = f"You found the {game_state['weapon']}!"
|
|
|
253 |
return f"You search the {location} and {found_weapon}"
|
254 |
else:
|
255 |
return f"You search the {location} but find nothing of interest."
|
|
|
261 |
game_state["turns"] += 1
|
262 |
suspect1, suspect2 = random.sample(suspect_names, 2)
|
263 |
conversation = f"{suspect1} whispers to {suspect2}: 'I think {suspects[suspect1]['suspects']} might be involved. They had a motive because of {suspects[suspects[suspect1]['suspects']]['motive']}.'"
|
|
|
264 |
return f"You overhear a conversation: {conversation}"
|
265 |
|
266 |
def bluff(player_input):
|
|
|
366 |
with gr.TabItem("Game"):
|
367 |
with gr.Row():
|
368 |
with gr.Column():
|
|
|
|
|
|
|
|
|
369 |
suspect_selection = gr.CheckboxGroup(choices=suspect_names, label="Select Suspects to Question")
|
370 |
player_input = gr.Textbox(lines=1, label="Your Input")
|
371 |
send_button = gr.Button("Send")
|
372 |
restart_button = gr.Button("Restart Game")
|
373 |
chatbox = gr.Textbox(lines=20, label="Chat History", interactive=False)
|
374 |
+
with gr.TabItem("Instructions"):
|
375 |
+
gr.Markdown("## How to Play")
|
376 |
+
gr.Markdown("""
|
377 |
+
- **Ask a Question**: Type your question in the input box.
|
378 |
+
- **Select Suspects**: Choose one or more suspects to question by selecting them.
|
379 |
+
- If you select multiple suspects, they will be questioned as a group.
|
380 |
+
- **Other Actions**:
|
381 |
+
- **Search a Location**: Type `"Search [Location]"` to search a room for clues.
|
382 |
+
- **Eavesdrop on Suspects**: Type `"Eavesdrop"` to overhear conversations.
|
383 |
+
- **Bluff a Suspect**: Type `"Bluff [Suspect]"` to try and trick a suspect into revealing information.
|
384 |
+
- **Analyze a Response**: Type `"Analyze"` to attempt to detect lies.
|
385 |
+
- **Reveal Your Deductions**: Type `"Reveal: [Your deductions]"` to present your findings before accusing.
|
386 |
+
- **Make an Accusation**: Include the word `"accuse"` in your statement to accuse a suspect.
|
387 |
+
- **Note**: Be careful with your actions; they may affect suspects' trust and anger levels.
|
388 |
+
""")
|
389 |
+
with gr.TabItem("Debug"):
|
390 |
+
debug_info = gr.Textbox(lines=30, label="Debug Information", interactive=False)
|
391 |
+
update_debug_button = gr.Button("Update Debug Info")
|
392 |
+
update_debug_button.click(fn=lambda: get_debug_info(), inputs=None, outputs=debug_info)
|
393 |
|
394 |
def send_message(player_input, selected_suspects):
|
395 |
chat_history = chat_interface(player_input, selected_suspects)
|