DEV Community

Mahinur Rahman
Mahinur Rahman

Posted on

My experience with OpenAI API

Today I’ll share my experience working with openAI API (ChatGPT)

✨ I have been working with AI based travel planner application✈️. I’m going to share my problem, what difficulties I’ve faced and how I came up with the solutions.

Problem

Planning a trip based on users interests and other preferences where trip could be of multiple days.

How OPEN AI helped me:

I’ve connected OPEN AI with user preferences to get related places with their personality.

⭐️ Challenges ⭐️

  1. Taking all user preferences to GPT to understand user’s personality.

  2. Making prompt so that every time i get same response format.

  3. Had to recover data returned from GPT in my preferred JSON format.

  4. Connect google places API to get users required trip places based on GPT driven result.

  5. Handling GPT error while generating a trip for smooth user experience.

⭐️ Solutions ⭐️

  1. GPT has limited token supply for each prompt. We can’t pass all our data through prompt. It’s better to make another prompt to get desired data before making the final prompt. In our case we had to generate personality for each profiles by providing user preferences and interests to maintain token length small enough in final prompt.

  2. POMPT Engineering is must for making application smooth. Application needs same response all the time. So making a prompt that gives same response all the time, is must. We had to repeat same keyword sometimes to make GPT understand what we need the most.

  3. GPT generally replies like human being. But for developer like us who has a little more complex issues need the JSON format mostly. We need key-value pair in order to get out best. Cause parsing text and making JSON is not a good idea. We had specified our JSON format and current version of JSON to get the static output.

  4. Now we have JSON, we need places. For getting places we made queries based on preferences of user and for each query we got some places from PLACES API.

  5. Finally, the worst part of GPT is when traffic is high it breaks down. That’s a big issue until you start a project related to OPEN AI 😄 So all you need to check every time whether there is anything right or not. Making smooth user experience we had to handle them multiple times.

That’s all from my perspective. I believe learning knows no bounds. Feel free to share your thoughts 💭

Top comments (0)