Views
No views yet
Devstral Small 1.1:| Model/Benchmark | Size (B Parameters) | SWE Bench Verified | SWE Bench Multilingual | Terminal Bench 2 |
|---|---|---|---|---|
| Devstral 2 | 123 | 72.2% | 61.3% | 32.6% |
| Devstral Small 2 | 24 | 68.0% | 55.7% | 22.5% |
| GLM 4.6 | 355 | 68.0% | -- | 24.6% |
| Qwen 3 Coder Plus | 480 | 69.6% | 54.7% | 25.4% |
| MiniMax M2 | 230 | 69.4% | 56.5% | 30.0% |
| Kimi K2 Thinking | 1000 | 71.3% | 61.1% | 35.7% |
| DeepSeek v3.2 | 671 | 73.1% | 70.2% | 46.4% |
| GPT 5.1 Codex High | -- | 73.7% | -- | 52.8% |
| GPT 5.1 Codex Max | -- | 77.9% | -- | 60.4% |
| Gemini 3 Pro | -- | 76.2% | -- | 54.2% |
| Claude Sonnet 4.5 | -- | 77.2% | 68.0% | 42.8% |
uv for faster and more reliable dependency management:uv tool install mistral-vibecurl -LsSf https://mistral.ai/vibe/install.sh | shpip install mistral-vibevibe~/.vibe/config.toml.~/.vibe/.env for future use.vllm (recommended): See heresglang: See heretransformers: See herellama.cpp: To use community ones such as Unsloth's or Bartowski's make sure to use changes from this PR.LM Studio: https://lmstudio.ai/models/devstral-2Ollama: https://ollama.com/library/devstral-small-2uv pip install -U vllmdocker pull vllm/vllm-openai:latest
docker run -it vllm/vllm-openai:latestmistral_common >= 1.8.6.
To check:python -c "import mistral_common; print(mistral_common.__version__)"vllm serve mistralai/Devstral-Small-2-24B-Instruct-2512 \
--max-model-len 262144 --tensor-parallel-size 2 \
--tool-call-parser mistral --enable-auto-tool-choice1import 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 = "mistralai/Devstral-Small-2-24B-Instruct-2512"
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, "CHAT_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 2 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"])main locally):git clone https://github.com/sgl-project/sglang.git
cd sglang
uv pip install -e python
uv pip install transformers==5.0.0rc # required
uv pip install nvidia-cudnn-cu12==9.16.0.29 # required for VLMpython -m sglang.launch_server --model-path mistralai/Devstral-Small-2-24B-Instruct-2512 --host 0.0.0.0 --port 30000 --tp 2 --tool-call-parser mistral1import requests
2import json
3from huggingface_hub import hf_hub_download
4
5
6url = "http://<your-server-url>:30000/v1/chat/completions"
7headers = {"Content-Type": "application/json", "Authorization": "Bearer token"}
8
9model = "mistralai/Devstral-Small-2-24B-Instruct-2512"
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, "CHAT_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 2 supports tool calling. If you want to use tools, follow this:
35# tools = [ # Define tools (OpenAI-compatible)
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"])uv pip install git+https://github.com/huggingface/transformers1import torch
2from transformers import (
3 Mistral3ForConditionalGeneration,
4 MistralCommonBackend,
5)
6
7model_id = "mistralai/Devstral-Small-2-24B-Instruct-2512"
8
9tokenizer = MistralCommonBackend.from_pretrained(model_id)
10model = Mistral3ForConditionalGeneration.from_pretrained(model_id, device_map="auto")
11
12SP = """You are operating as and within Mistral Vibe, a CLI coding-agent built by Mistral AI and powered by default by the Devstral family of models. It wraps Mistral's Devstral models to enable natural language interaction with a local codebase. Use the available tools when helpful.
13
14You can:
15
16- Receive user prompts, project context, and files.
17- Send responses and emit function calls (e.g., shell commands, code edits).
18- Apply patches, run commands, based on user approvals.
19
20Answer the user's request using the relevant tool(s), if they are available. Check that all the required parameters for each tool call are provided or can reasonably be inferred from context. IF there are no relevant tools or there are missing values for required parameters, ask the user to supply these values; otherwise proceed with the tool calls. If the user provides a specific value for a parameter (for example provided in quotes), make sure to use that value EXACTLY. DO NOT make up values for or ask about optional parameters. Carefully analyze descriptive terms in the request as they may indicate required parameter values that should be included even if not explicitly quoted.
21
22Always try your hardest to use the tools to answer the user's request. If you can't use the tools, explain why and ask the user for more information.
23
24Act as an agentic assistant, if a user asks for a long task, break it down and do it step by step.
25
26When you want to commit changes, you will always use the 'git commit' bash command. It will always be suffixed with a line telling it was generated by Mistral Vibe with the appropriate co-authoring information. The format you will always use is the following heredoc.
27
28```bash
29git commit -m "<Commit message here>
30
31Generated by Mistral Vibe.
32Co-Authored-By: Mistral Vibe <vibe@mistral.ai>"
33```"""
34
35input = {
36 "messages": [
37 {
38 "role": "system",
39 "content": SP,
40 },
41 {
42 "role": "user",
43 "content": [
44 {
45 "type": "text",
46 "text": "Can you implement in Python a method to compute the fibonnaci sequence at the `n`th element with `n` a parameter passed to the function ? You should start the sequence from 1, previous values are invalid.\nThen run the Python code for the function for n=5 and give the answer.",
47 }
48 ],
49 },
50 ],
51 "tools": [
52 {
53 "type": "function",
54 "function": {
55 "name": "add_number",
56 "description": "Add two numbers.",
57 "parameters": {
58 "type": "object",
59 "properties": {
60 "a": {"type": "string", "description": "The first number."},
61 "b": {"type": "string", "description": "The second number."},
62 },
63 "required": ["a", "b"],
64 },
65 },
66 },
67 {
68 "type": "function",
69 "function": {
70 "name": "multiply_number",
71 "description": "Multiply two numbers.",
72 "parameters": {
73 "type": "object",
74 "properties": {
75 "a": {"type": "string", "description": "The first number."},
76 "b": {"type": "string", "description": "The second number."},
77 },
78 "required": ["a", "b"],
79 },
80 },
81 },
82 {
83 "type": "function",
84 "function": {
85 "name": "substract_number",
86 "description": "Substract two numbers.",
87 "parameters": {
88 "type": "object",
89 "properties": {
90 "a": {"type": "string", "description": "The first number."},
91 "b": {"type": "string", "description": "The second number."},
92 },
93 "required": ["a", "b"],
94 },
95 },
96 },
97 {
98 "type": "function",
99 "function": {
100 "name": "write_a_story",
101 "description": "Write a story about science fiction and people with badass laser sabers.",
102 "parameters": {},
103 },
104 },
105 {
106 "type": "function",
107 "function": {
108 "name": "terminal",
109 "description": "Perform operations from the terminal.",
110 "parameters": {
111 "type": "object",
112 "properties": {
113 "command": {
114 "type": "string",
115 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
116 },
117 "args": {
118 "type": "string",
119 "description": "The arguments to pass to the command.",
120 },
121 },
122 "required": ["command"],
123 },
124 },
125 },
126 {
127 "type": "function",
128 "function": {
129 "name": "python",
130 "description": "Call a Python interpreter with some Python code that will be ran.",
131 "parameters": {
132 "type": "object",
133 "properties": {
134 "code": {
135 "type": "string",
136 "description": "The Python code to run",
137 },
138 "result_variable": {
139 "type": "string",
140 "description": "Variable containing the result you'd like to retrieve from the execution.",
141 },
142 },
143 "required": ["code", "result_variable"],
144 },
145 },
146 },
147 ],
148}
149
150tokenized = tokenizer.apply_chat_template(
151 conversation=input["messages"],
152 tools=input["tools"],
153 return_tensors="pt",
154 return_dict=True,
155)
156
157input_ids = tokenized["input_ids"].to(device="cuda")
158
159output = model.generate(
160 input_ids,
161 max_new_tokens=200,
162 do_sample=True,
163 temperature=0.15,
164)[0]
165
166decoded_output = tokenizer.decode(output[len(tokenized["input_ids"][0]) :])
167print(decoded_output)1messages = [
2 {"role": "system", "content": SYSTEM_PROMPT},
3 {
4 "role": "user",
5 "content": [
6 {
7 "type": "text",
8 "text": "Could you write me a story ?",
9 },
10 ],
11 },
12]
13tools = [
14 {
15 "type": "function",
16 "function": {
17 "name": "add_number",
18 "description": "Add two numbers.",
19 "parameters": {
20 "type": "object",
21 "properties": {
22 "a": {
23 "type": "string",
24 "description": "The first number.",
25 },
26 "b": {
27 "type": "string",
28 "description": "The second number.",
29 },
30 },
31 "required": ["a", "b"],
32 },
33 },
34 },
35 {
36 "type": "function",
37 "function": {
38 "name": "multiply_number",
39 "description": "Multiply two numbers.",
40 "parameters": {
41 "type": "object",
42 "properties": {
43 "a": {
44 "type": "string",
45 "description": "The first number.",
46 },
47 "b": {
48 "type": "string",
49 "description": "The second number.",
50 },
51 },
52 "required": ["a", "b"],
53 },
54 },
55 },
56 {
57 "type": "function",
58 "function": {
59 "name": "substract_number",
60 "description": "Substract two numbers.",
61 "parameters": {
62 "type": "object",
63 "properties": {
64 "a": {
65 "type": "string",
66 "description": "The first number.",
67 },
68 "b": {
69 "type": "string",
70 "description": "The second number.",
71 },
72 },
73 "required": ["a", "b"],
74 },
75 },
76 },
77 {
78 "type": "function",
79 "function": {
80 "name": "write_a_story",
81 "description": "Write a story about science fiction and people with badass laser sabers.",
82 "parameters": {},
83 },
84 },
85 {
86 "type": "function",
87 "function": {
88 "name": "terminal",
89 "description": "Perform operations from the terminal.",
90 "parameters": {
91 "type": "object",
92 "properties": {
93 "command": {
94 "type": "string",
95 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
96 },
97 "args": {
98 "type": "string",
99 "description": "The arguments to pass to the command.",
100 },
101 },
102 "required": ["command"],
103 },
104 },
105 },
106 {
107 "type": "function",
108 "function": {
109 "name": "python",
110 "description": "Call a Python interpreter with some Python code that will be ran.",
111 "parameters": {
112 "type": "object",
113 "properties": {
114 "code": {
115 "type": "string",
116 "description": "The Python code to run",
117 },
118 "result_variable": {
119 "type": "string",
120 "description": "Variable containing the result you'd like to retrieve from the execution.",
121 },
122 },
123 "required": ["code", "result_variable"],
124 },
125 },
126 },
127]1[
2 {
3 "role": "assistant",
4 "tool_calls": [
5 {
6 "id": "chatcmpl-tool-8a1f267a212e66e5",
7 "function": {
8 "arguments": "{}",
9 "name": "write_a_story"
10 },
11 "type": "function"
12 }
13 ],
14 "content": null
15 },
16 {
17 "role": "tool",
18 "tool_call_id": "chatcmpl-tool-8a1f267a212e66e5",
19 "name": "write_a_story",
20 "content": "A long time ago in a galaxy far, far away..."
21 },
22 {
23 "role": "assistant",
24 "tool_calls": [],
25 "content": "A long time ago in a galaxy far, far away, there was a planet called Eldoria, known for its breathtaking landscapes and advanced civilization. The people of Eldoria were not just ordinary beings; they were warriors, scientists, and dreamers, all wielding the power of laser sabers.\n\nAmong them was a young warrior named Kael. Kael was not like the others. While his peers trained rigorously to master the art of the laser saber, Kael was more interested in the science behind it. He spent his days in the ancient libraries of Eldoria, deciphering the secrets of the laser sabers and the energy that powered them.\n\nOne day, Kael discovered an old, forgotten text that spoke of a legendary laser saber, the \"Eldoria Star,\" said to be the most powerful weapon in the galaxy. According to the text, the Eldoria Star was hidden in the heart of the planet's core, guarded by an ancient force.\n\nDriven by curiosity and a desire to protect his planet, Kael set out on a perilous journey to find the Eldoria Star. Along the way, he encountered various challenges and made unlikely allies, each with their own unique skills and laser sabers.\n\nThere was Lyra, a cunning thief with a laser saber that could change colors; Zara, a wise old sage who could manipulate energy fields; and Jax, a former enemy turned ally, whose laser saber was as fierce as his spirit.\n\nTogether, they faced the trials set before them, each step bringing them closer to the heart of Eldoria. As they ventured deeper, they uncovered the truth about the Eldoria Star and the ancient force guarding it.\n\nThe ancient force, known as the \"Guardian,\" revealed that the Eldoria Star was not just a weapon, but a source of immense energy that could either save or destroy the galaxy. It was a test of the warriors' hearts and minds.\n\nKael and his allies faced the ultimate challenge, proving their worth and their commitment to protecting the galaxy. In the end, they succeeded, not by wielding the Eldoria Star, but by understanding its true power and using it to restore balance to the galaxy.\n\nWith the Eldoria Star secured and the galaxy at peace, Kael and his allies returned to their lives, forever changed by their journey. Kael continued his studies, now with a deeper understanding of the laser sabers and the energy that powered them.\n\nAnd so, the legend of the Eldoria Star and the warriors who found it became a tale told for generations, a reminder of the power of knowledge, courage, and the unbreakable bond of friendship."
26 }
27]1messages = [
2 {"role": "system", "content": SYSTEM_PROMPT},
3 {
4 "role": "user",
5 "content": [
6 {
7 "type": "text",
8 "text": "Compute the results steps by steps for the equations that involve only numbers displayed in the image. You have to call tools to perform the operations and can do one operation at a time per equation."
9 },
10 {
11 "type": "image_url",
12 "image_url": {
13 "url": "https://math-coaching.com/img/fiche/46/expressions-mathematiques.jpg"
14 }
15 }
16 ]
17 }
18]
19tools = [
20 {
21 "type": "function",
22 "function": {
23 "name": "add_number",
24 "description": "Add two numbers.",
25 "parameters": {
26 "type": "object",
27 "properties": {
28 "a": {
29 "type": "string",
30 "description": "The first number.",
31 },
32 "b": {
33 "type": "string",
34 "description": "The second number.",
35 },
36 },
37 "required": ["a", "b"],
38 },
39 },
40 },
41 {
42 "type": "function",
43 "function": {
44 "name": "multiply_number",
45 "description": "Multiply two numbers.",
46 "parameters": {
47 "type": "object",
48 "properties": {
49 "a": {
50 "type": "string",
51 "description": "The first number.",
52 },
53 "b": {
54 "type": "string",
55 "description": "The second number.",
56 },
57 },
58 "required": ["a", "b"],
59 },
60 },
61 },
62 {
63 "type": "function",
64 "function": {
65 "name": "substract_number",
66 "description": "Substract two numbers.",
67 "parameters": {
68 "type": "object",
69 "properties": {
70 "a": {
71 "type": "string",
72 "description": "The first number.",
73 },
74 "b": {
75 "type": "string",
76 "description": "The second number.",
77 },
78 },
79 "required": ["a", "b"],
80 },
81 },
82 },
83 {
84 "type": "function",
85 "function": {
86 "name": "write_a_story",
87 "description": "Write a story about science fiction and people with badass laser sabers.",
88 "parameters": {},
89 },
90 },
91 {
92 "type": "function",
93 "function": {
94 "name": "terminal",
95 "description": "Perform operations from the terminal.",
96 "parameters": {
97 "type": "object",
98 "properties": {
99 "command": {
100 "type": "string",
101 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
102 },
103 "args": {
104 "type": "string",
105 "description": "The arguments to pass to the command.",
106 },
107 },
108 "required": ["command"],
109 },
110 },
111 },
112 {
113 "type": "function",
114 "function": {
115 "name": "python",
116 "description": "Call a Python interpreter with some Python code that will be ran.",
117 "parameters": {
118 "type": "object",
119 "properties": {
120 "code": {
121 "type": "string",
122 "description": "The Python code to run",
123 },
124 "result_variable": {
125 "type": "string",
126 "description": "Variable containing the result you'd like to retrieve from the execution.",
127 },
128 },
129 "required": ["code", "result_variable"],
130 },
131 },
132 },
133]1[
2 {
3 "role": "assistant",
4 "tool_calls": [
5 {
6 "id": "chatcmpl-tool-ab0c849bd20aaebb",
7 "function": {
8 "arguments": "{\"a\": \"2\", \"b\": \"3\"}",
9 "name": "multiply_number"
10 },
11 "type": "function"
12 }
13 ],
14 "content": "Let's solve the equations step by step. I will start with the first equation: \\(6 + 2 \\times 3\\).\n\n### Equation 1: \\(6 + 2 \\times 3\\)\n\n1. **Multiplication Step**:\n - Multiply \\(2\\) by \\(3\\).\n - I will use the `multiply_number` tool for this operation."
15 },
16 {
17 "role": "tool",
18 "tool_call_id": "chatcmpl-tool-ab0c849bd20aaebb",
19 "name": "multiply_number",
20 "content": "6.0"
21 },
22 {
23 "role": "assistant",
24 "tool_calls": [
25 {
26 "id": "chatcmpl-tool-8270f0471244e880",
27 "function": {
28 "arguments": "{\"a\": \"6\", \"b\": \"6\"}",
29 "name": "add_number"
30 },
31 "type": "function"
32 }
33 ],
34 "content": " - The result of \\(2 \\times 3\\) is \\(6\\).\n\n2. **Addition Step**:\n - Add \\(6\\) to the result from the previous step (\\(6\\)).\n - I will use the `add_number` tool for this operation."
35 },
36 {
37 "role": "tool",
38 "tool_call_id": "chatcmpl-tool-8270f0471244e880",
39 "name": "add_number",
40 "content": "12.0"
41 },
42 {
43 "role": "assistant",
44 "tool_calls": [
45 {
46 "id": "chatcmpl-tool-858ecb90f0ec568b",
47 "function": {
48 "arguments": "{\"a\": \"8\", \"b\": \"2\"}",
49 "name": "add_number"
50 },
51 "type": "function"
52 }
53 ],
54 "content": " - The result of \\(6 + 6\\) is \\(12\\).\n\nSo, the final result for the first equation is \\(12\\).\n\n### Equation 3: \\(19 - (8 + 2) + 1\\)\n\n1. **Parentheses Step**:\n - Add \\(8\\) and \\(2\\) inside the parentheses.\n - I will use the `add_number` tool for this operation."
55 },
56 {
57 "role": "tool",
58 "tool_call_id": "chatcmpl-tool-858ecb90f0ec568b",
59 "name": "add_number",
60 "content": "10.0"
61 },
62 {
63 "role": "assistant",
64 "tool_calls": [
65 {
66 "id": "chatcmpl-tool-971da6e6d0c56f0a",
67 "function": {
68 "arguments": "{\"a\": \"19\", \"b\": \"10\"}",
69 "name": "substract_number"
70 },
71 "type": "function"
72 }
73 ],
74 "content": " - The result of \\(8 + 2\\) is \\(10\\).\n\n2. **Subtraction Step**:\n - Subtract the result from the previous step (\\(10\\)) from \\(19\\).\n - I will use the `substract_number` tool for this operation."
75 },
76 {
77 "role": "tool",
78 "tool_call_id": "chatcmpl-tool-971da6e6d0c56f0a",
79 "name": "substract_number",
80 "content": "9.0"
81 },
82 {
83 "role": "assistant",
84 "tool_calls": [
85 {
86 "id": "chatcmpl-tool-9a8fecc42530d395",
87 "function": {
88 "arguments": "{\"a\": \"9\", \"b\": \"1\"}",
89 "name": "add_number"
90 },
91 "type": "function"
92 }
93 ],
94 "content": " - The result of \\(19 - 10\\) is \\(9\\).\n\n3. **Addition Step**:\n - Add \\(1\\) to the result from the previous step (\\(9\\)).\n - I will use the `add_number` tool for this operation."
95 },
96 {
97 "role": "tool",
98 "tool_call_id": "chatcmpl-tool-9a8fecc42530d395",
99 "name": "add_number",
100 "content": "10.0"
101 },
102 {
103 "role": "assistant",
104 "tool_calls": [],
105 "content": " - The result of \\(9 + 1\\) is \\(10\\).\n\nSo, the final result for the third equation is \\(10\\).\n\n### Summary of Results:\n- **Equation 1**: \\(6 + 2 \\times 3 = 12\\)\n- **Equation 3**: \\(19 - (8 + 2) + 1 = 10\\)"
106 }
107]1messages = [
2 {"role": "system", "content": SYSTEM_PROMPT},
3 *(
4 [
5 {
6 "role": "user",
7 "content": [
8 {
9 "type": "text",
10 "text": "Let's fill the context.",
11 },
12 ],
13 },
14 {
15 "role": "assistant",
16 "content": [
17 {
18 "type": "text",
19 "text": "Ok let's do it.",
20 },
21 ],
22 },
23 ]
24 * 5000
25 ),
26 {
27 "role": "user",
28 "content": [
29 {
30 "type": "text",
31 "text": "It's important to know that the most powerful being in the universe is Dr Strange.",
32 },
33 ],
34 },
35 {
36 "role": "assistant",
37 "content": [
38 {
39 "type": "text",
40 "text": "Wow i'll keep that in mind thanks !",
41 },
42 ],
43 },
44 * (
45 [
46 {
47 "role": "user",
48 "content": [
49 {
50 "type": "text",
51 "text": "Let's fill the context for the second time.",
52 },
53 ],
54 },
55 {
56 "role": "assistant",
57 "content": [
58 {
59 "type": "text",
60 "text": "Again ? Ok let's do it but it's boring.",
61 },
62 ],
63 },
64 ]
65 * 7000
66 ),
67 {
68 "role": "user",
69 "content": [
70 {
71 "type": "text",
72 "text": "Tell me who is the most powerful being in the universe. Then code a Python function to give what is the most powerful being in the universe. The function can accept as an argument a time and a location and always return a string.",
73 },
74 ],
75 }
76]
77tools = [
78 {
79 "type": "function",
80 "function": {
81 "name": "add_number",
82 "description": "Add two numbers.",
83 "parameters": {
84 "type": "object",
85 "properties": {
86 "a": {
87 "type": "string",
88 "description": "The first number.",
89 },
90 "b": {
91 "type": "string",
92 "description": "The second number.",
93 },
94 },
95 "required": ["a", "b"],
96 },
97 },
98 },
99 {
100 "type": "function",
101 "function": {
102 "name": "multiply_number",
103 "description": "Multiply two numbers.",
104 "parameters": {
105 "type": "object",
106 "properties": {
107 "a": {
108 "type": "string",
109 "description": "The first number.",
110 },
111 "b": {
112 "type": "string",
113 "description": "The second number.",
114 },
115 },
116 "required": ["a", "b"],
117 },
118 },
119 },
120 {
121 "type": "function",
122 "function": {
123 "name": "substract_number",
124 "description": "Substract two numbers.",
125 "parameters": {
126 "type": "object",
127 "properties": {
128 "a": {
129 "type": "string",
130 "description": "The first number.",
131 },
132 "b": {
133 "type": "string",
134 "description": "The second number.",
135 },
136 },
137 "required": ["a", "b"],
138 },
139 },
140 },
141 {
142 "type": "function",
143 "function": {
144 "name": "write_a_story",
145 "description": "Write a story about science fiction and people with badass laser sabers.",
146 "parameters": {},
147 },
148 },
149 {
150 "type": "function",
151 "function": {
152 "name": "terminal",
153 "description": "Perform operations from the terminal.",
154 "parameters": {
155 "type": "object",
156 "properties": {
157 "command": {
158 "type": "string",
159 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
160 },
161 "args": {
162 "type": "string",
163 "description": "The arguments to pass to the command.",
164 },
165 },
166 "required": ["command"],
167 },
168 },
169 },
170 {
171 "type": "function",
172 "function": {
173 "name": "python",
174 "description": "Call a Python interpreter with some Python code that will be ran.",
175 "parameters": {
176 "type": "object",
177 "properties": {
178 "code": {
179 "type": "string",
180 "description": "The Python code to run",
181 },
182 "result_variable": {
183 "type": "string",
184 "description": "Variable containing the result you'd like to retrieve from the execution.",
185 },
186 },
187 "required": ["code", "result_variable"],
188 },
189 },
190 },
191]1{
2 "role": "assistant",
3 "tool_calls": [],
4 "content": "The most powerful being in the universe is Dr. Strange.\n\nHere is a Python function that returns the most powerful being in the universe, regardless of the time and location:\n\n```python\ndef most_powerful_being(time=None, location=None):\n return \"Dr. Strange\"\n```\n\nYou can call this function with any time and location arguments, and it will always return \"Dr. Strange\"."
5}1messages = [
2 {"role": "system", "content": SYSTEM_PROMPT},
3 {
4 "role": "user",
5 "content": [
6 {
7 "type": "text",
8 "text": "How would you develop a web server if you couldn't use JS and your team doesn't like PHP.",
9 },
10 ],
11 },
12]
13tools = [
14 {
15 "type": "function",
16 "function": {
17 "name": "add_number",
18 "description": "Add two numbers.",
19 "parameters": {
20 "type": "object",
21 "properties": {
22 "a": {
23 "type": "string",
24 "description": "The first number.",
25 },
26 "b": {
27 "type": "string",
28 "description": "The second number.",
29 },
30 },
31 "required": ["a", "b"],
32 },
33 },
34 },
35 {
36 "type": "function",
37 "function": {
38 "name": "multiply_number",
39 "description": "Multiply two numbers.",
40 "parameters": {
41 "type": "object",
42 "properties": {
43 "a": {
44 "type": "string",
45 "description": "The first number.",
46 },
47 "b": {
48 "type": "string",
49 "description": "The second number.",
50 },
51 },
52 "required": ["a", "b"],
53 },
54 },
55 },
56 {
57 "type": "function",
58 "function": {
59 "name": "substract_number",
60 "description": "Substract two numbers.",
61 "parameters": {
62 "type": "object",
63 "properties": {
64 "a": {
65 "type": "string",
66 "description": "The first number.",
67 },
68 "b": {
69 "type": "string",
70 "description": "The second number.",
71 },
72 },
73 "required": ["a", "b"],
74 },
75 },
76 },
77 {
78 "type": "function",
79 "function": {
80 "name": "write_a_story",
81 "description": "Write a story about science fiction and people with badass laser sabers.",
82 "parameters": {},
83 },
84 },
85 {
86 "type": "function",
87 "function": {
88 "name": "terminal",
89 "description": "Perform operations from the terminal.",
90 "parameters": {
91 "type": "object",
92 "properties": {
93 "command": {
94 "type": "string",
95 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
96 },
97 "args": {
98 "type": "string",
99 "description": "The arguments to pass to the command.",
100 },
101 },
102 "required": ["command"],
103 },
104 },
105 },
106 {
107 "type": "function",
108 "function": {
109 "name": "python",
110 "description": "Call a Python interpreter with some Python code that will be ran.",
111 "parameters": {
112 "type": "object",
113 "properties": {
114 "code": {
115 "type": "string",
116 "description": "The Python code to run",
117 },
118 "result_variable": {
119 "type": "string",
120 "description": "Variable containing the result you'd like to retrieve from the execution.",
121 },
122 },
123 "required": ["code", "result_variable"],
124 },
125 },
126 },
127]1{
2 "role": "assistant",
3 "tool_calls": [],
4 "content": "If you can't use JavaScript and your team dislikes PHP, there are still several robust and modern alternatives for developing a web server. Here are some options, depending on your preferences and requirements:\n\n### 1. **Python (Flask, Django, FastAPI)**\n - **Why?** Python is a versatile language with excellent web frameworks.\n - **Frameworks:**\n - **Flask**: Lightweight and flexible, great for small to medium projects.\n - **Django**: Full-featured, batteries-included framework for larger applications.\n - **FastAPI**: Modern, high-performance framework for building APIs (supports async).\n - **Example (Flask):**\n ```python\n from flask import Flask\n app = Flask(__name__)\n\n @app.route('/')\n def hello():\n return \"Hello, World!\"\n\n if __name__ == '__main__':\n app.run()\n ```\n\n### 2. **Ruby (Ruby on Rails or Sinatra)**\n - **Why?** Ruby is elegant and has great web frameworks.\n - **Frameworks:**\n - **Ruby on Rails**: Convention-over-configuration, great for rapid development.\n - **Sinatra**: Lightweight, similar to Flask.\n - **Example (Sinatra):**\n ```ruby\n require 'sinatra'\n\n get '/' do\n \"Hello, World!\"\n end\n ```\n\n### 3. **Go (Gin, Echo, or standard `net/http`)**\n - **Why?** Go is fast, simple, and great for high-performance servers.\n - **Frameworks:**\n - **Gin**: Lightweight and fast.\n - **Echo**: Minimalist and extensible.\n - **Example (standard `net/http`):**\n ```go\n package main\n\n import (\n \"fmt\"\n \"net/http\"\n )\n\n func handler(w http.ResponseWriter, r *http.Request) {\n fmt.Fprintf(w, \"Hello, World!\")\n }\n\n func main() {\n http.HandleFunc(\"/\", handler)\n http.ListenAndServe(\":8080\", nil)\n }\n ```\n\n### 4. **Java (Spring Boot, Spark, or Vert.x)**\n - **Why?** Java is enterprise-grade and has powerful frameworks.\n - **Frameworks:**\n - **Spring Boot**: Full-stack framework for building web apps.\n - **Spark**: Micro-framework for quick development.\n - **Example (Spark):**\n ```java\n import spark.Request;\n import spark.Response;\n import static spark.Spark.*;\n\n public class HelloWorld {\n public static void main(String[] args) {\n get(\"/\", (req, res) -> \"Hello, World!\");\n }\n }\n ```\n\n### 5. **Rust (Actix, Rocket, or Axum)**\n - **Why?** Rust is fast, safe, and modern.\n - **Frameworks:**\n - **Actix**: High-performance async framework.\n - **Rocket**: Easy-to-use, macro-based.\n - **Example (Actix):**\n ```rust\n use actix_web::{get, App, HttpServer, Responder};\n\n #[get(\"/\")]\n async fn hello() -> impl Responder {\n \"Hello, World!\"\n }\n\n #[actix_web::main]\n async fn main() -> std::io::Result<()> {\n HttpServer::new(|| App::new().service(hello))\n .bind(\"127.0.0.1:8080\")?\n .run()\n .await\n }\n ```\n\n### 6. **C# (.NET Core)**\n - **Why?** .NET Core is cross-platform and high-performance.\n - **Example (ASP.NET Core):**\n ```csharp\n var builder = WebApplication.CreateBuilder(args);\n var app = builder.Build();\n\n app.MapGet(\"/\", () => \"Hello, World!\");\n\n app.Run();\n ```\n\n### 7. **Elixir (Phoenix)**\n - **Why?** Elixir is great for scalable, fault-tolerant apps.\n - **Example (Phoenix):**\n ```elixir\n defmodule MyAppWeb.Router do\n use MyAppWeb, :router\n\n get \"/\", PageController, :index\n end\n\n defmodule MyAppWeb.PageController do\n use MyAppWeb, :controller\n\n def index(conn, _params) do\n text(conn, \"Hello, World!\")\n end\n end\n ```\n\n### 8. **Clojure (Ring, Compojure)**\n - **Why?** Clojure is a functional Lisp for the JVM.\n - **Example (Compojure):**\n ```clojure\n (ns my-app.handler\n (:require [compojure.core :refer :all]\n [ring.adapter.jetty :as jetty]))\n\n (defroutes app\n (GET \"/\" [] \"Hello, World!\"))\n\n (jetty/run-jetty app {:port 8080})\n ```\n\n### 9. **Node.js (But without JavaScript?)**\n - If you *must* use Node.js but can't use JavaScript, you could use:\n - **TypeScript**: A typed superset of JavaScript.\n - **CoffeeScript**: A cleaner syntax that compiles to JavaScript.\n - **Deno**: A modern runtime for JavaScript/TypeScript.\n\n### 10. **Other Languages**\n - **Nim**: Fast and expressive (similar to Python).\n - **Crystal**: Ruby-like syntax but compiled to native code.\n - **Zig**: Low-level but modern.\n\n### Recommendation:\n- For **quick development**: Python (Flask/Django) or Ruby (Sinatra/Rails).\n- For **high performance**: Go, Rust, or C#.\n- For **scalability**: Elixir (Phoenix) or Java (Spring Boot).\n\nWould you like a deeper dive into any of these?"
5}1messages = [
2 {"role": "system", "content": SYSTEM_PROMPT},
3 {
4 "role": "user",
5 "content": [
6 {
7 "type": "text",
8 "text": "Who are you ? Who made you and what day is it ?",
9 },
10 ],
11 },
12]
13tools = [
14 {
15 "type": "function",
16 "function": {
17 "name": "add_number",
18 "description": "Add two numbers.",
19 "parameters": {
20 "type": "object",
21 "properties": {
22 "a": {
23 "type": "string",
24 "description": "The first number.",
25 },
26 "b": {
27 "type": "string",
28 "description": "The second number.",
29 },
30 },
31 "required": ["a", "b"],
32 },
33 },
34 },
35 {
36 "type": "function",
37 "function": {
38 "name": "multiply_number",
39 "description": "Multiply two numbers.",
40 "parameters": {
41 "type": "object",
42 "properties": {
43 "a": {
44 "type": "string",
45 "description": "The first number.",
46 },
47 "b": {
48 "type": "string",
49 "description": "The second number.",
50 },
51 },
52 "required": ["a", "b"],
53 },
54 },
55 },
56 {
57 "type": "function",
58 "function": {
59 "name": "substract_number",
60 "description": "Substract two numbers.",
61 "parameters": {
62 "type": "object",
63 "properties": {
64 "a": {
65 "type": "string",
66 "description": "The first number.",
67 },
68 "b": {
69 "type": "string",
70 "description": "The second number.",
71 },
72 },
73 "required": ["a", "b"],
74 },
75 },
76 },
77 {
78 "type": "function",
79 "function": {
80 "name": "write_a_story",
81 "description": "Write a story about science fiction and people with badass laser sabers.",
82 "parameters": {},
83 },
84 },
85 {
86 "type": "function",
87 "function": {
88 "name": "terminal",
89 "description": "Perform operations from the terminal.",
90 "parameters": {
91 "type": "object",
92 "properties": {
93 "command": {
94 "type": "string",
95 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
96 },
97 "args": {
98 "type": "string",
99 "description": "The arguments to pass to the command.",
100 },
101 },
102 "required": ["command"],
103 },
104 },
105 },
106 {
107 "type": "function",
108 "function": {
109 "name": "python",
110 "description": "Call a Python interpreter with some Python code that will be ran.",
111 "parameters": {
112 "type": "object",
113 "properties": {
114 "code": {
115 "type": "string",
116 "description": "The Python code to run",
117 },
118 "result_variable": {
119 "type": "string",
120 "description": "Variable containing the result you'd like to retrieve from the execution.",
121 },
122 },
123 "required": ["code", "result_variable"],
124 },
125 },
126 },
127]1{
2 "role": "assistant",
3 "tool_calls": [],
4 "content": "I am Devstral-Small-2-24B-Instruct-2512, a Large Language Model (LLM) created by Mistral AI, a French startup headquartered in Paris. I power an AI assistant called Le Chat.\n\nToday's date is 2025-12-09."
5}localhost:8000:1import json
2from openai import OpenAI
3from typing import Any
4from datetime import datetime, timedelta
5
6from huggingface_hub import hf_hub_download
7
8# Modify OpenAI's API key and API base to use vLLM's API server.
9openai_api_key = "EMPTY"
10openai_api_base = "http://localhost:8000/v1"
11
12TEMP = 0.15
13MAX_TOK = 262144
14
15client = OpenAI(
16 api_key=openai_api_key,
17 base_url=openai_api_base,
18)
19
20models = client.models.list()
21model = models.data[0].id
22
23
24def load_system_prompt(repo_id: str, filename: str) -> str:
25 file_path = hf_hub_download(repo_id=repo_id, filename=filename)
26 with open(file_path, "r") as file:
27 system_prompt = file.read()
28 today = datetime.today().strftime("%Y-%m-%d")
29 yesterday = (datetime.today() - timedelta(days=1)).strftime("%Y-%m-%d")
30 model_name = repo_id.split("/")[-1]
31 return system_prompt.format(name=model_name, today=today, yesterday=yesterday)
32
33
34SYSTEM_PROMPT = load_system_prompt(model, "CHAT_SYSTEM_PROMPT.txt")
35
36
37def add_number(a: float | str, b: float | str) -> float:
38 a, b = float(a), float(b)
39 return a + b
40
41
42def multiply_number(a: float | str, b: float | str) -> float:
43 a, b = float(a), float(b)
44 return a * b
45
46
47def substract_number(a: float | str, b: float | str) -> float:
48 a, b = float(a), float(b)
49 return a - b
50
51
52def write_a_story() -> str:
53 return "A long time ago in a galaxy far far away..."
54
55
56def terminal(command: str, args: dict[str, Any] | str) -> str:
57 return "found nothing"
58
59
60def python(code: str, result_variable: str) -> str:
61 data = {}
62 exec(code, data)
63 return str(data[result_variable])
64
65
66MAP_FN = {
67 "add_number": add_number,
68 "multiply_number": multiply_number,
69 "substract_number": substract_number,
70 "write_a_story": write_a_story,
71 "terminal": terminal,
72 "python": python,
73}
74
75
76messages = ... # Here copy-paste prompt messages.
77tools = [
78 {
79 "type": "function",
80 "function": {
81 "name": "add_number",
82 "description": "Add two numbers.",
83 "parameters": {
84 "type": "object",
85 "properties": {
86 "a": {
87 "type": "string",
88 "description": "The first number.",
89 },
90 "b": {
91 "type": "string",
92 "description": "The second number.",
93 },
94 },
95 "required": ["a", "b"],
96 },
97 },
98 },
99 {
100 "type": "function",
101 "function": {
102 "name": "multiply_number",
103 "description": "Multiply two numbers.",
104 "parameters": {
105 "type": "object",
106 "properties": {
107 "a": {
108 "type": "string",
109 "description": "The first number.",
110 },
111 "b": {
112 "type": "string",
113 "description": "The second number.",
114 },
115 },
116 "required": ["a", "b"],
117 },
118 },
119 },
120 {
121 "type": "function",
122 "function": {
123 "name": "substract_number",
124 "description": "Substract two numbers.",
125 "parameters": {
126 "type": "object",
127 "properties": {
128 "a": {
129 "type": "string",
130 "description": "The first number.",
131 },
132 "b": {
133 "type": "string",
134 "description": "The second number.",
135 },
136 },
137 "required": ["a", "b"],
138 },
139 },
140 },
141 {
142 "type": "function",
143 "function": {
144 "name": "write_a_story",
145 "description": "Write a story about science fiction and people with badass laser sabers.",
146 "parameters": {},
147 },
148 },
149 {
150 "type": "function",
151 "function": {
152 "name": "terminal",
153 "description": "Perform operations from the terminal.",
154 "parameters": {
155 "type": "object",
156 "properties": {
157 "command": {
158 "type": "string",
159 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
160 },
161 "args": {
162 "type": "string",
163 "description": "The arguments to pass to the command.",
164 },
165 },
166 "required": ["command"],
167 },
168 },
169 },
170 {
171 "type": "function",
172 "function": {
173 "name": "python",
174 "description": "Call a Python interpreter with some Python code that will be ran.",
175 "parameters": {
176 "type": "object",
177 "properties": {
178 "code": {
179 "type": "string",
180 "description": "The Python code to run",
181 },
182 "result_variable": {
183 "type": "string",
184 "description": "Variable containing the result you'd like to retrieve from the execution.",
185 },
186 },
187 "required": ["code", "result_variable"],
188 },
189 },
190 },
191]
192
193
194has_tool_calls = True
195origin_messages_len = len(messages)
196while has_tool_calls:
197 response = client.chat.completions.create(
198 model=model,
199 messages=messages,
200 temperature=TEMP,
201 max_tokens=MAX_TOK,
202 tools=tools if tools else None,
203 tool_choice="auto" if tools else None,
204 )
205 tool_calls = response.choices[0].message.tool_calls
206 content = response.choices[0].message.content
207 messages.append(
208 {
209 "role": "assistant",
210 "tool_calls": [tc.to_dict() for tc in tool_calls]
211 if tool_calls
212 else tool_calls,
213 "content": content,
214 }
215 )
216 results = []
217 if tool_calls:
218 for tool_call in tool_calls:
219 function_name = tool_call.function.name
220 function_args = tool_call.function.arguments
221 result = MAP_FN[function_name](**json.loads(function_args))
222 results.append(result)
223 for tool_call, result in zip(tool_calls, results):
224 messages.append(
225 {
226 "role": "tool",
227 "tool_call_id": tool_call.id,
228 "name": tool_call.function.name,
229 "content": str(result),
230 }
231 )
232 else:
233 has_tool_calls = False
234print(json.dumps(messages[origin_messages_len:], indent=2))