Sofia
Account created on 11 February 2008, over 17 years ago
#

Merge Requests

More

Recent comments

🇧🇬Bulgaria valthebald Sofia

valthebald made their first commit to this issue’s fork.

🇧🇬Bulgaria valthebald Sofia

Actually, it is possible to perform the check earlier and avoid the ReferenceFieldExtractor::extract() call

🇧🇬Bulgaria valthebald Sofia

@lakhal: thanks for reporting this. The issue is caused by ReferenceFieldExtractor assuming that in the entity reference field, referenced entities are (fieldable) content entities, which is not the case for config entity Domain.

Possible solution is to check that $subEntity is instance of ContentEntityInterface before calling extractTextMetadata($subEntity)`:

    foreach ($entity->get($fieldName)
      ->referencedEntities() as $delta => $subEntity) {
      // Intentionally check each sub entity because of https://www.drupal.org/project/drupal/issues/2407587
      if (!($subEntity instanceof ContentEntityInterface)) {
        continue;
      }
      foreach ($this->textExtractor->extractTextMetadata($subEntity) as $subMeta) {
        $textMeta[] = ['delta' => $delta] + $subMeta;
      }
    }

Also, if you switch from 1.0.5 to 1.1.0-beta, you can disable domain translation and avoid this issue (go to Administration/Content types//fields/:

🇧🇬Bulgaria valthebald Sofia

Version 1.1 is not BC with 1.0.5, but there will be an upgrade path.
If you start building a WIP, better start with 1.1-beta

🇧🇬Bulgaria valthebald Sofia

@anjaliprasannan I've added some code style comments

🇧🇬Bulgaria valthebald Sofia

Frankly, if this is the only issue blocking the release, happens only under certain conditions and only with VDB/RAG enabled, I would move it to 1.2.x and have the release without the fix.

🇧🇬Bulgaria valthebald Sofia

In AiAssistantForm.php around line 239:

      $form['agents_enabled']['agents_agent'] = [
        '#type' => 'checkboxes',
        '#title' => $this->t('Agents to use'),
        '#options' => $agent_options,
        '#default_value' => $tools,
        '#description' => $this->t('Select which agents to use for this plugin.'),
      ];

      // Only show if AI search is enabled.
      if ($this->moduleHandler->moduleExists('ai_search')) {

there should be similar check if ai_agents module is enabled (same check as for ai_search module in the code fragment above).
Otherwise, there is an empty "Agents to use" form element.
I'm reviewing the MR and will add comments in gitlab if I see something else.

🇧🇬Bulgaria valthebald Sofia

I was thinking... can we combine the best of 2 worlds?
How hard would it be to create a form for dynamically creating a tool as a Drupal plugin?
Conceptually, this could be similar to what XB does with the option to create a component on the fly, only much-much simpler.
The form in question could contain a dynamic list of parameters (name/type/description) + the body field
The body could include PHP code (simple but potentially dangerous option) or some form of pseudo code - twig/ECA model

🇧🇬Bulgaria valthebald Sofia

Hi @aolivera since you're still working on this (I see the status is "Needs work"), can you check some more things please:

  1. I see that Google consistently uses the term "data store" but not "datastore"
  2. In the new form element #description, is it possible to add a link to documentation what "data store" is? Maybe https://cloud.google.com/generative-ai-app-builder/docs/create-datastore... but if you have a better link that's fine
  3. OK if I close MR#8?
🇧🇬Bulgaria valthebald Sofia

@prabha1997:

I feel that the safest would be to discard the changes except the one in AiTranslateController.php

🇧🇬Bulgaria valthebald Sofia

My experience is the same as of @ronttizz
After some debugging, the issue is caused by the way translation is created in AiTranslateController::insertTranslation():

  public function insertTranslation(
    ContentEntityInterface $entity,
    string $lang_to,
    array &$context,
  ) {
    $translation = $entity->addTranslation($lang_to);

compared to how it is done in core's ContentTranslationController::prepareTranslation():

    $target_translation = $entity->addTranslation($target->getId(), $source_translation->toArray());

i.e. in AI, translation is created with empty defaults, while in core it is prepopulated by the source entity values.

Adding the source values in AI

  public function insertTranslation(
    ContentEntityInterface $entity,
    string $lang_to,
    array &$context,
  ) {
    $translation = $entity->addTranslation($lang_to, $entity->toArray());

solves the issue for me. Can someone confirm if this works?

🇧🇬Bulgaria valthebald Sofia

@marcus_johansson I see that MR is already against 1.1.x, changing issue version

🇧🇬Bulgaria valthebald Sofia

Does this mean we can close the issue?

🇧🇬Bulgaria valthebald Sofia

That change would make sense. Merge request is welcome!

🇧🇬Bulgaria valthebald Sofia

Looks like the only remaining issue is Add the actual agents as configs Active ?

🇧🇬Bulgaria valthebald Sofia

PHP port of python MCP SDK https://packagist.org/packages/logiscape/mcp-sdk-php allows something similar:

https://github.com/logiscape/mcp-sdk-php/blob/5885e4cad09eae9662f9c8e3b7...

 // Create schema with properties and required fields
    $inputSchema = new ToolInputSchema(
        properties: $properties,
        required: ['num1', 'num2']
    );

    // Create calculator tool
    $calculator = new Tool(
        name: 'add-numbers',
        description: 'Adds two numbers together',
        inputSchema: $inputSchema
    );

$server->registerHandler('tools/call', function($params) {
    $name = $params->name;
    switch ($name) {
        case 'add-numbers':
...
🇧🇬Bulgaria valthebald Sofia

@marcus_johansson: I'd vote for 1.2.x as a target then

🇧🇬Bulgaria valthebald Sofia

I wonder if that's too late to include this feature to 1.1.0
I agree this is a great-to-have, yet having 1.1.0 release is overdue now, can this be postponed to 1.2.x/2.0.x?

🇧🇬Bulgaria valthebald Sofia

No feedback for several days, merging

🇧🇬Bulgaria valthebald Sofia

Looks good to me code-wise.
I miss some explanation on why this changes is needed in the first place, but this can be added in the follow-up issue when it's created.
Pending creation of 2.0.x/2.x branch to do this

🇧🇬Bulgaria valthebald Sofia

Actually, my bad, translations work. @prashant.c can you review the CI bot comments?

🇧🇬Bulgaria valthebald Sofia

After applying the patch, I see full list of operations in the settings form, but have no translate with ai links in node//translations

🇧🇬Bulgaria valthebald Sofia

Having a simple autoloading class for the sake of autoloading sounds fair

🇧🇬Bulgaria valthebald Sofia

Alright, so this worked. It is now possible to create a Translation model in Vertex provider settings form /admin/config/ai/providers/google_vertex:

(on a side note, Vertex provider configuration is relatively complex and would win of a better documentation/examples)

🇧🇬Bulgaria valthebald Sofia

Created first working version. Vertex native translation supports 2 modes: Translation LLM (highest quality, limited to 19 languages) and NMT (fastest, works with larger set of languages), see https://cloud.google.com/vertex-ai/generative-ai/docs/translate/translat... for details.
MR in its current state supports only Translation LLM.
Results are promising (as in translation is really fast and has the quality expected from Google translation), but I'd like to support NMT as well before marking MR as ready for review

🇧🇬Bulgaria valthebald Sofia

I added hook_update_N() just in case

🇧🇬Bulgaria valthebald Sofia

In order to provide native translation support, VertexProvider needs to implement Drupal\ai\OperationType\TranslateText\TranslateTextInterface (which has only one translateText() method)
Implementation can use its own endpoint, different from chat()

🇧🇬Bulgaria valthebald Sofia

What if, to avoid confusion, we limit selection of keys in provider form to only file-based? Suggested MR does just that, and changes a little description of the key select to

Choose an available key. If the desired key is not listed, create a new key. Important: Key must use "File" provider and point to the JSON credentials file. Read more at https://cloud.google.com/docs/authentication/application-default-credent....

One thing to decide is whether we need an update hook to switch from config/environment key to file based for existing installations.

🇧🇬Bulgaria valthebald Sofia

I see 2 parts here:
1. Although Vertex authentication should be done via JSON file, keys of type "File" do not work. This is a bug that is easily fixable in VertexProvider::getAccessToken() - which should try to unserialize the key before creating ServiceAccountCredentials
2. (working) keys of type environment/configuration should be documented better. This part specifically?

Could explain that the key should be in fact the path to the JSON file (which is a bit controversial)

🇧🇬Bulgaria valthebald Sofia

@aolivera: thank you, fixed!
Just a small note for the future: it's better to use branch that is named after the issue number (i.s. 3506263-something) instead of 1.0.x on a separate git origin - that makes local distinction easier

🇧🇬Bulgaria valthebald Sofia

@jibla: it turns out that function calling is not yet supported by google-gemini-php. There is a PR https://github.com/google-gemini-php/client/pull/67 against beta branch, but not merged yet.

Should we park the issue until PR is merged, or switch to vanilla Guzzle requests as suggested in related Google Vertex issue https://www.drupal.org/project/ai_provider_google_vertex/issues/3506263 🐛 Vertex provider uses PredictionServiceClient and slows down response time. Active ?

🇧🇬Bulgaria valthebald Sofia

As @andypost mentioned in #7, the issue is about 2 variants of transcribing "щ" character that are found in the core.
From several sources I've checked, "shch" variant is more "favourable", so I'd suggest use it consistently in all places

🇧🇬Bulgaria valthebald Sofia

Going to work on this during DDD25

🇧🇬Bulgaria valthebald Sofia

Bumping the target version

Production build 0.71.5 2024