Upload HuggingFaceTB_SmolLM3-3B_7.py with huggingface_hub
Browse files
HuggingFaceTB_SmolLM3-3B_7.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# /// script
|
2 |
+
# requires-python = ">=3.12"
|
3 |
+
# dependencies = [
|
4 |
+
# "transformers",
|
5 |
+
# "torch",
|
6 |
+
# ]
|
7 |
+
# ///
|
8 |
+
|
9 |
+
try:
|
10 |
+
import os
|
11 |
+
from huggingface_hub import InferenceClient
|
12 |
+
|
13 |
+
client = InferenceClient(
|
14 |
+
provider="auto",
|
15 |
+
api_key=os.environ["HF_TOKEN"],
|
16 |
+
)
|
17 |
+
|
18 |
+
completion = client.chat.completions.create(
|
19 |
+
model="HuggingFaceTB/SmolLM3-3B",
|
20 |
+
messages=[
|
21 |
+
{
|
22 |
+
"role": "user",
|
23 |
+
"content": "What is the capital of France?"
|
24 |
+
}
|
25 |
+
],
|
26 |
+
)
|
27 |
+
|
28 |
+
print(completion.choices[0].message)
|
29 |
+
with open('HuggingFaceTB_SmolLM3-3B_7.txt', 'w') as f:
|
30 |
+
f.write('Everything was good in HuggingFaceTB_SmolLM3-3B_7.txt')
|
31 |
+
except Exception as e:
|
32 |
+
with open('HuggingFaceTB_SmolLM3-3B_7.txt', 'w') as f:
|
33 |
+
import traceback
|
34 |
+
traceback.print_exc(file=f)
|
35 |
+
finally:
|
36 |
+
from huggingface_hub import upload_file
|
37 |
+
upload_file(
|
38 |
+
path_or_fileobj='HuggingFaceTB_SmolLM3-3B_7.txt',
|
39 |
+
repo_id='model-metadata/custom_code_execution_files',
|
40 |
+
path_in_repo='HuggingFaceTB_SmolLM3-3B_7.txt',
|
41 |
+
repo_type='dataset',
|
42 |
+
)
|