"use client" import { ArrowsDownUp, Bell, CaretCircleDown, Sparkle } from "@phosphor-icons/react"; import { Button } from "@/components/ui/button"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"; import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { Textarea } from "@/components/ui/textarea"; import { ModelSelector } from "@/app/common/modelSelector"; import { FilesMenu } from "../allConversations/allConversations"; import { AgentConfigurationOptions } from "@/app/agents/page"; import useSWR from "swr"; import { Sheet, SheetContent } from "@/components/ui/sheet"; import { AgentData } from "../agentCard/agentCard"; import { useState } from "react"; import { getIconForSlashCommand, getIconFromIconName } from "@/app/common/iconUtils"; import { Label } from "@/components/ui/label"; import { Checkbox } from "@/components/ui/checkbox"; import { Tooltip, TooltipTrigger } from "@/components/ui/tooltip"; import { TooltipContent } from "@radix-ui/react-tooltip"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"; interface ChatSideBarProps { preexistingAgent?: AgentData | null; conversationId: string; isOpen: boolean; isMobileWidth?: boolean; onOpenChange: (open: boolean) => void; } const fetcher = (url: string) => fetch(url).then((res) => res.json()); export function ChatSidebar({ ...props }: ChatSideBarProps) { if (props.isMobileWidth) { return ( ); } return ( ); } function ChatSidebarInternal({ ...props }: ChatSideBarProps) { const isEditable = props.preexistingAgent?.name.toLowerCase() === "khoj" || props.preexistingAgent?.is_hidden === true; const isDefaultAgent = props.preexistingAgent?.name.toLowerCase() === "khoj"; const { data: agentConfigurationOptions, error: agentConfigurationOptionsError } = useSWR("/api/agents/options", fetcher); const [customPrompt, setCustomPrompt] = useState(!isDefaultAgent && props.preexistingAgent ? props.preexistingAgent.persona : "always respond in spanish"); const [selectedModel, setSelectedModel] = useState(props.preexistingAgent?.chat_model); const [inputTools, setInputTools] = useState(props.preexistingAgent?.input_tools); function isValueChecked(value: string, existingSelections: string[] | undefined): boolean { if (existingSelections === undefined || existingSelections === null || existingSelections.length === 0) { return true; } return existingSelections.includes(value); } return ( { props.preexistingAgent && !isEditable ? ( ) : (
{getIconFromIconName("lightbulb", "orange")} Chat Options
) }
{ props.preexistingAgent && props.preexistingAgent.has_files ? (
Using custom knowledge base
) : null }
Custom Instructions