generate_path_introduction
Generate personalized narrative introductions for reincarnation paths, setting the stage for interactive storytelling adventures based on user choices and character transformations.
Instructions
Generate the introduction narrative for the chosen path
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes |
Implementation Reference
- main.py:268-294 (handler)The core handler function for the MCP tool 'generate_path_introduction'. It checks user state, generates a personalized introduction prompt using a helper prompt function, updates the story state, and returns a formatted response containing the prompt for the AI to generate the narrative.def generate_path_introduction(user_id: str) -> str: """Generate the introduction narrative for the chosen path""" state = get_user_state(user_id) if not state["story_started"]: return "Please start the story first by typing 'Arise'." if not state["current_path"]: return "Please choose a reincarnation path first." # This prompt will be used by the AI to generate the introduction intro_prompt = str(path_introduction_prompt( state["current_path"], state["user_answers"] )) state["current_context"] = f"Beginning of {state['current_path']} journey" state["story_step"] = 1 return f""" INTRODUCTION PROMPT READY: {intro_prompt} The AI will now generate your personalized introduction to the {state['current_path']} path based on your answers to the guidance questions. After the introduction, you'll find yourself in your new life with three choices before you. """
- main.py:128-160 (helper)Supporting prompt generator function used by the tool handler to create the detailed prompt for generating the path introduction narrative, incorporating path-specific info and user answers.def path_introduction_prompt(path: str, user_answers: Dict[str, str]) -> str: """Generate an introduction narrative when a path is chosen""" path_info = { "revenge": { "name": "Path of Vengeance", "description": "Returning to the same world with new powers to take revenge" }, "bilbo": { "name": "There and Back Again", "description": "Becoming Bilbo Baggins in Middle-earth" }, "luffy": { "name": "King of the Pirates", "description": "Becoming Monkey D. Luffy in the world of One Piece" } } return f""" Generate an introduction narrative for a reincarnation story. PATH: {path_info[path]['name']} - {path_info[path]['description']} USER'S ANSWERS TO GUIDANCE QUESTIONS: {json.dumps(user_answers, indent=2)} INSTRUCTIONS: 1. Write a compelling introduction where the user is reborn into their chosen path 2. Incorporate their answers to the three questions to personalize the narrative 3. Set the scene authentically according to the source material 4. End with the character in a situation that requires their first decision 5. Write in third person narrative style 6. Maximum 250 words INTRODUCTION NARRATIVE: """
- main.py:268-268 (registration)The @mcp.tool() decorator registers this function as an MCP tool named 'generate_path_introduction'.def generate_path_introduction(user_id: str) -> str: