Upload moonshotai_Kimi-K2-Instruct_3.py with huggingface_hub
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142# /// script# requires-python = ">=3.12"# dependencies = [# "transformers",# "torch",# ]# ///
try: import os from openai import OpenAI client = OpenAI( base_url="https://router.huggingface.co/v1", api_key=os.environ["HF_TOKEN"], ) completion = client.chat.completions.create( model="moonshotai/Kimi-K2-Instruct", messages=[ { "role": "user", "content": "What is the capital of France?" } ], ) print(completion.choices[0].message) with open('moonshotai_Kimi-K2-Instruct_3.txt', 'w') as f: f.write('Everything was good in moonshotai_Kimi-K2-Instruct_3.txt')except Exception as e: with open('moonshotai_Kimi-K2-Instruct_3.txt', 'w') as f: import traceback traceback.print_exc(file=f)finally: from huggingface_hub import upload_file upload_file( path_or_fileobj='moonshotai_Kimi-K2-Instruct_3.txt', repo_id='model-metadata/custom_code_execution_files', path_in_repo='moonshotai_Kimi-K2-Instruct_3.txt', repo_type='dataset', )moonshotai_Kimi-K2-Instruct_3.pyAdded+42