Changeset 3767789 for ai-engine/trunk/classes/modules/workspace.php
- Timestamp:
- 10/27/2026 05:37:58 AM (9 days ago)
- File:
-
- 1 edited
-
ai-engine/trunk/classes/modules/workspace.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ai-engine/trunk/classes/modules/workspace.php
r3760851 r3767789 274 274 'envs' => $this->build_envs(), 275 275 'embeddings_envs' => $this->build_embeddings_envs(), 276 'chatbots' => $this->build_chatbots(), 276 277 'mcp_envs' => $this->build_mcp_envs(), 277 278 'functions' => $this->build_functions(), … … 289 290 'settings_url' => admin_url( 'admin.php?page=mwai_settings' ), 290 291 ]; 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; 291 316 } 292 317 … … 426 451 } 427 452 $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 } 428 464 // "This WordPress" mode: remember the requested categories for this 429 465 // request (chatbot_query attaches the tools) and tell the AI where it is. … … 474 510 'mcpServers' => [], 475 511 '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'] ?? '' ) : '', 479 515 ] ); 480 516 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)