Skip to content

Commit c88fdc4

Browse files
Add mistral-common library (#1641)
Hi ! We'd like to add [vLLM](https://docs.vllm.ai/en/stable/) as a library and track the downloads via two possible formats: - Transformers with the `config.json` - Mistral with the `params.json` The code snippet suggested is through serving. Edit: Based on @Wauplin comment we changed the integration to instead add the `mistral-common` library --------- Co-authored-by: Lucain <lucainp@gmail.com>
1 parent fa9fe9d commit c88fdc4

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

packages/tasks/src/local-apps.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,27 @@ curl -X POST "http://localhost:8000/v1/completions" \\
207207
"temperature": 0.5
208208
}'`;
209209
const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct;
210+
211+
let setup;
212+
let dockerCommand;
213+
214+
if (model.tags.includes("mistral-common")) {
215+
setup = [
216+
"# Install vLLM from pip:",
217+
"pip install vllm",
218+
"# Make sure you have the latest version of mistral-common installed:",
219+
"pip install --upgrade mistral-common",
220+
].join("\n");
221+
dockerCommand = `# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id} --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice"`;
222+
} else {
223+
setup = ["# Install vLLM from pip:", "pip install vllm"].join("\n");
224+
dockerCommand = `# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`;
225+
}
226+
210227
return [
211228
{
212229
title: "Install from pip",
213-
setup: ["# Install vLLM from pip:", "pip install vllm"].join("\n"),
230+
setup: setup,
214231
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand],
215232
},
216233
{
@@ -226,10 +243,7 @@ curl -X POST "http://localhost:8000/v1/completions" \\
226243
` vllm/vllm-openai:latest \\`,
227244
` --model ${model.id}`,
228245
].join("\n"),
229-
content: [
230-
`# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`,
231-
runCommand,
232-
],
246+
content: [dockerCommand, runCommand],
233247
},
234248
];
235249
};

packages/tasks/src/model-libraries-snippets.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2023,4 +2023,24 @@ audio = model.autoencoder.decode(codes)[0].cpu()
20232023
torchaudio.save("sample.wav", audio, model.autoencoder.sampling_rate)
20242024
`,
20252025
];
2026+
2027+
export const mistral_common = (model: ModelData): string[] => [
2028+
`# We recommend to use vLLM to serve Mistral AI models.
2029+
pip install vllm
2030+
2031+
# Make sure to have installed the latest version of mistral-common.
2032+
pip install --upgrade mistral-common[image,audio]
2033+
2034+
# Serve the model with an OpenAI-compatible API.
2035+
vllm serve ${model.id} --tokenizer_mode mistral --config_format mistral --load_format mistral --tool-call-parser mistral --enable-auto-tool-choice
2036+
2037+
# Query the model with curl in a separate terminal.
2038+
curl http://localhost:8000/v1/chat/completions \
2039+
-H "Content-Type: application/json" \
2040+
-d '{
2041+
"model": "${model.id}",
2042+
"messages": [{"role": "user", "content": "What is the capital of France?"}]
2043+
}'`,
2044+
];
2045+
20262046
//#endregion

packages/tasks/src/model-libraries.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,14 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
631631
filter: false,
632632
countDownloads: `path_extension:"ckpt"`,
633633
},
634+
mistral_common: {
635+
prettyLabel: "mistral-common",
636+
repoName: "mistral-common",
637+
repoUrl: "https://github.com/mistralai/mistral-common",
638+
docsUrl: "https://mistralai.github.io/mistral-common/",
639+
snippets: snippets.mistral_common,
640+
countDownloads: `path:"config.json" OR path:"params.json"`,
641+
},
634642
mitie: {
635643
prettyLabel: "MITIE",
636644
repoName: "MITIE",

0 commit comments

Comments
 (0)