Skip to content

Commit 28c7c01

Browse files
committed
Update function calling README
1 parent 9229dd5 commit 28c7c01

File tree

1 file changed

+33
-5
lines changed
  • blogs/agentic-workflows/max-serve-openai-function-calling

1 file changed

+33
-5
lines changed

blogs/agentic-workflows/max-serve-openai-function-calling/README.md

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ In this blog, we will:
1010
- Showcase how MAX Serve can facilitate local and cloud deployment of LLM-based applications.
1111
- Walk through a working example that you can clone and run locally.
1212

13-
Note that this feature is available in [MAX nightly 25.1.0.dev2025012905](https://github.com/modular/max/commit/2f83e343a4d28a341570b2aab7131ff2da3e19d5) and the code is available in our [GitHub repository](https://github.com/modular/devrel-extras/tree/main/blogs/agentic-workflows/max-serve-openai-function-calling).
13+
Note that this feature is available in [MAX nightly 25.1.0.dev2025012905](https://github.com/modular/max/commit/2f83e343a4d28a341570b2aab7131ff2da3e19d5) which corresponds to this nightly MAX Serve docker image
14+
[docker.modular.com/modular/max-openai-api:25.1.0.dev2025012905](https://hub.docker.com/layers/modular/max-openai-api/25.1.0.dev2025012905/images/sha256-332299d35cda7c7072df9c61b08d736781948f8f104504797200a9c7b7f599d5)
15+
16+
The code is available in our [GitHub repository](https://github.com/modular/devrel-extras/tree/main/blogs/agentic-workflows/max-serve-openai-function-calling).
1417

1518
To proceed, please make sure to install magic` CLI
1619

@@ -43,7 +46,14 @@ Function calling allows LLMs to enhance their responses by:
4346

4447
## Implementing function calling with OpenAI
4548

46-
To illustrate function calling, let's start with a simple example where an AI retrieves the weather using a mock function.
49+
First things first, you can run the MAX Serve easily on both CPU and GPU as follows:
50+
51+
```bash
52+
magic global install max-pipelines
53+
max-serve serve --huggingface-repo-id=modularai/llama-3.1
54+
```
55+
56+
Then to illustrate function calling, let's start with a simple example where an AI retrieves the weather using a mock function.
4757

4858
### `single_function_call.py`
4959

@@ -104,7 +114,14 @@ Run the example via:
104114
magic run single_function_call
105115
```
106116

107-
Note that the very first compilation of the model can take a few minutes. The next invocations will be much faster.
117+
which outputs:
118+
119+
```txt
120+
User message: What's the weather like in San Francisco?
121+
Weather response: The weather in San Francisco is sunny with a temperature of 72°F
122+
```
123+
124+
**Note** that the very first compilation of the model can take a few minutes. The next invocations will be much faster.
108125

109126
### Understanding the function calling format
110127

@@ -219,7 +236,17 @@ The LLM can now determine when to call `get_weather` or `get_air_quality` based
219236
Run the example via:
220237

221238
```bash
222-
magic run muli_function_calls
239+
magic run multi_function_calls
240+
```
241+
242+
which outputs:
243+
244+
```txt
245+
User message: What's the weather like in San Francisco?
246+
Weather response: The weather in San Francisco is sunny with a temperature of 72°F
247+
248+
User message: What's the air quality like in San Francisco?
249+
Air quality response: The air quality in San Francisco is good with a PM2.5 of 10µg/m³
223250
```
224251

225252
## Deploying with MAX Serve
@@ -437,5 +464,6 @@ OpenAI's function calling and MAX Serve together provide an efficient way to bui
437464
Now that you've implemented function calling with MAX Serve, you can explore more advanced features and join our developer community. Here are some resources to help you continue your journey:
438465

439466
- [Get started with MAX](https://docs.modular.com/max/get-started)
440-
- Explore [MAX Serve](https://docs.modular.com/max/serve) and [Magic tutorial](https://docs.modular.com/max/tutorials/magic).
467+
- Explore [MAX Serve](https://docs.modular.com/max/serve) and [MAX Container](https://docs.modular.com/max/container/)
468+
- Learn more about `magic` CLI in this [Magic tutorial](https://docs.modular.com/max/tutorials/magic)
441469
- Join our [Discord](https://discord.gg/modular) and our [Modular forum](https://forum.modular.com/)

0 commit comments

Comments
 (0)