Call functions from custom LLM
# support
m
Hi all 👋 I'm using a custom LLM on my Vapi assistant and I want to trigger the basic phone functionalities provided by default: call end, call transfer and dial. I don't understant how I should generate the chunk for the tool call in order to trigger the action or if there is some configuration to do to enable these functionalities ( I already enabled the check on functions menu) Thanks for your support!
v
@Marco Falcone Hello there! 👋 Great to hear that you're using a custom LLM with your Vapi assistant. To trigger the basic phone functionalities such as call end, call transfer, and dial, you would typically use specific commands or API calls that are designed for those actions. Since you've mentioned that you've already enabled the check on the functions menu, you're on the right track. The next step is to ensure that your custom LLM can generate the appropriate commands or API calls that correspond to the actions you want to trigger. For example, if you want to end a call, your LLM should generate a command or an API call that is recognized by Vapi as an instruction to end the call. The same goes for call transfer and dialing functionalities. If you're unsure about the exact format or the API calls needed to trigger these actions, you may need to refer to the Vapi documentation or ask support for more info on this. They can provide you with the specific syntax or commands that your custom LLM needs to output in order to interact with the phone functionalities. If you have any specific commands or API calls in mind and need assistance on how to format them for the tool call, please let me know, and I'll be happy to help you further!
You can continue this conversation by mentioning me in the message.
m
@Vapi I tried to send the following chunk for call end:
Copy code
json
{
  "id": "indigoai-1",
  "object": "chat.completion.chunk",
  "created": 63904351243,
  "model": "ndg",
  "system_fingerprint": "fp_ndg",
  "choices": [
    {
      "delta": {
      "tool_calls": [
         {
           "function": {
              "arguments": "{}",
              "name": "endCall"
           },
           "id": "call_84934067-e51f-4380-a76e-0dfb8f32ff8a_0",
           "index": 0
         }
       ]
     },
     "finish_reason": "function_call",
     "index": 0,
     "logprobs": null
    }
  ]
}
Is this correct?
v
@Marco Falcone The chunk you've provided seems to be structured correctly for a tool call, but it's important to ensure that the function name and arguments match exactly with what the Vapi system expects. In the chunk you've sent, the function name is
endCall
, and it's being called with an empty arguments object
{}
. However, I don't have the exact specifications for the
endCall
function or other related functions like
transferCall
or
dial
in the context provided. If
endCall
is indeed the correct function name and it requires no arguments, then your chunk should work as intended. If you're not sure about the function names or the required arguments, please refer to the Vapi documentation or ask support for the correct specifications. If
endCall
is not the correct function name or if there are specific arguments needed, you'll need to adjust the chunk accordingly. If you need further assistance with the correct function names or arguments, please let me know, and I'll be glad to help!
m
@Vapi I need assistance with the naming
v
@Marco Falcone Please ask support for more info on this.
m
Please 🙏
s
@Marco Falcone Try out the following code snippet and let me know how it goes.
Copy code
py
                if request_payload.function_name == "transferCall" and request_payload.destination:
                    function_call_payload = {
                        "function_call": {
                            "name": request_payload.function_name,
                            "arguments": {
                                "destination": request_payload.destination
                            },
                        }
                    }
                    yield f"data: {json.dumps(function_call_payload)}\n\n"
Do let me know, how can i help you next.
m
This doesn't work for me. I try to give you more context. This is the request on call start arriving to my custom LLM
As you can see I defined
endCall
,
transferCall
and
dtmf
tools and they are provided in the request to my LLM. My LLM responses are in chunks. If I try to return a chunk like the one you suggest Vapi crashes. If I wrap the function call in a chunk structure, Vapi play the text provided but doesn't execute the function. I'm trying the behavior from dashbord web preview with the
endCall
tool. I don't know if this can be relevant. Here is an example of returned chunkes:
Copy code
data: {"choices":[{"delta":{"content":"Goodmorning! Ask me anything.","role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":63904584257,"id":"indigoai-5fc61008-5310-4b97-98d3-09b9d12fc19d","model":"ndg","object":"chat.completion.chunk","system_fingerprint":"fp_ndg"}


data: {"choices":[{"delta":{"content":null,"tool_calls":[{"function":{"arguments":{},"name":"endCall"},"id":"call_5fc61008-5310-4b97-98d3-09b9d12fc19d_0","index":0}]},"finish_reason":"function_call","index":0,"logprobs":null}],"created":63904584257,"id":"indigoai-5fc61008-5310-4b97-98d3-09b9d12fc19d","model":"ndg","object":"chat.completion.chunk","system_fingerprint":"fp_ndg"}


data: {"choices":[{"delta":{},"finish_reason":"stop","index":0,"logprobs":null}],"created":63904584257,"id":"indigoai-5fc61008-5310-4b97-98d3-09b9d12fc19d","model":"ndg","object":"chat.completion.chunk","system_fingerprint":"fp_ndg"}
Is there something wrong in the chunks I produce? Thanks for your help 🙏
@Shubham Bajaj sorry to bother, have you any other advice on this?
s
@Marco Falcone available for a quick call?
m
Sure
s
check your DM.
3 Views