Spaces:
Sleeping

byte-vortex commited on
Commit
7d3ff23
·
verified ·
1 Parent(s): 85b0b1b

Deploy Myco from CI

Browse files
Files changed (1) hide show
  1. game/engine.py +21 -9
game/engine.py CHANGED
@@ -692,24 +692,36 @@ def eat_current(current=None, collection=None, history=None):
692
  return coll, _append(hist, "assistant", reply)
693
 
694
 
695
- # Updated get_myco_narrative to use the real engine
 
696
  def get_myco_narrative(current=None):
697
- # This prompt tells the AI to be a character, not a tool
698
  prompt = (
699
  "You are Myco, a tiny, emotional mushroom companion. "
700
- "Don't give me JSON or game data. "
701
- "Speak to me in a whimsical, slightly mysterious way about the forest. "
702
- "Be warm, curious, or a little nervous."
703
  )
704
 
705
- # We pass the 'current' mushroom context so the AI actually
706
- # knows what it's looking at, but we tell it NOT to output JSON.
707
  context = {}
708
  if current:
709
  context = {"name": current.get("name"), "rarity": current.get("rarity")}
710
 
711
- # Use your powerful _llm function, but with the 'chat' personality
712
  reply = _llm(prompt, context=context)
713
 
714
- return reply if reply else "The forest feels deep today... ✨"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
 
 
692
  return coll, _append(hist, "assistant", reply)
693
 
694
 
695
+ # Myco narrative
696
+
697
  def get_myco_narrative(current=None):
698
+ # 1. Personality Prompt
699
  prompt = (
700
  "You are Myco, a tiny, emotional mushroom companion. "
701
+ "Write a whimsical, mysterious thought about the forest. "
702
+ "DO NOT use JSON. Do NOT use action tags. Just speak naturally."
 
703
  )
704
 
 
 
705
  context = {}
706
  if current:
707
  context = {"name": current.get("name"), "rarity": current.get("rarity")}
708
 
709
+ # 2. Get the response
710
  reply = _llm(prompt, context=context)
711
 
712
+ # 3. CRITICAL: Aggressive Clean-up
713
+ # If the LLM ignored our "no JSON" instruction, we parse it ourselves.
714
+ if reply:
715
+ # If it's wrapped in JSON, extract the 'thought'
716
+ if reply.strip().startswith("{"):
717
+ try:
718
+ data = json.loads(reply)
719
+ return data.get("thought", "The forest feels deep today... ✨")
720
+ except:
721
+ pass # If it's broken JSON, just return the reply
722
+
723
+ # If it's just raw text, return it
724
+ return reply
725
+
726
+ return "The forest feels deep today... ✨"
727