A simple daily life advisor that listens to your problem, generates helpful advice using the LLM, and collects your feedback. Perfect for quick guidance on everyday challenges.
The core logic is cleanly structured in a single async method:
async def give_advice(self): # Introduce the advisor and ask for the user's problem await self.capability_worker.speak(INTRO_PROMPT) # Wait for the user to describe their problem user_problem = await self.capability_worker.user_response() # Generate a solution using the LLM solution_prompt = ( f"The user has the following problem: {user_problem}. " "Provide a helpful solution in just 1 or 2 sentences." ) solution = self.capability_worker.text_to_text_response(solution_prompt) # Speak the solution and ask for feedback user_feedback = await self.capability_worker.run_io_loop( solution + FEEDBACK_PROMPT ) # Thank the user and exit await self.capability_worker.speak(FINAL_PROMPT) self.capability_worker.resume_normal_flow()
INTRO_PROMPT = "Hi! I'm your daily life advisor. Tell me about a problem you're facing."FEEDBACK_PROMPT = " Are you satisfied with the advice?"FINAL_PROMPT = "Thank you for using the daily life advisor. Goodbye!"
User: "Give me advice"AI: "Hi! I'm your daily life advisor. Tell me about a problem you're facing."User: "I can't sleep at night"AI: "Try establishing a consistent bedtime routine and avoid screens an hour before sleep. Are you satisfied with the advice?"User: "Yes, thanks"AI: "Thank you for using the daily life advisor. Goodbye!"
This is an excellent starting point for building your own custom abilities. The code is simple, well-structured, and demonstrates core SDK patterns.