Return value from predefined list

Hi Experts!

Need help with a somehow easy request. I’m working on a solution that collects the subject from an emailhook and matches with a predefined set. As an example.

List of defined values are: Restaurant, Hotel, Travel, Grocery

The subject says “Rest”. then, it should return “Restaurant”.

Trying to do this with OpenAI or Parse, no luck. Any ideas??

Thanks!

OpenAI should be able to manage that easily if configured correctly, just provide a few examples for each and it’ll work the rest out.

not getting there. Im using Open AI Transform text to structured data, with following prompt:

Analyze the text and check for spelling mistakes and writing errors. Return one of the following values:

  1. TRAVEL
  2. TRANSPORTATION
  3. FOOD
  4. MATERIAL
  5. LOCATIONS
  6. PROFESSIONAL SERVICES
  7. STUDY
  8. INSURANCE
  9. LEGAL

Examples:

  • If the text includes words like “flight,” “trip,” “itinerary,” “plane,” or similar, return “1. TRAVEL”
  • If the text includes words like “parking,” “fuel,” “refueling,” “blue zone,” “green zone,” or similar, return “2. TRANSPORTATION”
  • If the text includes words like “meals,” “restaurant,” “food,” “snack,” or similar, return “3. FOOD”
  • If the text includes words like “clothing,” “Zara,” “misc,” “props,” “accessories,” or similar, return “4. MATERIAL”
  • If the text includes words like “farmhouse,” “location,” “base,” or similar, return “5. LOCATIONS”
  • If the text includes words like “catering,” “runners,” “deliveries,” “hairdresser,” “esthetician,” “makeup,” or similar, return “6. PROFESSIONAL SERVICES”
  • If the text includes “study” or similar, return “7. STUDY”
  • If the text includes words like “insurance,” “protection,” “damage,” “coverage,” or similar, return “8. INSURANCE”
  • If the text includes words like “legal,” “contract,” “agreement,” or similar, return “9. LEGAL”

If the text is empty, contains “Fw,” or does not match any category, return “Others”.

Any thoughts? hugely appreciated!

Try the “create a completion” function.

The above looks good, but make it quite clear you want a JSON output, and define exactly how you want it. Also mention that your input data is email subjects that you’re wanting to classify, then put the text at the end with something like:

Use the following text to answer the query:

TEXT

That should get you started :slightly_smiling_face:

you were right! so before trying to structure the data, I added a creation completion Open AI module, to do the validation. then, after that its sent to Open AI create structured data, so that it can be easily mapped.

Thank you!

1 Like

No problem, I’m glad that helped.

You can mark my response as the solution :wink: