Function calling not working
# support
s
The function call appears to be working correctly. I've just created a simple test assistant that asks for the customer's name and performs the function call on the Pipedream server. Could you please confirm if you added the necessary properties when creating the custom function? // @westy412
s
works for me as well.
w
I'm doing it in Flask. Made sure all the properties are there. The function is called and returns "success" rather than the availability. All the function does is get the availability and does not have any parameters. In testing the endpoint in postman it works fine however during a call nothing is returned. Here is the code that handles the function.
Copy code
python
@app.route('/functions', methods=['POST'])
def functions():
  data = request.get_json()
  payload = data.get('message')
  print(payload["type"])

  if payload['type'] == 'end-of-call-report':
    call_analysis(data)
    return jsonify({"result": "call analysed"})

  elif payload["type"] == "function-call":
    function_call = payload.get('functionCall')

    if not function_call:
      raise ValueError("Invalid function call")

    function_name = function_call.get('name')
    parameters = function_call.get('parameters')

    if function_name == "get_availability":
      availability = get_free_slots()
      print("AVAILABILITY FUNCTION CALLED", "\n")
      return jsonify({"result": availability})

  else:
      raise ValueError("Unhandled message type")
Has been sorted now, the issue was that I had left async = True while i required a response
However Groq still seems to not work, stops responding and hangs up before the silence timeout.
g
Did they say that function calling not available through groq ?
w
I'm not sure but was under the impression that Mixtral - Groq now does support function calling through their api.
just checked and it was just JSON mode
g
so not possible at this time given the way it is implemented in vapi ?
n
Groq doesn't support function calling yet
If they add it, it'll work out of the box with VAPI
t
@nikhil Groq added function calling, When are we going to have it on VAPI ? Tried to add it my self using custom llm server, but there is the streaming limitation. any thoughts on this ?
e
I'm waiting too. Any info about that to be implemented on Vapi?
s
Add a feature request here https://vapi.canny.io/feature-requests and if your feature request gets the most vote we will work on it.
e
This were a promise from Vapi. Do You changed your mind about that?
s
When did we promise it?
e
Here
s
They still don't support function calling via streaming.
s
Can you tell me exact timestamp where they mentioned function calling is supported via STREAMING?
e
I request from chatbot from Groq now. Yes, Groq supports calling functions via streaming. Groq is a query engine that allows you to execute complex queries on large datasets in a scalable and efficient manner. One of the key features of Groq is its support for streaming queries, which enables you to process large datasets in a streaming fashion. In Groq, you can define functions that can be called via streaming, which allows you to process data in a streaming fashion. This is particularly useful when working with large datasets that don't fit into memory or when you need to perform real-time processing on data as it arrives. When you define a function in Groq, you can specify whether it should be executed in a streaming fashion or not. If you specify that a function should be executed in a streaming fashion, Groq will execute the function on each incoming data point, rather than processing the entire dataset at once. Groq provides a number of built-in functions that can be used to process data in a streaming fashion, such as the
map
function, which applies a user-defined function to each element in a stream of data. You can also define your own custom functions that can be used to process data in a streaming fashion. Overall, Groq's support for streaming queries and functions makes it a powerful tool for processing large datasets in a scalable and efficient manner.
Here is an example of how you can implement a streaming function in Groq: Let's say you have a dataset of user activity logs, and you want to calculate the total number of clicks for each user. You can define a streaming function in Groq that takes in a stream of user activity logs and returns the total number of clicks for each user. Here is an example of how you can define this function in Groq:
Copy code
streaming function total_clicks(user_activity_log: struct {
  user_id: string,
  click: bool
}) -> struct {
  user_id: string,
  total_clicks: int
} {
  let clicks = 0;
  foreach (user_activity_log) {
    if (user_activity_log.click) {
      clicks++;
    }
  }
  return { user_id: user_activity_log.user_id, total_clicks: clicks };
}
In this example, the
total_clicks
function takes in a stream of user activity logs and returns a new stream of structs that contain the total number of clicks for each user. The function uses a
foreach
loop to iterate over the stream of user activity logs, and increments a counter
clicks
each time it encounters a log that indicates a click. Finally, the function returns a new struct that contains the user ID and the total number of clicks for that user. You can then use this function in a Groq query to calculate the total number of clicks for each user:
Copy code
SELECT total_clicks(user_activity_log) AS total_clicks
FROM user_activity_log
GROUP BY user_id
This query will execute the
total_clicks
function on each user activity log in the dataset, and return a new stream of structs that contain the total number of clicks for each user. I hope this helps! Let me know if you have any questions.
s
Yeah, it is supported now. We will add it.
It is supported.
You can use function calling with GROQ Now.
e
Thank-you so much Sahil. I appreciate your support about that.
3 Views