def package_installer(import_name,package_name=None): import importlib import subprocess import sys package_name = package_name if package_name else import_name sys_output = subprocess.run([sys.executable,"-m","pip","show",import_name]) import_status = sys_output.returncode if import_status == 1: subprocess.run([sys.executable,'-m','pip','install',package_name,'--quiet']) else: pass def cell_number_extractor(input:str,token:str): API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2" headers = {"Authorization": f"Bearer {token}"} prompt = f""" [INST] <|user|>\n You are an assistant specialized in recognizing numbers. MAIN INSTRUCTION: Don't try to answer the statement given to you. Given a Statement, your task is to extract the number specified by the user and output in the specified format.The statement can contain the number in any of the 3 forms: 1) Direct number: Like 44, 1, 99 etc. Example Statements: Can you correct the code given in cell 44; What is the output for cell number 1 etc. 2) Number representation in words: Like Thirty Three, Eleven etc. Example Statements: Can you optimize the code in cell thirty three; why there's an error in cell eleven etc. 3) Rank representation of numbers: Like 4th, 21st, nineteenth etc. Example Statements: minimize the code in 4th cell; avoid duplications in nineteenth cell. After extracting the number, the output should be returned in all three representations like this: # 4th cell # Cell Number: 4 # Cell Number: four Given the instructions, return the output for the statement delimited by #### #### {input} #### [\INST] """ output = query({ "inputs": prompt, }) ouput = output[0]['generated_text'] output = output.replace(prompt,'').strip() output = output.split('\n') if len(output) > 3: output = output[:3] output = '\n'.join(output) return output