Sahil
03/27/2024, 1:55 AMSangy
03/27/2024, 6:26 AMwesty412
03/27/2024, 9:06 AMpython
@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")
westy412
03/27/2024, 10:26 AMwesty412
03/27/2024, 10:34 AMGetInference
03/27/2024, 5:42 PMwesty412
03/27/2024, 5:45 PMwesty412
03/27/2024, 5:45 PMGetInference
03/28/2024, 10:37 AMnikhil
03/31/2024, 10:48 PMnikhil
03/31/2024, 10:50 PMtechlead_05823
04/29/2024, 10:12 AMEvergreenGains
06/03/2024, 7:34 AMSahil
06/03/2024, 7:37 AMEvergreenGains
06/05/2024, 6:11 AMSahil
06/05/2024, 6:17 AMEvergreenGains
06/05/2024, 6:24 AMSahil
06/05/2024, 6:37 AMEvergreenGains
06/05/2024, 6:51 AMSahil
06/05/2024, 7:25 AMEvergreenGains
06/06/2024, 5:17 AMmap
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.EvergreenGains
06/06/2024, 5:18 AMstreaming 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:
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.Sahil
06/06/2024, 9:43 AMSahil
06/06/2024, 8:54 PMSahil
06/06/2024, 8:54 PMEvergreenGains
06/06/2024, 11:25 PM