Need Help with Backend Workflow for Parsing GPT-4 API JSON Response for User Matching

I’m working on a feature that connects users based on shared interests and compatibility. I’m using OpenAI’s GPT-4 API to analyze user profiles and suggest potential matches. The process works as follows:

  1. I collect profiles of users in a specific geographical area.
  2. Send these profiles along with the current user’s profile to GPT-4, which then returns a JSON string containing the unique IDs of matched users and the reasons for the match.

Currently, this process runs fine on the frontend, and I use the JSON Manipulator plugin to parse the JSON response. I then link these IDs to the actual user profiles and display them in a repeating group, along with the reason for the match. While this works well, the API response time is a bottleneck, affecting the user experience.

I want to shift this process to a backend workflow to improve performance. The idea is to run this when the user logs in so that the matched profiles are instantly available. However, I’m facing challenges in parsing the JSON string on the backend to extract the user IDs and the matching reasons.

I tried having ChatGPT create a plugin to handle the JSON parsing, but I haven’t been successful.

Has anyone tackled a similar issue or have any suggestions on how to implement this as a backend workflow?

Any help would be greatly appreciated!

This might help: