# Parallel Function Calling

**URL:** <https://community.openai.com/t/parallel-function-calling/626868>\
**Category:** API\
**Tags:** functions, function-calling, tools, tool-choice\
**Created:** [February 14, 2024, 5:40pm UTC](https://community.openai.com/t/parallel-function-calling/626868 "2024-02-14T17:40:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhinabamitra19](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@abhinabamitra19](https://community.openai.com/u/abhinabamitra19)\
**Post date:** [February 14, 2024, 5:40pm UTC](https://community.openai.com/t/parallel-function-calling/626868/1 "2024-02-14T17:40:53Z")

</div>

Given the current documentation described [here] ([https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool\_choice](https://platform.openai.com/docs/api-reference/chat/create#chat-create-tool_choice)), regarding the use of parallel function calling.

I have 5 different `function` with the following format:

```auto
tools = [
{"type":"function",
"function":{
"name":"<function_a>"
...
},{
....
},
...
]

```

as is described by the docs. I am assuming that since I have specified the function signature, i should expect GPT to call all 5 functions.

```auto
def response_generator():
    response = client.chat.completions.create(
        model="gpt-3.5-turbo-1106",
        temperature=0,
        messages=messages,
        tools=tools,
        tool_choice="auto",
    )
    return response

```

Problem is the response object has only 2 objects in the `tool_calls` attribute, although i want all 5 to be called.

Do i have to specify something in the prompt or not put “auto” in the `tool_choice` parameter. If not, what should i put there?

What am i missing?

Any help is appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![jlvanhulst](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/jlvanhulst/32/195305_2.png) [@jlvanhulst](https://community.openai.com/u/jlvanhulst)\
**Post date:** [February 14, 2024, 5:44pm UTC](https://community.openai.com/t/parallel-function-calling/626868/2 "2024-02-14T17:44:32Z")

</div>

Few things … if you ALWAYS want all 5 to be called why not create on function. That would be way more efficient.

Functions will be called based on their instructions (What is in the function description) and your prompt. So you CAN instruct the model to ALWAYS call all five.

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [February 14, 2024, 5:57pm UTC](https://community.openai.com/t/parallel-function-calling/626868/3 "2024-02-14T17:57:59Z")

</div>

> [@abhinabamitra19](#):
>
> What am i missing?

I have found that the AI just seems not to be trained on using its multi\_tool\_use wrapper to call different functions at the same time. It will do parallel calls to the same function almost too easily though.

For example, I have both a float and an int random number generator function:

- ask the AI to roll four dice and give results: four functions in tool calls.
- ask the AI to just give a random int and a random float: just one function.

Adding “Can operate in parallel with other function types.” to all function descriptions? No difference.

Unlike “devday”, the AI isn’t going to lock your car and roll up the windows in the same tool\_call unless the parameters are in the same function.

I finally got this to go with the additional description on gpt-4-turbo-preview:

```auto

        "tool_calls": [
          {
            "id": "call_Z8jTwVecJP7o4Tot5tD3suMo",
            "function": {
              "arguments": "{\"range_start\": 0, \"range_end\": 66}",
              "name": "get_random_float"
            },
            "type": "function"
          },
          {
            "id": "call_AeiKMGkPzxzZosOuVlsexbEg",
            "function": {
              "arguments": "{\"range_start\": 1, \"range_end\": 33}",
              "name": "get_random_int"
            },
            "type": "function"
          }
        ]

```

---

<div class="post-metadata">

**Author:** ![abhinabamitra19](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@abhinabamitra19](https://community.openai.com/u/abhinabamitra19)\
**Post date:** [February 14, 2024, 6:27pm UTC](https://community.openai.com/t/parallel-function-calling/626868/4 "2024-02-14T18:27:45Z")

</div>

Hi! thanks for the input and suggestions ! I’ll give it a go
