Skip to content

Commit e4c6cba

Browse files
committed
update python snippets
1 parent d9d5a43 commit e4c6cba

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

packages/tasks/src/snippets/python.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@ import type { ModelDataMinimal } from "./types.js";
55
export const snippetConversational = (model: ModelDataMinimal, accessToken: string): string =>
66
`from huggingface_hub import InferenceClient
77
8-
client = InferenceClient(
9-
"${model.id}",
10-
token="${accessToken || "{API_TOKEN}"}",
11-
)
8+
client = InferenceClient(api_key="${accessToken || "{API_TOKEN}"}")
129
1310
for message in client.chat_completion(
11+
model="${model.id}",
1412
messages=[{"role": "user", "content": "What is the capital of France?"}],
1513
max_tokens=500,
1614
stream=True,
@@ -20,13 +18,12 @@ for message in client.chat_completion(
2018
export const snippetConversationalWithImage = (model: ModelDataMinimal, accessToken: string): string =>
2119
`from huggingface_hub import InferenceClient
2220
23-
client = InferenceClient(
24-
"${model.id}",
25-
token="${accessToken || "{API_TOKEN}"}",
26-
)
21+
client = InferenceClient(api_key="${accessToken || "{API_TOKEN}"}")
22+
2723
image_url = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
2824
2925
for message in client.chat_completion(
26+
model="${model.id}",
3027
messages=[
3128
{
3229
"role": "user",

0 commit comments

Comments
 (0)