Skip to content

Commit fd20ab4

Browse files
committed
os.environ[...]
1 parent 3857067 commit fd20ab4

File tree

56 files changed

+58
-58
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+58
-58
lines changed

packages/inference/src/snippets/getInferenceSnippets.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@ function replaceAccessTokenPlaceholder(
456456
snippet = "import os\n" + snippet;
457457
snippet = snippet.replace(
458458
`"${ACCESS_TOKEN_PLACEHOLDER}"`,
459-
`os.getenv("${accessTokenEnvVar}")` // e.g. os.getenv("HF_TOKEN")
459+
`os.environ["${accessTokenEnvVar}"]` // e.g. os.environ["HF_TOKEN")
460460
);
461461
snippet = snippet.replace(
462462
`"Bearer <ACCESS_TOKEN>"`,
463-
`f"Bearer {os.getenv('${accessTokenEnvVar}')}"` // e.g. f"Bearer {os.getenv('HF_TOKEN')}"
463+
`f"Bearer {os.environ['${accessTokenEnvVar}']}"` // e.g. f"Bearer {os.environ['HF_TOKEN']}"
464464
);
465465
snippet = snippet.replace(
466466
`"Key <ACCESS_TOKEN>"`,
467-
`f"Key {os.getenv('${accessTokenEnvVar}')}"` // e.g. f"Key {os.getenv('FAL_AI_API_TOKEN')}"
467+
`f"Key {os.environ['${accessTokenEnvVar}']}"` // e.g. f"Key {os.environ['FAL_AI_API_TOKEN']}"
468468
);
469469
} else if (language === "js") {
470470
snippet = snippet.replace(

packages/tasks-gen/snippets-fixtures/automatic-speech-recognition/python/huggingface_hub/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = InferenceClient(
55
provider="hf-inference",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
)
88

99
output = client.automatic_speech_recognition("sample1.flac", model="openai/whisper-large-v3-turbo")

packages/tasks-gen/snippets-fixtures/automatic-speech-recognition/python/requests/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
API_URL = "https://router.huggingface.co/hf-inference/models/openai/whisper-large-v3-turbo"
55
headers = {
6-
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}",
6+
"Authorization": f"Bearer {os.environ['HF_TOKEN']}",
77
}
88

99
def query(filename):

packages/tasks-gen/snippets-fixtures/basic-snippet--token-classification/python/huggingface_hub/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = InferenceClient(
55
provider="hf-inference",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
)
88

99
result = client.token_classification(

packages/tasks-gen/snippets-fixtures/basic-snippet--token-classification/python/requests/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
API_URL = "https://router.huggingface.co/hf-inference/models/FacebookAI/xlm-roberta-large-finetuned-conll03-english"
55
headers = {
6-
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}",
6+
"Authorization": f"Bearer {os.environ['HF_TOKEN']}",
77
}
88

99
def query(payload):

packages/tasks-gen/snippets-fixtures/bill-to-param/python/huggingface_hub/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = InferenceClient(
55
provider="hf-inference",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
bill_to="huggingface",
88
)
99

packages/tasks-gen/snippets-fixtures/bill-to-param/python/openai/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = OpenAI(
55
base_url="https://router.huggingface.co/hf-inference/models/meta-llama/Llama-3.1-8B-Instruct/v1",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
default_headers={
88
"X-HF-Bill-To": "huggingface"
99
}

packages/tasks-gen/snippets-fixtures/bill-to-param/python/requests/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
API_URL = "https://router.huggingface.co/hf-inference/models/meta-llama/Llama-3.1-8B-Instruct/v1/chat/completions"
55
headers = {
6-
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}",
6+
"Authorization": f"Bearer {os.environ['HF_TOKEN']}",
77
"X-HF-Bill-To": "huggingface"
88
}
99

packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/python/huggingface_hub/0.hf-inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = InferenceClient(
55
provider="hf-inference",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
)
88

99
completion = client.chat.completions.create(

packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/python/huggingface_hub/0.together.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
client = InferenceClient(
55
provider="together",
6-
api_key=os.getenv("HF_TOKEN"),
6+
api_key=os.environ["HF_TOKEN"],
77
)
88

99
completion = client.chat.completions.create(

0 commit comments

Comments
 (0)