Spaces:
Sleeping
Sleeping
Update app.py
Browse files2 unmodified lines345678910111213141516171819202122232425262728293031323334353637382 unmodified linesimport requestsimport pytzimport yamlimport osfrom youtube_transcript_api import YouTubeTranscriptApiimport refrom tools.final_answer import FinalAnswerToolfrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity !@tooldef get_video_transcript(url: str) -> str:"""Returns the transcript text of a give YouTube video URL.Args:url: YouTube video url given by a user."""try:video_id = extract_video_id(url)transctipt = YouTubeTranscriptApi.get_transcript(video_id)text = " ".join([entry["text"] for entry in transctipt])return textexcept Exception as e:return f"Error: {str(e)}"def extract_video_id(url: str) -> str:match = re.search(r"(?:v=|youtu\.be/)([^&\n?#]+)", url)if match:return match.grou(1)else:raise ValueError("Invalid YouTube URL.")@tooldef get_current_time_in_timezone(timezone: str) -> str:2 unmodified lines345678910111213141516171819202122232425262728293031323334353637383940414243442 unmodified linesimport requestsimport pytzimport yamlfrom tools.final_answer import FinalAnswerToolfrom Gradio_UI import GradioUI# Below is an example of a tool that does nothing. Amaze us with your creativity !OMDB_API_KEY = "a08b4599"@tooldef get_movies_by_mood(mood: str) -> str:"""Suggests up to 5 movies based on the user's mood using OMDb API."""mood_keywords = {"happy": "comedy","sad": "drama","romantic": "romance","inspired": "biography","bored": "action","stressed": "family","excited": "adventure","lonely": "friendship"}keyword = next((v for k, v in mood_keywords.items() if k in mood.lower()), "drama")search = requests.get(f"http://www.omdbapi.com/?s={keyword}&apikey={OMDB_API_KEY}&type=movie").json()if "Search" in search:movies = []for movie in search["Search"][:5]:info = requests.get(f"http://www.omdbapi.com/?i={movie['imdbID']}&apikey={OMDB_API_KEY}").json()title = info.get("Title", "Unknown")year = info.get("Year", "N/A")plot = info.get("Plot", "No plot available.")movies.append(f"{title} ({year}): {plot}")return "\n\n".join(movies)return "Couldn't find movies matching your mood. Try again!"@tooldef get_current_time_in_timezone(timezone: str) -> str:
app.py+28-22