Plugin Directory


Ignore:
Timestamp:
10/27/2026 05:37:58 AM (9 days ago)
Author:
TigrouMeow
Message:

Version 3.8.8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ai-engine/trunk/classes/modules/workspace.php

    r3760851 r3767789  
    274274      'envs' => $this->build_envs(),
    275275      'embeddings_envs' => $this->build_embeddings_envs(),
     276      'chatbots' => $this->build_chatbots(),
    276277      'mcp_envs' => $this->build_mcp_envs(),
    277278      'functions' => $this->build_functions(),
    … …  
    289290      'settings_url' => admin_url( 'admin.php?page=mwai_settings' ),
    290291    ];
     292  }
     293
     294  /**
     295   * The site's own chatbots, to chat with in the Workspace (their instructions and Knowledge
     296   * apply; the conversation stays a Workspace one). Chat mode only: Assistant, Realtime,
     297   * Images and Prompt bots don't fit a chat window.
     298   */
     299  private function build_chatbots() {
     300    $out = [];
     301    foreach ( (array) $this->core->get_chatbots() as $bot ) {
     302      $botId = (string) ( $bot['botId'] ?? '' );
     303      $mode = $bot['mode'] ?? 'chat';
     304      if ( $botId === '' || strpos( $botId, 'mwai_' ) === 0 || ( $mode && $mode !== 'chat' ) ) {
     305        continue;
     306      }
     307      $out[] = [
     308        'botId' => $botId,
     309        'name' => (string) ( $bot['name'] ?? $botId ),
     310        'envId' => $bot['envId'] ?? null,
     311        'model' => $bot['model'] ?? null,
     312        'knowledge' => !empty( $bot['embeddingsEnvId'] ),
     313      ];
     314    }
     315    return $out;
    291316  }
    292317
    … …  
    426451    }
    427452    $instructions = 'You are a capable, direct assistant. Format your answers in Markdown.';
     453    // A conversation started with one of the site's chatbots runs on its instructions and,
     454    // unless the composer picks another, its Knowledge. Requested by a Discord user who
     455    // wanted his Cross-Site bots on the Workspace apps (2026-10-24).
     456    $wsBot = null;
     457    $wsBotId = sanitize_text_field( (string) ( $params['wsBot'] ?? '' ) );
     458    if ( $wsBotId !== '' && strpos( $wsBotId, 'mwai_' ) !== 0 ) {
     459      $wsBot = $this->core->get_chatbot( $wsBotId );
     460      if ( is_array( $wsBot ) && !empty( $wsBot['instructions'] ) ) {
     461        $instructions = $wsBot['instructions'];
     462      }
     463    }
    428464    // "This WordPress" mode: remember the requested categories for this
    429465    // request (chatbot_query attaches the tools) and tell the AI where it is.
    … …  
    474510      'mcpServers' => [],
    475511      'tools' => [],
    476       'embeddingsEnvId' => '',
    477       'embeddingsIndex' => '',
    478       'embeddingsNamespace' => '',
     512      'embeddingsEnvId' => is_array( $wsBot ) ? ( $wsBot['embeddingsEnvId'] ?? '' ) : '',
     513      'embeddingsIndex' => is_array( $wsBot ) ? ( $wsBot['embeddingsIndex'] ?? '' ) : '',
     514      'embeddingsNamespace' => is_array( $wsBot ) ? ( $wsBot['embeddingsNamespace'] ?? '' ) : '',
    479515    ] );
    480516  }
Note: See TracChangeset for help on using the changeset viewer.