Skip to content
Snippets Groups Projects

Resolve #3493277 "Extend logging capabilities tabs"

Closes #3493277

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
10 10 dependencies:
11 11 - ai:ai
12 12 - drupal:views
13 - drupal:menu_ui
14 - drupal:field
15 - drupal:field_ui
  • Do we need to depend on these UI modules or are they just nice to have? I'm not sure I'd expect to have to turn these on for an AI logging module

    Also need to review the dependencies from the config being installed cause I think there are a few that are missing here (options and user were the ones I noticed). Whether we add them here or change the config will depend on what each one is doing.

  • Please register or sign in to reply
  • 32 *
    33 * @param string $prompt
    34 * The system prompt to extract actions from.
    35 *
    36 * @return array|null
    37 * Array of available actions or null if none found.
    38 */
    39 public function extractAvailableActions(string $prompt): ?array {
    40 // Look for action format definition in the prompt.
    41 if (preg_match('/\[{"action":([^}]+)}\]/', $prompt, $matches)) {
    42 return [
    43 [
    44 'id' => 'answer',
    45 'label' => 'Answer',
    46 'description' => 'Provides an answer to the question',
    47 'plugin' => 'answer',
  • 80 if ($view_id === 'ai_logs') {
    81 return [];
    82 }
    83
    84 return [
    85 '#type' => 'container',
    86 '#attributes' => [
    87 'class' => ['llm-warning-message'],
    88 ],
    89 'message' => [
    90 '#markup' => new TranslatableMarkup('This log overview page is significantly improved with AI summaries that can be turned on from the @link.', [
    91 '@link' => Link::createFromRoute('AI Logs settings page', 'ai_logging.settings_form')
    92 ->toString(),
    93 ]),
    94 '#prefix' => '<div class="messages messages--warning">',
    95 '#suffix' => '</div>',
  • 220 223 ])
    221 224 ->setDisplayConfigurable('form', TRUE)
    222 225 ->setDisplayConfigurable('view', TRUE);
    226 $fields['ail_call_chain'] = BaseFieldDefinition::create('entity_reference')
    • I think prefix-ing every field (here and in config) with ail_ is unnecessary as these are all on the AiLog entity anyway so there won't be clashes with other field names. Unless I'm missing something?

    • Author Developer

      These are stadard Drupal fields now, accessible via GUI, to accommodate different fields per different bundles of ai_log entity. Prefixing means no one can have these already in system.

    • Please register or sign in to reply
  • 282 $output .= '<div class="role-indicator">' . ucfirst($role) . '</div>';
    283 $output .= '<div class="message-content">' . $content . '</div>';
    284 $output .= '</div>';
    285 }
    286 $output .= '</div>';
    287 }
    288 else {
    289 // Render as modern text prompt.
    290 $output = '<div class="modern-prompt">';
    291 $output .= '<div class="prompt-header">';
    292 $output .= '<div class="prompt-label">Prompt</div>';
    293 $output .= '</div>';
    294 $output .= '<div class="prompt-body">';
    295 $output .= '<div class="prompt-content">' . nl2br($entity->get('prompt')->value) . '</div>';
    296 $output .= '</div>';
    297 $output .= '</div>';
    • Comment on lines +277 to +297

      Could we create some new templates for this so that it's easier for themes to tweak things if necessary? (If we stick with this then we need to make sure the "Prompt" label goes through translation)

    • Author Developer

      It definitely can be pre-processed and then templated. For now I would stick with t() for Prompt, but doing proper templating in future is yes.

    • Please register or sign in to reply
  • 296 $output .= '</div>';
    297 $output .= '</div>';
    298 }
    299
    300 // Add download section.
    301 $output .= '<div class="prompt-download-section">';
    302
    303 if (!$this->hasFunctions($entity)) {
    304 $output .= '<div class="message success">This prompt can be downloaded and used in other environments.</div>';
    305 }
    306 else {
    307 $output .= '<div class="message warning">This prompt cannot be used outside this site because it uses Function calls.</div>';
    308 }
    309
    310 $url = Url::fromRoute('ai_logging.download_prompt', ['ai_log' => $entity->id()])->toString();
    311 $output .= '<a href="' . $url . '" class="download-button">Download Prompt</a>';
  • The end product of this looks great! I've added a few suggestions & questions but I think only the preg_match and missing dependencies could cause bugs

  • Please register or sign in to reply
    Loading