from smolagents import DuckDuckGoSearchTool from smolagents import Tool from huggingface_hub import InferenceClient import soundfile as sf import torch from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline from datasets import load_dataset from transformers import Qwen2VLForConditionalGeneration, AutoTokenizer, AutoProcessor from qwen_vl_utils import process_vision_info import requests from bs4 import BeautifulSoup from pydub import AudioSegment import numpy as np from scipy.io import wavfile import pandas as pd from PIL import Image import html5lib class read_python_file(Tool): name = "reader_python" description = "Read a python file. Will return the entire code in the file" inputs = { "file_name": { "type": "string", "description": "The python file path" }, } output_type = "string" def forward(self, file_name): try: with open(file_name, "r", encoding="utf-8") as fichier: contenu = fichier.read() print("Contenu du fichier :\n") return contenu except FileNotFoundError: print(f"Erreur : le fichier '{fichier_cible}' n'existe pas.") return except Exception as e: print(f"Une erreur est survenue : {e}") return class read_excel_file(Tool): name = "reader_excel" description = "Read a excel file. Will return the entire info in the file" inputs = { "file_name": { "type": "string", "description": "The excel file path" }, } output_type = "string" def forward(self, file_name): try: # Lecture de toutes les feuilles xls = pd.ExcelFile(file_name) print("Sheets :", xls.sheet_names) # Lecture d'une feuille spécifique (ici, la première) df = pd.read_excel(xls, sheet_name=xls.sheet_names[0]) print("\nContent of the sheet :\n") return df except FileNotFoundError: print(f"Erreur : le fichier '{fichier_excel}' n'existe pas.") return except Exception as e: print(f"Une erreur est survenue : {e}") return class is_commutative(Tool): name = "commutative" description = "Performs a study on a table set to see if it is commutative." inputs = { "set": { "type": "array", "items": {"type": "string"}, "description": "The set defined, for example : {'a','b','c'}." }, "table": { "type": "string", "description": "The table in markdown format with rows separated by '\n'. Give only the table after the '|---|---|---|---|---|---|' symbol, starting with the '\n', ending with '\n\n', as a string." } } output_type = "string" def forward(self, set, table): set_0=list(sorted(set)) table_0=np.empty((len(set_0)+1,len(set_0)+1),dtype='