Skip to content

Commit 815250c

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents 5e6cb04 + 89f8ab4 commit 815250c

Some content is hidden

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

55 files changed

+99
-102
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ You can run our packages with vanilla JS, without any bundler, by using a CDN or
9797

9898
```html
9999
<script type="module">
100-
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected].0/+esm';
100+
import { InferenceClient } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected].1/+esm';
101101
import { createRepo, commit, deleteRepo, listFiles } from "https://cdn.jsdelivr.net/npm/@huggingface/[email protected]/+esm";
102102
</script>
103103
```

packages/inference/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@huggingface/inference",
3-
"version": "3.7.0",
3+
"version": "3.7.1",
44
"packageManager": "[email protected]",
55
"license": "MIT",
66
"author": "Hugging Face and Tim Mikeladze <[email protected]>",

packages/inference/src/snippets/getInferenceSnippets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const prepareConversationalInput = (
254254
return {
255255
messages: opts?.messages ?? getModelInputSnippet(model),
256256
...(opts?.temperature ? { temperature: opts?.temperature } : undefined),
257-
max_tokens: opts?.max_tokens ?? 500,
257+
max_tokens: opts?.max_tokens ?? 512,
258258
...(opts?.top_p ? { top_p: opts?.top_p } : undefined),
259259
};
260260
};

packages/inference/src/snippets/templates/js/openai/conversationalStream.jinja

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@ const client = new OpenAI({
55
apiKey: "{{ accessToken }}",
66
});
77

8-
let out = "";
9-
108
const stream = await client.chat.completions.create({
11-
provider: "{{ provider }}",
12-
model: "{{ model.id }}",
9+
model: "{{ providerModelId }}",
1310
{{ inputs.asTsString }}
11+
stream: true,
1412
});
1513

1614
for await (const chunk of stream) {
17-
if (chunk.choices && chunk.choices.length > 0) {
18-
const newContent = chunk.choices[0].delta.content;
19-
out += newContent;
20-
console.log(newContent);
21-
}
15+
process.stdout.write(chunk.choices[0]?.delta?.content || "");
2216
}

packages/ollama-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@huggingface/ollama-utils",
33
"packageManager": "[email protected]",
4-
"version": "0.0.7",
4+
"version": "0.0.8",
55
"description": "Various utilities for maintaining Ollama compatibility with models on Hugging Face hub",
66
"repository": "https://github.com/huggingface/huggingface.js.git",
77
"publishConfig": {

packages/ollama-utils/src/chat-template-automap.ts

Lines changed: 24 additions & 7 deletions
Large diffs are not rendered by default.

packages/ollama-utils/src/chat-template.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ const CUSTOM_TEMPLATE_MAPPING: ((ggufTmpl: string) => OllamaCustomMappedTemplate
8181
stop: "<|END_OF_TURN_TOKEN|>",
8282
}
8383
: undefined,
84+
(ggufTmpl: string) =>
85+
ggufTmpl.match(/Mistral Small 3/) && ggufTmpl.match(/2023-10-01/)
86+
? {
87+
// https://ollama.com/library/mistral-small
88+
// (template is edited at some point, so we need manual map to make sure it works, ref commit: https://huggingface.co/mistralai/Mistral-Small-3.1-24B-Instruct-2503/commit/4b8dd8aae705887db5295fcbff4aedbb92d682eb)
89+
ollamaTmpl:
90+
'{{- range $index, $_ := .Messages }}\n{{- if eq .Role "system" }}[SYSTEM_PROMPT]{{ .Content }}[/SYSTEM_PROMPT]\n{{- else if eq .Role "user" }}\n{{- if and (le (len (slice $.Messages $index)) 2) $.Tools }}[AVAILABLE_TOOLS]{{ $.Tools }}[/AVAILABLE_TOOLS]\n{{- end }}[INST]{{ .Content }}[/INST]\n{{- else if eq .Role "assistant" }}\n{{- if .Content }}{{ .Content }}\n{{- if not (eq (len (slice $.Messages $index)) 1) }}</s>\n{{- end }}\n{{- else if .ToolCalls }}[TOOL_CALLS][\n{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}\n{{- end }}]</s>\n{{- end }}\n{{- else if eq .Role "tool" }}[TOOL_RESULTS]{"content": {{ .Content }}}[/TOOL_RESULTS]\n{{- end }}\n{{- end }}',
91+
stop: "[INST]",
92+
}
93+
: undefined,
8494
];
8595

8696
export function convertGGUFTemplateToOllama(

packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/js/huggingface.js/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const chatCompletion = await client.chatCompletion({
1111
content: "What is the capital of France?",
1212
},
1313
],
14-
max_tokens: 500,
14+
max_tokens: 512,
1515
});
1616

1717
console.log(chatCompletion.choices[0].message);

packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/js/huggingface.js/0.together.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const chatCompletion = await client.chatCompletion({
1111
content: "What is the capital of France?",
1212
},
1313
],
14-
max_tokens: 500,
14+
max_tokens: 512,
1515
});
1616

1717
console.log(chatCompletion.choices[0].message);

packages/tasks-gen/snippets-fixtures/conversational-llm-non-stream/js/openai/0.hf-inference.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const chatCompletion = await client.chat.completions.create({
1313
content: "What is the capital of France?",
1414
},
1515
],
16-
max_tokens: 500,
16+
max_tokens: 512,
1717
});
1818

1919
console.log(chatCompletion.choices[0].message);

0 commit comments

Comments
 (0)