Views
No views yet
| 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.Ollama: https://ollama.com/library/devstral-2uv pip install -U vllm \
--torch-backend=auto \
--extra-index-url https://wheels.vllm.ai/nightlydocker pull vllm/vllm-openai:nightly
docker run -it vllm/vllm-openai:nightly[!Warning] Make sure that your vllm installation includes this commit. If you do not have this commit included, you will get incorrectly parsed tool calls.
mistral_common >= 1.8.6.
To check:python -c "import mistral_common; print(mistral_common.__version__)"vllm serve mistralai/Devstral-2-123B-Instruct-2512 \
--tool-call-parser mistral --enable-auto-tool-choice \
--tensor-parallel-size 81import 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-2-123B-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 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 # requiredpython -m sglang.launch_server --model-path mistralai/Devstral-2-123B-Instruct-2512 --host 0.0.0.0 --port 30000 --tp 8 --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-2-123B-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 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/transformers1from transformers import (
2 MistralForCausalLM,
3 MistralCommonBackend,
4)
5
6model_id = "mistralai/Devstral-2-123B-Instruct-2512"
7
8tokenizer = MistralCommonBackend.from_pretrained(model_id)
9model = MistralForCausalLM.from_pretrained(model_id, device_map="auto")
10
11SP = """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.
12
13You can:
14
15- Receive user prompts, project context, and files.
16- Send responses and emit function calls (e.g., shell commands, code edits).
17- Apply patches, run commands, based on user approvals.
18
19Answer 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.
20
21Always 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.
22
23Act as an agentic assistant, if a user asks for a long task, break it down and do it step by step.
24
25When 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.
26
27```bash
28git commit -m "<Commit message here>
29
30Generated by Mistral Vibe.
31Co-Authored-By: Mistral Vibe <vibe@mistral.ai>"
32```"""
33
34input = {
35 "messages": [
36 {
37 "role": "system",
38 "content": SP,
39 },
40 {
41 "role": "user",
42 "content": [
43 {
44 "type": "text",
45 "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.",
46 }
47 ],
48 },
49 ],
50 "tools": [
51 {
52 "type": "function",
53 "function": {
54 "name": "add_number",
55 "description": "Add two numbers.",
56 "parameters": {
57 "type": "object",
58 "properties": {
59 "a": {"type": "string", "description": "The first number."},
60 "b": {"type": "string", "description": "The second number."},
61 },
62 "required": ["a", "b"],
63 },
64 },
65 },
66 {
67 "type": "function",
68 "function": {
69 "name": "multiply_number",
70 "description": "Multiply two numbers.",
71 "parameters": {
72 "type": "object",
73 "properties": {
74 "a": {"type": "string", "description": "The first number."},
75 "b": {"type": "string", "description": "The second number."},
76 },
77 "required": ["a", "b"],
78 },
79 },
80 },
81 {
82 "type": "function",
83 "function": {
84 "name": "substract_number",
85 "description": "Substract two numbers.",
86 "parameters": {
87 "type": "object",
88 "properties": {
89 "a": {"type": "string", "description": "The first number."},
90 "b": {"type": "string", "description": "The second number."},
91 },
92 "required": ["a", "b"],
93 },
94 },
95 },
96 {
97 "type": "function",
98 "function": {
99 "name": "write_a_story",
100 "description": "Write a story about science fiction and people with badass laser sabers.",
101 "parameters": {},
102 },
103 },
104 {
105 "type": "function",
106 "function": {
107 "name": "terminal",
108 "description": "Perform operations from the terminal.",
109 "parameters": {
110 "type": "object",
111 "properties": {
112 "command": {
113 "type": "string",
114 "description": "The command you wish to launch, e.g `ls`, `rm`, ...",
115 },
116 "args": {
117 "type": "string",
118 "description": "The arguments to pass to the command.",
119 },
120 },
121 "required": ["command"],
122 },
123 },
124 },
125 {
126 "type": "function",
127 "function": {
128 "name": "python",
129 "description": "Call a Python interpreter with some Python code that will be ran.",
130 "parameters": {
131 "type": "object",
132 "properties": {
133 "code": {
134 "type": "string",
135 "description": "The Python code to run",
136 },
137 "result_variable": {
138 "type": "string",
139 "description": "Variable containing the result you'd like to retrieve from the execution.",
140 },
141 },
142 "required": ["code", "result_variable"],
143 },
144 },
145 },
146 ],
147}
148
149tokenized = tokenizer.apply_chat_template(
150 conversation=input["messages"],
151 tools=input["tools"],
152 return_tensors="pt",
153 return_dict=True,
154)
155
156input_ids = tokenized["input_ids"].to(device="cuda")
157
158output = model.generate(
159 input_ids,
160 max_new_tokens=200,
161 do_sample=True,
162 temperature=0.15,
163)[0]
164
165decoded_output = tokenizer.decode(output[len(tokenized["input_ids"][0]) :])
166print(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": "\n1. 6 + 2 x 3\n2. 3a + 7b - 2a\n19 - (8+2) + 1\n4. 5y (6x - 7).\n\nCompute the results steps by steps for the equations that involve only numbers ? You have to call tools to perform the operations and can do one operation at a time per equation."
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-84aa136ef835f886",
7 "function": {
8 "arguments": "{\"a\": \"2\", \"b\": \"3\"}",
9 "name": "multiply_number"
10 },
11 "type": "function"
12 }
13 ],
14 "content": "Let's compute the results step by step for the equations that involve only numbers.\n\n### 1. \\( 6 + 2 \\times 3 \\)\n\nFirst, we perform the multiplication \\( 2 \\times 3 \\):\n"
15 },
16 {
17 "role": "tool",
18 "tool_call_id": "chatcmpl-tool-84aa136ef835f886",
19 "name": "multiply_number",
20 "content": "6.0"
21 },
22 {
23 "role": "assistant",
24 "tool_calls": [
25 {
26 "id": "chatcmpl-tool-bedc049b0a248952",
27 "function": {
28 "arguments": "{\"a\": \"6\", \"b\": \"6\"}",
29 "name": "add_number"
30 },
31 "type": "function"
32 }
33 ],
34 "content": "Now, we add the result to 6:\n"
35 },
36 {
37 "role": "tool",
38 "tool_call_id": "chatcmpl-tool-bedc049b0a248952",
39 "name": "add_number",
40 "content": "12.0"
41 },
42 {
43 "role": "assistant",
44 "tool_calls": [
45 {
46 "id": "chatcmpl-tool-ae4558bc0558f4e7",
47 "function": {
48 "arguments": "{\"a\": \"8\", \"b\": \"2\"}",
49 "name": "add_number"
50 },
51 "type": "function"
52 }
53 ],
54 "content": "The result of \\( 6 + 2 \\times 3 \\) is **12**.\n\n---\n\n### 3. \\( 19 - (8 + 2) + 1 \\)\n\nFirst, we compute the expression inside the parentheses \\( 8 + 2 \\):\n"
55 },
56 {
57 "role": "tool",
58 "tool_call_id": "chatcmpl-tool-ae4558bc0558f4e7",
59 "name": "add_number",
60 "content": "10.0"
61 },
62 {
63 "role": "assistant",
64 "tool_calls": [
65 {
66 "id": "chatcmpl-tool-b21f003d298e65df",
67 "function": {
68 "arguments": "{\"a\": \"19\", \"b\": \"10\"}",
69 "name": "substract_number"
70 },
71 "type": "function"
72 }
73 ],
74 "content": "Next, we subtract the result from 19:\n"
75 },
76 {
77 "role": "tool",
78 "tool_call_id": "chatcmpl-tool-b21f003d298e65df",
79 "name": "substract_number",
80 "content": "9.0"
81 },
82 {
83 "role": "assistant",
84 "tool_calls": [
85 {
86 "id": "chatcmpl-tool-bb7628cded899f04",
87 "function": {
88 "arguments": "{\"a\": \"9\", \"b\": \"1\"}",
89 "name": "add_number"
90 },
91 "type": "function"
92 }
93 ],
94 "content": "Finally, we add 1 to the result:\n"
95 },
96 {
97 "role": "tool",
98 "tool_call_id": "chatcmpl-tool-bb7628cded899f04",
99 "name": "add_number",
100 "content": "10.0"
101 },
102 {
103 "role": "assistant",
104 "tool_calls": [],
105 "content": "The result of \\( 19 - (8 + 2) + 1 \\) is **10**.\n\n---\n\n### Summary of Results:\n1. \\( 6 + 2 \\times 3 = 12 \\)\n3. \\( 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-2-123B-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))