diff --git a/web/src/app/admin/assistants/AssistantEditor.tsx b/web/src/app/admin/assistants/AssistantEditor.tsx index 2661919b5..1ed651efa 100644 --- a/web/src/app/admin/assistants/AssistantEditor.tsx +++ b/web/src/app/admin/assistants/AssistantEditor.tsx @@ -73,9 +73,10 @@ import { errorHandlingFetcher } from "@/lib/fetcher"; import { DeleteEntityModal } from "@/components/modals/DeleteEntityModal"; import { DeletePersonaButton } from "./[id]/DeletePersonaButton"; import Title from "@/components/ui/title"; +import { SEARCH_TOOL_ID } from "@/app/chat/tools/constants"; function findSearchTool(tools: ToolSnapshot[]) { - return tools.find((tool) => tool.in_code_tool_id === "SearchTool"); + return tools.find((tool) => tool.in_code_tool_id === SEARCH_TOOL_ID); } function findImageGenerationTool(tools: ToolSnapshot[]) { diff --git a/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigCreationForm.tsx b/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigCreationForm.tsx index 80450b867..c45d06740 100644 --- a/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigCreationForm.tsx +++ b/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigCreationForm.tsx @@ -14,7 +14,7 @@ import CardSection from "@/components/admin/CardSection"; import { useRouter } from "next/navigation"; import { Persona } from "@/app/admin/assistants/interfaces"; import { StandardAnswerCategoryResponse } from "@/components/standardAnswers/getStandardAnswerCategoriesIfEE"; -import { SEARCH_TOOL_NAME } from "@/app/chat/tools/constants"; +import { SEARCH_TOOL_ID, SEARCH_TOOL_NAME } from "@/app/chat/tools/constants"; import { SlackChannelConfigFormFields } from "./SlackChannelConfigFormFields"; export const SlackChannelConfigCreationForm = ({ @@ -36,16 +36,12 @@ export const SlackChannelConfigCreationForm = ({ const existingSlackBotUsesPersona = existingSlackChannelConfig?.persona ? !isPersonaASlackBotPersona(existingSlackChannelConfig.persona) : false; - const knowledgePersona = personas.find((persona) => persona.id === 0); - - const documentSetContainsSync = (documentSet: DocumentSet) => - documentSet.cc_pair_descriptors.some( - (descriptor) => descriptor.access_type === "sync" - ); const searchEnabledAssistants = useMemo(() => { return personas.filter((persona) => { - return persona.tools.some((tool) => tool.name == SEARCH_TOOL_NAME); + return persona.tools.some( + (tool) => tool.in_code_tool_id == SEARCH_TOOL_ID + ); }); }, [personas]); diff --git a/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigFormFields.tsx b/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigFormFields.tsx index 9660614ca..02dfaeca1 100644 --- a/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigFormFields.tsx +++ b/web/src/app/admin/bots/[bot-id]/channels/SlackChannelConfigFormFields.tsx @@ -51,7 +51,7 @@ export function SlackChannelConfigFormFields({ setPopup, }: SlackChannelConfigFormFieldsProps) { const router = useRouter(); - const { values, setFieldValue, isSubmitting } = useFormikContext(); + const { values, setFieldValue } = useFormikContext(); const [showAdvancedOptions, setShowAdvancedOptions] = useState(false); const [viewUnselectableSets, setViewUnselectableSets] = useState(false); const [viewSyncEnabledAssistants, setViewSyncEnabledAssistants] = @@ -315,6 +315,7 @@ export function SlackChannelConfigFormFields({ )} + ({ diff --git a/web/src/app/assistants/ToolsDisplay.tsx b/web/src/app/assistants/ToolsDisplay.tsx index 8efa02d55..2a597dff4 100644 --- a/web/src/app/assistants/ToolsDisplay.tsx +++ b/web/src/app/assistants/ToolsDisplay.tsx @@ -1,5 +1,6 @@ import { FiImage, FiSearch } from "react-icons/fi"; import { Persona } from "../admin/assistants/interfaces"; +import { SEARCH_TOOL_ID } from "../chat/tools/constants"; export function AssistantTools({ assistant, @@ -13,7 +14,9 @@ export function AssistantTools({ return (
0 && "py-1"} ${!list ? "font-semibold" : "text-subtle text-sm"}`} + className={`${assistant.tools.length > 0 && "py-1"} ${ + !list ? "font-semibold" : "text-subtle text-sm" + }`} > Tools: {" "} @@ -22,7 +25,7 @@ export function AssistantTools({ ) : (
{assistant.tools.map((tool, ind) => { - if (tool.name === "SearchTool") { + if (tool.name === SEARCH_TOOL_ID) { return (
{tool.name}
diff --git a/web/src/app/chat/ChatPage.tsx b/web/src/app/chat/ChatPage.tsx index 4ab259381..ad162a23e 100644 --- a/web/src/app/chat/ChatPage.tsx +++ b/web/src/app/chat/ChatPage.tsx @@ -91,7 +91,11 @@ import { DeleteEntityModal } from "../../components/modals/DeleteEntityModal"; import { MinimalMarkdown } from "@/components/chat_search/MinimalMarkdown"; import ExceptionTraceModal from "@/components/modals/ExceptionTraceModal"; -import { SEARCH_TOOL_NAME } from "./tools/constants"; +import { + INTERNET_SEARCH_TOOL_ID, + SEARCH_TOOL_ID, + SEARCH_TOOL_NAME, +} from "./tools/constants"; import { useUser } from "@/components/user/UserProvider"; import { ApiKeyModal } from "@/components/llm/ApiKeyModal"; import BlurBackground from "./shared_chat_search/BlurBackground"; @@ -272,8 +276,8 @@ export function ChatPage({ ? parseFloat(search_param_temperature) : selectedAssistant?.tools.some( (tool) => - tool.in_code_tool_id === "SearchTool" || - tool.in_code_tool_id === "InternetSearchTool" + tool.in_code_tool_id === SEARCH_TOOL_ID || + tool.in_code_tool_id === INTERNET_SEARCH_TOOL_ID ) ? 0 : 0.7; @@ -1842,7 +1846,7 @@ export function ChatPage({ useEffect(() => { if (liveAssistant) { const hasSearchTool = liveAssistant.tools.some( - (tool) => tool.in_code_tool_id === "SearchTool" + (tool) => tool.in_code_tool_id === SEARCH_TOOL_ID ); setRetrievalEnabled(hasSearchTool); if (!hasSearchTool) { @@ -1854,7 +1858,7 @@ export function ChatPage({ const [retrievalEnabled, setRetrievalEnabled] = useState(() => { if (liveAssistant) { return liveAssistant.tools.some( - (tool) => tool.in_code_tool_id === "SearchTool" + (tool) => tool.in_code_tool_id === SEARCH_TOOL_ID ); } return false; diff --git a/web/src/app/chat/lib.tsx b/web/src/app/chat/lib.tsx index a3815260f..e5aa62768 100644 --- a/web/src/app/chat/lib.tsx +++ b/web/src/app/chat/lib.tsx @@ -24,6 +24,9 @@ import { Persona } from "../admin/assistants/interfaces"; import { ReadonlyURLSearchParams } from "next/navigation"; import { SEARCH_PARAM_NAMES } from "./searchParams"; import { Settings } from "../admin/settings/interfaces"; +import { INTERNET_SEARCH_TOOL_ID } from "./tools/constants"; +import { SEARCH_TOOL_ID } from "./tools/constants"; +import { IIMAGE_GENERATION_TOOL_ID } from "./tools/constants"; interface ChatRetentionInfo { chatRetentionDays: number; @@ -572,14 +575,14 @@ export function personaIncludesRetrieval(selectedPersona: Persona) { return selectedPersona.tools.some( (tool) => tool.in_code_tool_id && - ["SearchTool", "InternetSearchTool"].includes(tool.in_code_tool_id) + [SEARCH_TOOL_ID, INTERNET_SEARCH_TOOL_ID].includes(tool.in_code_tool_id) ); } export function personaIncludesImage(selectedPersona: Persona) { return selectedPersona.tools.some( (tool) => - tool.in_code_tool_id && tool.in_code_tool_id == "ImageGenerationTool" + tool.in_code_tool_id && tool.in_code_tool_id == IIMAGE_GENERATION_TOOL_ID ); } diff --git a/web/src/app/chat/tools/constants.ts b/web/src/app/chat/tools/constants.ts index 35624493b..5f970b6f1 100644 --- a/web/src/app/chat/tools/constants.ts +++ b/web/src/app/chat/tools/constants.ts @@ -1,3 +1,9 @@ +// Tool names as referenced by tool results / tool calls export const SEARCH_TOOL_NAME = "run_search"; export const INTERNET_SEARCH_TOOL_NAME = "run_internet_search"; export const IMAGE_GENERATION_TOOL_NAME = "run_image_generation"; + +// In-code tool IDs that also correspond to the tool's name when associated with a persona +export const SEARCH_TOOL_ID = "SearchTool"; +export const IIMAGE_GENERATION_TOOL_ID = "ImageGenerationTool"; +export const INTERNET_SEARCH_TOOL_ID = "InternetSearchTool"; diff --git a/web/src/components/assistants/AssistantCards.tsx b/web/src/components/assistants/AssistantCards.tsx index b4f9df7d3..eac334b80 100644 --- a/web/src/components/assistants/AssistantCards.tsx +++ b/web/src/components/assistants/AssistantCards.tsx @@ -7,6 +7,8 @@ import { FiBookmark, FiImage, FiSearch } from "react-icons/fi"; import { MdDragIndicator } from "react-icons/md"; import { Badge } from "../ui/badge"; +import { IIMAGE_GENERATION_TOOL_ID } from "@/app/chat/tools/constants"; +import { SEARCH_TOOL_ID } from "@/app/chat/tools/constants"; export const AssistantCard = ({ assistant, @@ -19,14 +21,14 @@ export const AssistantCard = ({ }) => { const renderBadgeContent = (tool: { name: string }) => { switch (tool.name) { - case "SearchTool": + case SEARCH_TOOL_ID: return ( <> Search ); - case "ImageGenerationTool": + case IIMAGE_GENERATION_TOOL_ID: return ( <>