diff --git a/libs/langchain/langchain/agents/load_tools.py b/libs/langchain/langchain/agents/load_tools.py index e464d6b728780..60377c137d056 100644 --- a/libs/langchain/langchain/agents/load_tools.py +++ b/libs/langchain/langchain/agents/load_tools.py @@ -142,7 +142,11 @@ def _get_llm_math(llm: BaseLanguageModel) -> BaseTool: def _get_open_meteo_api(llm: BaseLanguageModel) -> BaseTool: - chain = APIChain.from_llm_and_api_docs(llm, open_meteo_docs.OPEN_METEO_DOCS) + chain = APIChain.from_llm_and_api_docs( + llm, + open_meteo_docs.OPEN_METEO_DOCS, + limit_to_domains=["https://api.open-meteo.com/"], + ) return Tool( name="Open-Meteo-API", description="Useful for when you want to get weather information from the OpenMeteo API. The input should be a question in natural language that this API can answer.", @@ -159,7 +163,10 @@ def _get_open_meteo_api(llm: BaseLanguageModel) -> BaseTool: def _get_news_api(llm: BaseLanguageModel, **kwargs: Any) -> BaseTool: news_api_key = kwargs["news_api_key"] chain = APIChain.from_llm_and_api_docs( - llm, news_docs.NEWS_DOCS, headers={"X-Api-Key": news_api_key} + llm, + news_docs.NEWS_DOCS, + headers={"X-Api-Key": news_api_key}, + limit_to_domains=["https://newsapi.org/"], ) return Tool( name="News-API", @@ -174,6 +181,7 @@ def _get_tmdb_api(llm: BaseLanguageModel, **kwargs: Any) -> BaseTool: llm, tmdb_docs.TMDB_DOCS, headers={"Authorization": f"Bearer {tmdb_bearer_token}"}, + limit_to_domains=["https://api.themoviedb.org/"], ) return Tool( name="TMDB-API", @@ -188,6 +196,7 @@ def _get_podcast_api(llm: BaseLanguageModel, **kwargs: Any) -> BaseTool: llm, podcast_docs.PODCAST_DOCS, headers={"X-ListenAPI-Key": listen_api_key}, + limit_to_domains=["https://listen-api.listennotes.com/"], ) return Tool( name="Podcast-API",