Resolve #3493277 "Extend logging capabilities tabs"
6 open threads
Closes #3493277
Merge request reports
Activity
requested review from @Marcus_Johansson
added 2 commits
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.
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') 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>'; 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>';
Please register or sign in to reply