generate_path_introduction
Generate narrative introductions for reincarnation paths in interactive storytelling, setting the stage for personalized adventures based on user choices.
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-295 (handler)The handler function for the generate_path_introduction tool. It retrieves the user state, checks prerequisites, generates a prompt using path_introduction_prompt, updates the state, and returns a formatted response with the prompt for AI generation.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. """ @mcp.tool()
- main.py:128-161 (helper)Supporting prompt function that generates the detailed prompt template for the path introduction narrative, incorporating path info and user answers. Used within the handler.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: