Make it possible to take the input as an interactive prompt

Created on 18 May 2025, 2 months ago

Problem/Motivation

We just added โœจ Add Drush AI Command Active - one direct improvement is to add so you can add multi row prompts without having to use the slash newline escape sign when pasting, we should make an interactive command.

An interactive command is easier also for normal use, since you can do `drush ai` and then start typing away.

Steps to reproduce

Proposed resolution

Add a interactive element if the input is empty.

Remaining tasks

User interface changes

API changes

Data model changes

โœจ Feature request
Status

Active

Version

1.1

Component

AI Core module

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany marcus_johansson

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

Merge Requests

Comments & Activities

  • Issue created by @marcus_johansson
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada RobLoach Earth

    Looks good, thanks. Do we need to update the docs for this? Seems intuitive enough to not really need mentioning ๐Ÿคท

    The other thing I'd like to have when entering drush ai is an interactive shell that continuously chats with you back and forth.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhinesh

    Thanks @ marcus_johansson โ†’ and @ robloach โ†’ ! The current implementation is intuitive and doesnโ€™t require additional documentation. As noted, it would be great to explore the possibility of having an interactive shell mode for drush ai in future iterations โ€” where it maintains a continuous back-and-forth chat experience.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany marcus_johansson

    I made a slight change in the order, so the interactive prompt doesn't show up if no default or set provider is set. Please rereview.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia annmarysruthy

    Reviewed the changes. Looks good to me. Tested scenarios:

    1. Without any provider: got error "No default AI provider or model set" but 2 warnings:
      [warning] Trying to access array offset on null AiCommands.php:84
      [warning] Trying to access array offset on null AiCommands.php:85
    2. Using invalid free tier key with openai provider. Input was accepted. Error: Unable to fetch response: Too Many Requests
    3. Using valid key with Openai. Interactive prompt appeared, accepted input and output was displayed successfully.
    4. Deleted the key from last step. Provider settings was kept the same as last step: Intercative prompt is displayed, accepted input from user, displayed "fetching Response.." and error: "Unable to fetch response: Error invoking model response: Could not load the OpenAI API key, please check your environment settings or your setup key."
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia prashant.c Dharamshala

    I tried the following:

    1. drush ai "what is Drupal?" It is showing "Fetching response..." as a loader.
    2. drush ai showing interactive input and shows "Fetching response..." as a loader.
    3. drush aiby default works for chat only, is it supposed to work for ai:translate-entity ai:translate-text also?

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada RobLoach Earth

    Hmm, perhaps something changed in the API. Thanks for the testing.

Production build 0.71.5 2024