Add field types, widgets and formatters to reference AI provider

Created on 25 March 2025, about 1 month ago

Problem/Motivation

I'm using ECK to create my own data structures for managing prompts, agents, tools and workflows. I'd like to reference AI providers in these entity types.

Proposed resolution

Add an AI provider reference field, widget and formatter.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.1

Component

AI Core module

Created by

🇳🇿New Zealand Josh Waihi

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

Merge Requests

Comments & Activities

  • Issue created by @Josh Waihi
  • Merge request !526#3515209 - Field support for AI providers. → (Open) created by Josh Waihi
  • Pipeline finished with Failed
    about 1 month ago
    Total: 446s
    #456758
  • Pipeline finished with Failed
    about 1 month ago
    Total: 369s
    #456768
  • 🇬🇧United Kingdom MrDaleSmith

    The tests are failing because you are using Drupal::service() inside an object: you need to be using dependency injection to get the Ai provider service in there. See https://drupal.stackexchange.com/questions/224247/how-do-i-inject-a-depe... for a steer if you don't know how to do it.

  • Pipeline finished with Failed
    25 days ago
    Total: 313s
    #461340
  • First commit to issue fork.
  • Pipeline finished with Failed
    24 days ago
    Total: 401s
    #462153
  • Pipeline finished with Failed
    24 days ago
    Total: 323s
    #462172
  • Pipeline finished with Failed
    24 days ago
    Total: 237s
    #462191
  • Pipeline finished with Failed
    24 days ago
    Total: 242s
    #462219
  • 🇬🇧United Kingdom MrDaleSmith

    Tests still failing: https://git.drupalcode.org/issue/ai-3515209/-/jobs/4833128 - the $provider_id variable only exists if the $item is not empty, so it is theoretically possible that you then try to put a non-existent variable in the $form_state. The easiest fix is to give the $provider_id a NULL value outside of your if statement.

  • Pipeline finished with Failed
    24 days ago
    Total: 209s
    #462359
  • Pipeline finished with Success
    24 days ago
    Total: 327s
    #462520
  • 🇬🇧United Kingdom MrDaleSmith

    Applies fine and does what it says it will.

    The default value functionality however requires you to set up a default when adding the field type to a node type, which isn't the behaviour of others field: default values are usually optional when setting up a content type, with a "Set default value" checkbox. I think users will expect it to work this way, given it is the standard for Drupal field types.

    Possibly the field type should just be an additional item in the Reference category rathewr than its own thing when adding a new field - it doesn't do anything different to the other reference field types - but that may be a personal preference.

  • Pipeline finished with Failed
    17 days ago
    Total: 234s
    #468173
  • Pipeline finished with Canceled
    17 days ago
    Total: 97s
    #468181
  • Pipeline finished with Canceled
    17 days ago
    Total: 153s
    #468184
  • Pipeline finished with Failed
    17 days ago
    Total: 340s
    #468187
  • Pipeline finished with Failed
    17 days ago
    Total: 210s
    #468217
  • 🇮🇳India anjaliprasannan

    @mrdalesmith
    The current implementation removes the standalone field type and introduces an aiprovider entity, which is referenced using an entity reference field type. Additionally, the default value can now be set through the field widget.

    There are still some issues with the implementation, but before proceeding further, I wanted to confirm if this is the kind of setup you were expecting for the AI Provider entity reference.

  • 🇬🇧United Kingdom MrDaleSmith

    No, not really: why does it require an entity to be created? I was just suggesting changing the label so the reference widget you'd created appears in the "reference" list when setting up a new field, rather than as a separate field type.

    Also, I'm not a maintainer on this project so I wouldn't completely retool your approach based on my suggestions without any feedback from the actual maintainers. My suggestions have no weight here.

  • Pipeline finished with Success
    17 days ago
    Total: 208s
    #468244
  • 🇮🇳India anjaliprasannan

    ok @mrdalesmith. Waiting for the maintainers input.

  • Pipeline finished with Success
    2 days ago
    #479997
Production build 0.71.5 2024