# Function to force DuckDuckGo for specific search types
)
defforced_duckduckgo_search(query:str)->str:
memory.chat_memory.add_message(f"SYSTEM: today is {current_time.strftime('%Y-%m-%d')}")
"""Use DuckDuckGo to search for specific information."""
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")
returnsearch_tool.run(query)
memory.chat_memory.add_message(f"SYSTEM:from now on when list torrents show seeds number and MAGNET LINK (USING A MARKDOWN LINK WITH TEXT 'Magnet link 🧲')")
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, \
memory.chat_memory.add_message(f"SYSTEM: from now on, when user ask for downolad NEVER start a qbittorrent download if user hasn't viewed the list of torrents first, \
andchoosedoneofthem")
# Initialize tools
# Initialize tools
tools=[
tools=[
DownloadListTool(),
QbitDownloadListTool(),
QBitSearchTool(),
QbitSearchTool(),
DownloadTorrentTool(),
QbitDownloadTorrentTool(),
Tool(
MoviesAdviceSearchTool(),
name="ForcedDuckDuckGoSearch",
MediaInfoSearchTool()
func=forced_duckduckgo_search,
description="Use this tool when you need to find specific information about movies, TV shows. Input should be a search query including the keyword 'imdb'.",
)
]
]
# Initialize the agent with memory
# Initialize the agent with memory
@ -65,20 +68,23 @@ def main():
print("Starting qBittorrent AI Agent...")
print("Starting qBittorrent AI Agent...")
# Create Gradio interface
# Create Gradio interface
withgr.Blocks(title="qBittorrent AI Agent")asinterface:
withgr.Blocks(title="qbit-agent")asinterface:
gr.Markdown("# qBittorrent AI Agent")
gr.Markdown("# qbit-agent")
gr.Markdown("Ask questions about downloads, search for content, or get recommendations.")
gr.Markdown("### Made by Matteo with hate and piracy 💀")
gr.Markdown("Ask about downloads, search for content (and torrent), or get recommendations.")
chatbot=gr.ChatInterface(
chatbot=gr.ChatInterface(
process_query,
process_query,
examples=["Find me the latest sci-fi movies",
examples=["Find me the latest sci-fi movies",
"What are the top TV shows from 2023?",
"What are the top TV shows from 2023?",
"Download Interstellar in 1080p"],
"Download Interstellar in 1080p",
title="qBittorrent Assistant"
"Show me my current downloads",
"What is The Matrix",
"Get me a list of horror movies"],
)
)
# Launch the interface
# Launch the interface
interface.launch(share=False)
interface.launch(share=True)
defcli_main():
defcli_main():
print("Starting qBittorrent AI Agent in CLI mode...")
print("Starting qBittorrent AI Agent in CLI mode...")