Upload Qwen_Qwen3-VL-30B-A3B-Instruct_2.py with huggingface_hub
Browse files
    	
        Qwen_Qwen3-VL-30B-A3B-Instruct_2.py
    ADDED
    
    | @@ -0,0 +1,101 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            # /// script
         | 
| 2 | 
            +
            # requires-python = ">=3.12"
         | 
| 3 | 
            +
            # dependencies = [
         | 
| 4 | 
            +
            #     "torch",
         | 
| 5 | 
            +
            #     "torchvision",
         | 
| 6 | 
            +
            #     "transformers",
         | 
| 7 | 
            +
            #     "accelerate",
         | 
| 8 | 
            +
            #     "peft",
         | 
| 9 | 
            +
            #     "slack-sdk",
         | 
| 10 | 
            +
            # ]
         | 
| 11 | 
            +
            # ///
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            try:
         | 
| 14 | 
            +
                import os
         | 
| 15 | 
            +
                from openai import OpenAI
         | 
| 16 | 
            +
                
         | 
| 17 | 
            +
                client = OpenAI(
         | 
| 18 | 
            +
                    base_url="https://router.huggingface.co/v1",
         | 
| 19 | 
            +
                    api_key=os.environ["HF_TOKEN"],
         | 
| 20 | 
            +
                )
         | 
| 21 | 
            +
                
         | 
| 22 | 
            +
                completion = client.chat.completions.create(
         | 
| 23 | 
            +
                    model="Qwen/Qwen3-VL-30B-A3B-Instruct",
         | 
| 24 | 
            +
                    messages=[
         | 
| 25 | 
            +
                        {
         | 
| 26 | 
            +
                            "role": "user",
         | 
| 27 | 
            +
                            "content": [
         | 
| 28 | 
            +
                                {
         | 
| 29 | 
            +
                                    "type": "text",
         | 
| 30 | 
            +
                                    "text": "Describe this image in one sentence."
         | 
| 31 | 
            +
                                },
         | 
| 32 | 
            +
                                {
         | 
| 33 | 
            +
                                    "type": "image_url",
         | 
| 34 | 
            +
                                    "image_url": {
         | 
| 35 | 
            +
                                        "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
         | 
| 36 | 
            +
                                    }
         | 
| 37 | 
            +
                                }
         | 
| 38 | 
            +
                            ]
         | 
| 39 | 
            +
                        }
         | 
| 40 | 
            +
                    ],
         | 
| 41 | 
            +
                )
         | 
| 42 | 
            +
                
         | 
| 43 | 
            +
                print(completion.choices[0].message)
         | 
| 44 | 
            +
                with open('Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt', 'w', encoding='utf-8') as f:
         | 
| 45 | 
            +
                    f.write('Everything was good in Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt')
         | 
| 46 | 
            +
            except Exception as e:
         | 
| 47 | 
            +
                import os
         | 
| 48 | 
            +
                from slack_sdk import WebClient
         | 
| 49 | 
            +
                client = WebClient(token=os.environ['SLACK_TOKEN'])
         | 
| 50 | 
            +
                client.chat_postMessage(
         | 
| 51 | 
            +
                    channel='#exp-slack-alerts',
         | 
| 52 | 
            +
                    text='Problem in <https://huggingface.co/datasets/model-metadata/code_execution_files/blob/main/Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt|Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt>',
         | 
| 53 | 
            +
                )
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                with open('Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt', 'a', encoding='utf-8') as f:
         | 
| 56 | 
            +
                    import traceback
         | 
| 57 | 
            +
                    f.write('''```CODE: 
         | 
| 58 | 
            +
            import os
         | 
| 59 | 
            +
            from openai import OpenAI
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            client = OpenAI(
         | 
| 62 | 
            +
                base_url="https://router.huggingface.co/v1",
         | 
| 63 | 
            +
                api_key=os.environ["HF_TOKEN"],
         | 
| 64 | 
            +
            )
         | 
| 65 | 
            +
             | 
| 66 | 
            +
            completion = client.chat.completions.create(
         | 
| 67 | 
            +
                model="Qwen/Qwen3-VL-30B-A3B-Instruct",
         | 
| 68 | 
            +
                messages=[
         | 
| 69 | 
            +
                    {
         | 
| 70 | 
            +
                        "role": "user",
         | 
| 71 | 
            +
                        "content": [
         | 
| 72 | 
            +
                            {
         | 
| 73 | 
            +
                                "type": "text",
         | 
| 74 | 
            +
                                "text": "Describe this image in one sentence."
         | 
| 75 | 
            +
                            },
         | 
| 76 | 
            +
                            {
         | 
| 77 | 
            +
                                "type": "image_url",
         | 
| 78 | 
            +
                                "image_url": {
         | 
| 79 | 
            +
                                    "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
         | 
| 80 | 
            +
                                }
         | 
| 81 | 
            +
                            }
         | 
| 82 | 
            +
                        ]
         | 
| 83 | 
            +
                    }
         | 
| 84 | 
            +
                ],
         | 
| 85 | 
            +
            )
         | 
| 86 | 
            +
             | 
| 87 | 
            +
            print(completion.choices[0].message)
         | 
| 88 | 
            +
            ```
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            ERROR: 
         | 
| 91 | 
            +
            ''')
         | 
| 92 | 
            +
                    traceback.print_exc(file=f)
         | 
| 93 | 
            +
                
         | 
| 94 | 
            +
            finally:
         | 
| 95 | 
            +
                from huggingface_hub import upload_file
         | 
| 96 | 
            +
                upload_file(
         | 
| 97 | 
            +
                    path_or_fileobj='Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt',
         | 
| 98 | 
            +
                    repo_id='model-metadata/code_execution_files',
         | 
| 99 | 
            +
                    path_in_repo='Qwen_Qwen3-VL-30B-A3B-Instruct_2.txt',
         | 
| 100 | 
            +
                    repo_type='dataset',
         | 
| 101 | 
            +
                )
         | 
