diff --git a/client/src/plus/ai-help/constants.tsx b/client/src/plus/ai-help/constants.tsx index 2b4159ee1270..32c0f643fd1d 100644 --- a/client/src/plus/ai-help/constants.tsx +++ b/client/src/plus/ai-help/constants.tsx @@ -1,6 +1,6 @@ -export const SORRY_BACKEND = "Sorry, I don't know how to help with that."; +export const SORRY_BACKEND_PREFIX = "I'm sorry, but I can't"; export const SORRY_FRONTEND = - "Sorry, I don’t know how to help with that.\n\nPlease keep in mind that I am only limited to answer based on the MDN documentation."; + "I'm sorry, but I can't answer questions outside web development."; export const MESSAGE_SEARCHING = "Searching for MDN content…"; export const MESSAGE_SEARCHED = "Consulted MDN content:"; diff --git a/client/src/plus/ai-help/index.tsx b/client/src/plus/ai-help/index.tsx index 7373d8daa374..2c1943b92c51 100644 --- a/client/src/plus/ai-help/index.tsx +++ b/client/src/plus/ai-help/index.tsx @@ -48,7 +48,7 @@ import { useUIStatus } from "../../ui-context"; import { QueueEntry } from "../../types/playground"; import { AIHelpLanding } from "./landing"; import { - SORRY_BACKEND, + SORRY_BACKEND_PREFIX, SORRY_FRONTEND, MESSAGE_SEARCHING, MESSAGE_ANSWERING, @@ -288,6 +288,10 @@ function AIHelpAssistantResponse({ let sample = 0; + const isOffTopic = + message.role === MessageRole.Assistant && + message.content?.startsWith(SORRY_BACKEND_PREFIX); + function messageForStatus(status: MessageStatus) { switch (status) { case MessageStatus.Errored: @@ -314,33 +318,7 @@ function AIHelpAssistantResponse({ return ( <> -