Skip to content

Commit fabde81

Browse files
fpagnybene2k1jcirinosclwynerda-codes
authored andcommitted
Update use-function-calling.mdx (scaleway#4416)
* Update use-function-calling.mdx Add response display to tool call and update step descriptions * Apply suggestions from code review * Apply suggestions from code review Co-authored-by: Jessica <[email protected]> Co-authored-by: Néda <[email protected]> --------- Co-authored-by: Benedikt Rollik <[email protected]> Co-authored-by: Jessica <[email protected]> Co-authored-by: Néda <[email protected]>
1 parent b384bb9 commit fabde81

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

pages/generative-apis/how-to/use-function-calling.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ tools = [{
110110

111111
### Simple function call example
112112

113-
Here is how to implement a basic function call:
113+
To implement a basic function call, add the following code:
114114

115115
```python
116116
# Initialize the OpenAI client
@@ -138,6 +138,13 @@ response = client.chat.completions.create(
138138
tools=tools,
139139
tool_choice="auto"
140140
)
141+
142+
print(response.choices[0].message.tool_calls)
143+
```
144+
145+
As the model detects properly that a tool call is required to answer the question, the output should be a list of tool calls specifying function names and parameter properties:
146+
```bash
147+
[ChatCompletionMessageToolCall(id='chatcmpl-tool-81e63f4f496d429ba9ec6efcff6a86e1', function=Function(arguments='{"departure_airport": "CDG", "destination_airport": "LHR", "departure_date": "2024-11-01"}', name='get_flight_schedule'), type='function')]
141148
```
142149

143150
<Message type="note">
@@ -148,9 +155,9 @@ response = client.chat.completions.create(
148155
Some models must be told they can use external functions in the system prompt. If you do not provide a system prompt when using tools, Scaleway will automatically add one that works best for that specific model.
149156
</Message>
150157

151-
### Multi-turn conversation handling
158+
### Call the tool and provide a final answer
152159

153-
For more complex interactions, you will need to handle multiple turns of conversation:
160+
To provide the answer, or for more complex interactions, you will need to handle multiple turns of conversation:
154161

155162
```python
156163
# Process the tool call
@@ -328,5 +335,5 @@ For more information about function calling and advanced implementations, refer
328335
Function calling significantly extends the capabilities of language models by allowing them to interact with external tools and APIs.
329336

330337
<Message type="note">
331-
We can't wait to see what you will build with function calls. Tell us what you are up to, share your experiments on Scaleway's [Slack community](https://slack.scaleway.com/) #ai
332-
</Message>
338+
We cannot wait to see what you will build with function calls. Tell us what you are up to, and share your experiments on Scaleway's [Slack community](https://slack.scaleway.com/) in the #ai channel.
339+
</Message>

0 commit comments

Comments
 (0)