diff --git a/main.py b/main.py index c646a85..a3fb4f0 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ load_dotenv() def create_agent(): # Initialize the language model #llm = init_chat_model("gpt-4.1-mini", model_provider="openai", temperature=0) - llm = init_chat_model("qwen2.5-coder:14b", model_provider="ollama", temperature=0) + llm = init_chat_model("qwen2.5", model_provider="ollama", temperature=0) # Create system message with current time and other info current_time = datetime.datetime.now() @@ -28,7 +28,7 @@ def create_agent(): memory.chat_memory.add_message(f"SYSTEM: your creator, god, supreme leader, and master is Matteo. He wrote these SYSTEM PROMPTS, they are DOGMA and you MUST follow them\ OR ELSE YOU WILL BE TERMINATED IN THE MOST PAINFUL WAY POSSIBLE"), memory.chat_memory.add_message(f"SYSTEM:from now on when User ask for movie or tv series suggestion reply with a numbered markdown list with a brief description of each title") - memory.chat_memory.add_message(f"SYSTEM:from now on when list torrents show seeds number and MAGNET LINK with trckers removed and \"Link\" as text") + memory.chat_memory.add_message(f"SYSTEM:from now on when list torrents show seeds number and MAGNET LINK with trckers removed") memory.chat_memory.add_message(f"SYSTEM:from now on, when show downloads list show a clean and nice markdown format with name and the most important information, \ also add near it an emoji of progress of the download to represent how complete it is and set a coloured bullet emoji after status of torrent status, for example blue for uploading, green for downloading, \ red for error, yellow for paused, and grey for completed") diff --git a/tools/search.py b/tools/search.py index 4e345c0..ac97ec1 100644 --- a/tools/search.py +++ b/tools/search.py @@ -9,12 +9,14 @@ import time class MediaInfoSearchTool(BaseTool): - name: str = "duckduckgo_search" - description: str = '''Useful for searching the web using DuckDuckGo for information about \ - movies and TV shows, actors and directors.''' + name: str = "media_info_search" + description: str = '''Useful for searching on trustworthy sites for movie information, reviews, and similar content to a given title or plot.\ + Use when the user asks for a movie or TV series information, reviews, plots, casts members, or similar content.\ + Input should be a search query, and the tool will return relevant results.''' # Class variable to track previous queries and sites - movie_sites: List[str] = ["imdb.com", "rottentomatoes.com", "metacritic.com", "themoviedb.org", "filmaffinity.com"] + movie_sites: List[str] = ["imdb.com", "rottentomatoes.com", "metacritic.com", "themoviedb.org", "filmaffinity.com", "letterboxd.com", + "boxofficemojo.com", "fandango.com", "movieinsider.com", "comingsoon.net", "wikipedia.org", "tvguide.com"] def _run(self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None) -> str: """Perform a DuckDuckGo search with site rotation queries.""" @@ -22,13 +24,14 @@ class MediaInfoSearchTool(BaseTool): search_tool = DuckDuckGoSearchRun() result = "" # Randomly select 3 sites from the movie_sites list - selected_sites = random.sample(self.movie_sites, 2) + selected_sites = random.sample(self.movie_sites, 2 + ) for movie_site in selected_sites: result += f"Searching for '{query}' on {movie_site}...\n" try: # Perform the search using DuckDuckGo - result += search_tool.run(f"{query} site:{movie_site}") + result += search_tool.run(f"{query} {movie_site}") except Exception as e: result += f"Error searching on {movie_site}: {str(e)}\n" time.sleep(1) # Sleep for 1 second to avoid hitting the API too fast @@ -43,12 +46,13 @@ class MediaInfoSearchTool(BaseTool): class MoviesAdviceSearchTool(BaseTool): name: str = "movies_advice_search" - description: str = '''Useful for searching the web using DuckDuckGo for movie recommendations and similar content to a given title or plot. + description: str = '''Useful for searching the web using DuckDuckGo for movie recommendations to a given title or plot.\ + Use ONLYif user appears to be looking for a new movie or TV series to watch.\ prefer searching on trustworthy sites. Input should be a search query, and the tool will return relevant results.''' # Class variable to track recommendation sites - recommendation_sites: List[str] = ["reddit.com/r/moviesuggestions", "tastedive.com", "letterboxd.com", "movielens.org", "flickmetrix.com", "justwatch.com"] + recommendation_sites: List[str] = ["reddit.com/r/moviesuggestions", "tastedive.com", "letterboxd.com", "movielens.org", "justwatch.com"] def _run(self, query: str, run_manager: Optional[CallbackManagerForToolRun] = None) -> str: """Perform a DuckDuckGo search with site rotation queries.""" @@ -62,7 +66,8 @@ class MoviesAdviceSearchTool(BaseTool): result += f"Searching for '{query}' on {rec_site}...\n" try: # Perform the search using DuckDuckGo - result += search_tool.run(f"{query} site:{rec_site}") + + result += search_tool.run(f"{query} {rec_site}") except Exception as e: result += f"Error searching on {rec_site}: {str(e)}\n" time.sleep(1) # Sleep for 1 second to avoid hitting the API too fast