kyang6 / llmparser

Classify and extract structured data with LLMs
https://llmparser.com
MIT License
407 stars 23 forks source link

Extracting multiple items #7

Open acomagu opened 1 year ago

acomagu commented 1 year ago

Feature Request

Is your feature request related to a problem? Please describe.

I couldn't find a way to extract multiple items by LLMParser. My usecase is that I want to extract ingredients list from HTML of recipe site.

I defined the fields as follows but only one ingredient name could be obtained.

const parser = new LLMParser({
  model: 'gpt-3.5-turbo',
  fields: [
    {
      name: 'name',
      description: 'The name of an ingredient.',
      type: 'string',
    },
    {
      name: 'quantity',
      description: 'The quantity of the ingredient.',
      type: 'string',
    },
  ],
});

Describe the solution you'd like

Describe alternatives you've considered

Are you willing to resolve this issue by submitting a Pull Request?

kyang6 commented 1 year ago

Hi! There is no official way yet. I've added it to the roadmap.

The workaround today is to put in the description "a list of all ingredients separated by a comma" and then just split the string by comma.

const ingredients = "chicken, salt, water";
const list_of_ingredients = ingredients.split(",");