Upload CohereLabs_command-a-vision-07-2025_4.py with huggingface_hub
Browse files
CohereLabs_command-a-vision-07-2025_4.py
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# requires-python = ">=3.12"
|
3 |
+
# dependencies = [
|
4 |
+
# "transformers",
|
5 |
+
# "torch",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
try:
|
10 |
+
import os
|
11 |
+
from openai import OpenAI
|
12 |
+
|
13 |
+
client = OpenAI(
|
14 |
+
base_url="https://router.huggingface.co/v1",
|
15 |
+
api_key=os.environ["HF_TOKEN"],
|
16 |
+
)
|
17 |
+
|
18 |
+
completion = client.chat.completions.create(
|
19 |
+
model="CohereLabs/command-a-vision-07-2025",
|
20 |
+
messages=[
|
21 |
+
{
|
22 |
+
"role": "user",
|
23 |
+
"content": [
|
24 |
+
{
|
25 |
+
"type": "text",
|
26 |
+
"text": "Describe this image in one sentence."
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"type": "image_url",
|
30 |
+
"image_url": {
|
31 |
+
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
32 |
+
}
|
33 |
+
}
|
34 |
+
]
|
35 |
+
}
|
36 |
+
],
|
37 |
+
)
|
38 |
+
|
39 |
+
print(completion.choices[0].message)
|
40 |
+
with open('CohereLabs_command-a-vision-07-2025_4.txt', 'w') as f:
|
41 |
+
f.write('Everything was good in CohereLabs_command-a-vision-07-2025_4.txt')
|
42 |
+
except Exception as e:
|
43 |
+
with open('CohereLabs_command-a-vision-07-2025_4.txt', 'w') as f:
|
44 |
+
import traceback
|
45 |
+
traceback.print_exc(file=f)
|
46 |
+
finally:
|
47 |
+
from huggingface_hub import upload_file
|
48 |
+
upload_file(
|
49 |
+
path_or_fileobj='CohereLabs_command-a-vision-07-2025_4.txt',
|
50 |
+
repo_id='model-metadata/custom_code_execution_files',
|
51 |
+
path_in_repo='CohereLabs_command-a-vision-07-2025_4.txt',
|
52 |
+
repo_type='dataset',
|
53 |
+
)
|