We recommend using this model with the
vLLM library
to implement production-ready inference pipelines.
Also make sure to have installed
mistral_common >= 1.7.0.
You can also make use of a ready-to-go
docker image or on the
docker hub.
We recommand that you use Devstral in a server/client setting.
1import requests
2import json
3from huggingface_hub import hf_hub_download
4
5
6url = "http://<your-server-url>:8000/v1/chat/completions"
7headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
8
9model = "apolloparty/Devstral-Small-2507-NVFP4A16"
10
11def load_system_prompt(repo_id: str, filename: str) -> str:
12 file_path = hf_hub_download(repo_id=repo_id, filename=filename)
13 with open(file_path, "r") as file:
14 system_prompt = file.read()
15 return system_prompt
16
17SYSTEM_PROMPT = load_system_prompt(model, "SYSTEM_PROMPT.txt")
18
19messages = [
20 {"role": "system", "content": SYSTEM_PROMPT},
21 {
22 "role": "user",
23 "content": [
24 {
25 "type": "text",
26 "text": "<your-command>",
27 },
28 ],
29 },
30]
31
32data = {"model": model, "messages": messages, "temperature": 0.15}
33
34# Devstral Small 1.1 supports tool calling. If you want to use tools, follow this:
35# tools = [ # Define tools for vLLM
36# {
37# "type": "function",
38# "function": {
39# "name": "git_clone",
40# "description": "Clone a git repository",
41# "parameters": {
42# "type": "object",
43# "properties": {
44# "url": {
45# "type": "string",
46# "description": "The url of the git repository",
47# },
48# },
49# "required": ["url"],
50# },
51# },
52# }
53# ]
54# data = {"model": model, "messages": messages, "temperature": 0.15, "tools": tools} # Pass tools to payload.
55
56response = requests.post(url, headers=headers, data=json.dumps(data))
57print(response.json()["choices"][0]["message"]["content"])