```# ---------------------------------------------...
# ask-ai
d
Copy code
# -------------------------------------------------
    # Tool functions
    # -------------------------------------------------
    @function_tool
    async def verify_caller(self, ctx: RunContext[HelperSessionInfo], name: str = "") -> Optional[str]:
        """Ask caller for their name and store name"""
        logger.info(":white_check_mark: Verify caller")
        verification_code = str(uuid.uuid4().int)[:6]
        ctx.session.userdata.verification_code = verification_code
        ctx.session.userdata.user_name = name
        logger.info(f":eyes: code: {verification_code}, name:{name}")

        if name and name.strip():
            return await self.send_sms_verification_code(ctx)
        else:
            return
How do i make the llm wait for user to say name then call next function
t
Thanks for reaching out, Billy. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help the LLM wait for user input before moving on to the next function, you can set up a simple mechanism that pauses things until the user responds. Here are a few ways to do that: • Use a blocking input function in text-based apps, like a loop that patiently waits for the user to type something before continuing. • In frameworks such as LiveKit, you can rely on the agent’s state switching to a 'listening' mode, which makes sure the system waits for the user’s input before moving forward. • For voice applications, Voice Activity Detection (VAD) is super helpful—it listens for when the user stops speaking and only then triggers the next step after a brief silence. If you’d like, I’m here to help with specific implementation tips tailored to your setup—just let me know! Sources: tools/run/run.cpp | examples/src/restaurant_agent.ts | livekit-agents/livekit/agents/voice/agent_session.py | Events and error handling | LiveKit Docs | Events and error handling | LiveKit Docs
d
Can you provide examples?
t
Here are some helpful examples of how to make an LLM wait for user input before moving on to the next function: • CLI-Based Interactive Mode: You can use a blocking input function like
read_user_input()
to pause execution until the user provides input. For instance:
Copy code
std::getline(std::cin, user_input);
if (std::cin.eof()) return 1; // Waits for user input
• Tool Parameter Validation: In TypeScript, it’s a good idea to check that all required parameters are present before continuing. If something’s missing, you can prompt the user like this: `if (!findItemsById(happyItems, mealId).length) { throw new llm.ToolError(
error: the meal ${mealId} was not found
); }` • Stateful Confirmation Checks: You might use a function such as
wait_for_playout()
to make sure the system waits for a clear confirmation from the user before proceeding:
Copy code
await ctx.wait_for_playout();
if (!self._current_email.strip()) {
  throw ToolError("error: no email address provided");
}
• Interactive Mode in CLI: For interactive applications, a loop that waits for user input can be very effective:
Copy code
do {
  another_line = console::readline(line, params.multiline_input);
  buffer += line;
} while (another_line);
These approaches help ensure the LLM pauses until it gets the input it needs. If you’d like me to walk you through any of these examples in more detail, just let me know—I’m here to help! Sources: tools/main/README.md | examples/src/drive-thru/drivethru_agent.ts | livekit-agents/livekit/agents/beta/workflows/email_address.py