def get_google_trends_for_query(
    query: str, find_related: bool = False, region: str = ""
) -> Optional[pd.DataFrame]:
    """Find google search trends for a given query filtered by region if provided."""
    try:
        pytrend = TrendReq()
        # 12 is the category for Business and Industrial which covers most of the related
        # topics related to fin-gpt
        # Ref: https://github.com/pat310/google-trends-api/wiki/Google-Trends-Categories

        # Only search for last 30 days from now
        pytrend.build_payload(
            kw_list=[query], timeframe="today 1-m", geo=region, cat=12
        )
        return pytrend.interest_over_time()
    except Exception as e:
        print(f"Unable to find google trend for {query}, error: {e}")
        return None
Find google search trends for a given query filtered by region if provided.
llama-index-integrations/tools/llama-index-tools-finance/llama_index/tools/finance/news.py