process_user_input
Process user choices to generate personalized reincarnation story paths, allowing players to become characters like vengeful spirits or fantasy heroes based on their decisions.
Instructions
Process user input and generate narrative response with options
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_id | Yes | ||
| user_input | Yes |
Implementation Reference
- main.py:295-337 (handler)The core handler function for the process_user_input MCP tool. It manages story state, generates prompts for narrative continuation and next options based on user input.@mcp.tool() def process_user_input(user_id: str, user_input: str) -> str: """Process user input and generate narrative response with options""" 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." # Generate narrative based on user input narrative_prompt = str(generate_narrative_prompt( user_input=user_input, path=state["current_path"], step=state["story_step"], previous_context=state["current_context"] )) # Update context for next iteration state["current_context"] = f"Step {state['story_step']}: {user_input[:100]}..." state["story_step"] += 1 state["choices_made"].append(user_input) # Generate options for next step options_prompt = str(generate_options_prompt( current_narrative=f"User's action: {user_input}. Context: {state['current_context']}", path=state["current_path"], step=state["story_step"], previous_choices=state["choices_made"][-3:] # Last 3 choices )) return f""" NARRATIVE GENERATION PROMPT: {narrative_prompt} After the narrative is generated, use this prompt to create three options: OPTIONS GENERATION PROMPT: {options_prompt} The AI will now generate the next part of your story based on your input: "{user_input}" """