def _parse_response()

in src/psearch/gen_ai/services/conversational_search_service.py [0:0]


    def _parse_response(self, response_text: str) -> Dict[str, Any]:
        """Parse the response from the Gemini model"""
        try:
            # Try to parse the response as JSON
            response_json = json.loads(response_text)
            return response_json
        except json.JSONDecodeError:
            # If JSON parsing fails, extract what we can
            logger.warning(f"Failed to parse response as JSON: {response_text}")

            # Return a simple structure
            return {
                "greeting": "I can help you find what you're looking for.",
                "filter_questions": [],
                "filter_mappings": [],
            }