Problem/Motivation

In AI module 1.3 loadApiKey() is added in ai/src/Base/AiProviderClientBase.php and expects a api_key config item. Without this an error is thrown:

Drupal\ai\Exception\AiRequestErrorException: Error invoking model response: Could not load the Ollama API key, please check your environment settings or your setup key. in Drupal\ai\Plugin\ProviderProxy->wrapperCall() (line 322 of modules/contrib/ai/src/Plugin/ProviderProxy.php).

Proposed resolution

Override function in module.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jan kellermann created an issue. See original summary.

jan kellermann’s picture

Status: Active » Needs review
jan kellermann’s picture

Issue summary: View changes
jan kellermann’s picture

Title: Override loadApiKey() for ai 1,3 » Override loadApiKey() for ai 1.3
valthebald’s picture

@jan kellermann: loadApiKey() only is invoked when hasAuthentication() returns TRUE.
maybe that's the method to override in Ollama provider?

jibran’s picture

Status: Needs review » Needs work

Setting up NW for #6

jan kellermann’s picture

Status: Needs work » Needs review

Good point. Changed overridden function.

jan kellermann’s picture

Title: Override loadApiKey() for ai 1.3 » Override hasAuthentication() for ai 1.3
Issue summary: View changes
valthebald’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

LGTM!

jibran’s picture

Status: Reviewed & tested by the community » Fixed

The PR has been merged. Should we create a new release?

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

marcus_johansson’s picture

jan kellermann’s picture

Thanks for feedback and coding!

A new release would be great. I would suggest 1.3.0 - its time for a stable release because there are no bugs in the issue queue.

arianraeesi’s picture

Status: Fixed » Closed (fixed)