from smolagents import tool, Tool from tavily import TavilyClient from smolagents import DuckDuckGoSearchTool, GoogleSearchTool, VisitWebpageTool, WikipediaSearchTool, PythonInterpreterTool, FinalAnswerTool from dotenv import load_dotenv import os load_dotenv() # take environment variables # init tools duck_search = DuckDuckGoSearchTool() google_search = GoogleSearchTool() visit_page = VisitWebpageTool() wiki_search = WikipediaSearchTool() do_python = PythonInterpreterTool() final_answer = FinalAnswerTool() tavily_search = TavilyClient() speech_to_text_tool = Tool.from_space("hf-audio/whisper-large-v3-turbo", name="speech_to_text_tool", description="""Converts audio to text by providing a file or url. Use the with the command speed_to_text_tool(filename). Example: 'speech_to_text_tool("cache\\audio.mp3'""", api_name="/predict") visual_qa_tool = Tool.from_space("sitammeur/PicQ", name="visual_qa_tool", description="""Can answer question about a provided image. Use it with visual_qa_tool(question=, image=). Example visual_qa_tool(question='How many items are in the image?', image='cache\\image.png').""", api_name="/predict") # image_generation_tool = Tool.from_space( # "black-forest-labs/FLUX.1-schnell", # name="image_generator", # description="Generate an image from a prompt" # ) # image = image_generation_tool("A sunny beach") # print(image) ## Testing the tools # print(duck_search.forward("smolagents")) # connect error, does not take proxy # print(google_search.forward("smolagents")) # print(visit_page.forward("https://www.wikipedia.de")) # print(wiki_search.forward("Python_(programming_language)")) # print(do_python('print("hello world")')) # print(tavily_search.search("smolagents")) # print(speech_to_text_tool("cache\\1f975693-876d-457b-a649-393859e79bf3.mp3")) # print(visual_qa_tool(question="Name all black and white figures with each coordinates, e. g. black king on g8", image="cache\\cca530fc-4052-43b2-b130-b30968d8aa44.png"))