def analyze()

in gemini/agents/research-multi-agents/ev_agent/agent_handler/agent_03_QueryAnalysisAgent.py [0:0]


    def analyze(self, query: str) -> dict:
        if not self.debug:
            rich_print(
                "[bold yellow]â„šī¸ Warning: Deciphering your cryptic commands!  It's like translating ancient hieroglyphs, but with more emojis.  Curious about my interpretations? debug=True reveals all! (And if you want to see the output of each agent stage, set stage_output=True!) 🤔📜 [/bold yellow]"
            )

        if self.debug:
            print_executing("Starting analysis...")

        try:
            # Extract entities
            entities = self._extract_entities(query)
            if self.debug:
                print_planning(f"Found a {entities.pattern_type} pattern! đŸŽ¯")

            # Validate cities and states
            if not entities.cities:
                raise ValueError(
                    "No cities mentioned in query. Please specify the city."
                )

            if (
                entities.pattern_type == PatternType.COMPARISON
                and len(entities.cities) < 2
            ):
                raise ValueError(
                    "Comparison requires at least two cities. Please mention both cities."
                )

            if self.debug:
                print_executing(f"Analyzing {', '.join(entities.cities)} 🔄")
                print_info(f"States involved: {', '.join(entities.states)}")

            result = {
                "status": "success",
                "entities": entities.model_dump(),
            }

            if self.debug:
                print_debug("Analysis completed successfully! 🎉")
            return result

        except Exception as e:
            if self.debug:
                print_debug(f"Error in analysis: {str(e)}")
            return {"status": "error", "message": str(e)}