Could you implement a JSON parser feature?

Created on 2 November 2023, 8 months ago
Updated 12 November 2023, 8 months ago

First to say, what a fantastic and flexisble module!!! Thank you!

My feature request is parsing AI's JSON response result into specified one or multiple target fields with specified JSON Path. I explained why this feature is very useful here ✨ Provide more flexible multi-target widget with json data Active .

✨ Feature request
Status

Closed: outdated

Version

1.0

Component

Code

Created by

πŸ‡¨πŸ‡³China fishfree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @fishfree
  • πŸ‡©πŸ‡ͺGermany Marcus_Johansson

    Thanks fishfree!

    The OpenAI module is actually always generating JSON output in the background, that's how it can handle complex fields like location or taxonmy or in general create multiple fields. However this is of course not visible in the frontend. Check the source code.

    For instance the FAQ field looks like this

    {your prompt}
    
    Do not include any explanations, only provide a RFC8259 compliant JSON response with questions and answers following this format without deviation.\n[{\"value\": {\"question\": \"The question to ask\", \"answer\": \"The answer\"}}]
    

    What does exist, and I just pushed the alpha4 for it, is the plugin for the custom field β†’ module.

    This would can do one-shot learning with provided examples and fill out a complex field. See the video here for an example: https://workflows-of-ai.com/workflow/custom-complex-fields.

    What you can do with module currently is many-to-one and one-to-one generation, but not many-to-many. We have private modules for this that we are not ready to open source at the moment.

    If you actually want true JSON outputted, we could of course create a OpenAI rule for https://www.drupal.org/project/json_field β†’ , that would be easy. Together with this https://www.drupal.org/project/jfu β†’ it might do the trick?

    If you want that, just change the scope and I'll fix that for you.

    For many-to-many of course there could be a community solution for this, but we will probably release the solution sooner or later. If you want to setup that ticket, it probably makes more sense in the ai_interpolator module since it's a structure change in how the module's logic works.

  • πŸ‡±πŸ‡ΉLithuania mindaugasd

    Going forward (at some point) we will need to figure out one-to-many interpolation (filling multiple fields with a single request).
    Connecting a related issue.

    Happy to learn about new Custom field β†’ . It have not yet existed a year ago I was searching for solution like this.

  • πŸ‡¨πŸ‡³China fishfree

    @Marcus, Thank you for your quick reply.
    The module JSON field Utils β†’ is not suitable for our problem, and the custom_field is not the native core-built-in fields after all. So implementing this feature in the module ai_interpolator is more reasonable. I'd like to expect that.

    Thank you again for your passionate and generous work!

  • πŸ‡©πŸ‡ͺGermany Marcus_Johansson

    I will split this up in the tickets:

    1. Multi interpolation, so one or many fields to many (different) fields. We have a solution, but I think I have come up with a more sustainable version there. Anyone wanting to join the discussion of the UI/Usage of the solution, please check here: https://www.drupal.org/project/ai_interpolator/issues/3400745 ✨ Many Different Fields Interpolation Active .
    2. OpenAI on Monday added actual JSON output, this should be leveraged in the models where possible, since the current output in 3.5 sometimes outputs faulty JSON.
    3. An actual interpolator plugin for json_field β†’ .

    @fishfree - I hope that was the solution you are looking for, could you close this ticket since the actual multi field is an issue for the Interpolator in general. We could keep it open for the json_field, but since that's not what you were looking for it might make sense to create a separate ticket for that.

  • Status changed to Closed: outdated 8 months ago
  • πŸ‡¨πŸ‡³China fishfree

    OK. Thank you!

Production build 0.69.0 2024