model-metadata/code_python_files
013k
1# /// script2# requires-python = ">=3.12"3# dependencies = [4# "torch",5# "torchvision",6# "transformers",7# "diffusers",8# "sentence-transformers",9# "accelerate",10# "peft",11# "slack-sdk",12# ]13# ///14 15try:16 # Use a pipeline as a high-level helper17 from transformers import pipeline18 19 pipe = pipeline("text-generation", model="inference-net/Schematron-3B")20 messages = [21 {"role": "user", "content": "Who are you?"},22 ]23 pipe(messages)24 with open('inference-net_Schematron-3B_0.txt', 'w', encoding='utf-8') as f:25 f.write('Everything was good in inference-net_Schematron-3B_0.txt')26except Exception as e:27 import os28 from slack_sdk import WebClient29 client = WebClient(token=os.environ['SLACK_TOKEN'])30 client.chat_postMessage(31 channel='#exp-slack-alerts',32 text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/inference-net_Schematron-3B_0.txt|inference-net_Schematron-3B_0.txt>',33 )34 35 with open('inference-net_Schematron-3B_0.txt', 'a', encoding='utf-8') as f:36 import traceback37 f.write('''```CODE: 38# Use a pipeline as a high-level helper39from transformers import pipeline40 41pipe = pipeline("text-generation", model="inference-net/Schematron-3B")42messages = [43 {"role": "user", "content": "Who are you?"},44]45pipe(messages)46```47 48ERROR: 49''')50 traceback.print_exc(file=f)51 52finally:53 from huggingface_hub import upload_file54 upload_file(55 path_or_fileobj='inference-net_Schematron-3B_0.txt',56 repo_id='model-metadata/code_execution_files',57 path_in_repo='inference-net_Schematron-3B_0.txt',58 repo_type='dataset',59 )60 