From 740eafe41da7317f42387bdfe6d0f1f521f2cafd Mon Sep 17 00:00:00 2001 From: Ansil M B Date: Wed, 20 Sep 2023 05:34:06 +0530 Subject: [PATCH] Updated return parameter of YouTubeSearchTool (#10743) **Description:** changed return parameter of YouTubeSearchTool 1. changed the returning links of youtube videos by adding prefix "https://www.youtube.com", now this will return the exact links to the videos 2. updated the returning type from 'string' to 'list', which will be more suited for further processings **Issue:** Fixes #10742 **Dependencies:** None --------- Co-authored-by: Harrison Chase --- libs/langchain/langchain/tools/youtube/search.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/tools/youtube/search.py b/libs/langchain/langchain/tools/youtube/search.py index 310eb37aa0..4b996359a1 100644 --- a/libs/langchain/langchain/tools/youtube/search.py +++ b/libs/langchain/langchain/tools/youtube/search.py @@ -32,7 +32,9 @@ class YouTubeSearchTool(BaseTool): results = YoutubeSearch(person, num_results).to_json() data = json.loads(results) - url_suffix_list = [video["url_suffix"] for video in data["videos"]] + url_suffix_list = [ + "https://www.youtube.com" + video["url_suffix"] for video in data["videos"] + ] return str(url_suffix_list) def _run(