Convert categories to full path with AI

Hi there,

I’m trying to build a workflow that :

  • Get Google Sheets rows
  • Loop Over Items
  • Use AI to convert product categories to full path categories
  • Update Google Sheet row

Input is a Google Sheets row that contains a list of category, for example :

  • category A, category B, category C

Goal is to get :

  • category A, category A > category B, category A > B > C

For AI, I’m using Ollama, tried deepseek-r1, gemma3 and llama.

Here’s my instructions :
Your task is to convert the categories of a user-supplied product into their full hierarchical path.
Complete paths :
[list of all existing full paths]
For example, if the user specifies :

  • [example]
    the answer should be :
  • [example]
    Your answer must contain only the requested result.

Never got good results.

Any ideas ?

Edit : works with mistrall-small:24b, temp to 0,1 and context length to 8k.