mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-08 05:39:13 +00:00
set initial model of default state
This commit is contained in:
@@ -57,11 +57,11 @@ export function ChatSidebar({ ...props }: ChatSideBarProps) {
|
|||||||
|
|
||||||
function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
|
function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
|
||||||
const [isEditable, setIsEditable] = useState<boolean>(false);
|
const [isEditable, setIsEditable] = useState<boolean>(false);
|
||||||
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(false);
|
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(true);
|
||||||
const { data: agentConfigurationOptions, error: agentConfigurationOptionsError } =
|
const { data: agentConfigurationOptions, error: agentConfigurationOptionsError } =
|
||||||
useSWR<AgentConfigurationOptions>("/api/agents/options", fetcher);
|
useSWR<AgentConfigurationOptions>("/api/agents/options", fetcher);
|
||||||
|
|
||||||
const { data: agentData, error: agentDataError } = useSWR<AgentData>(`/api/agents/conversation?conversation_id=${props.conversationId}`, fetcher);
|
const { data: agentData, isLoading: agentDataLoading, error: agentDataError } = useSWR<AgentData>(`/api/agents/conversation?conversation_id=${props.conversationId}`, fetcher);
|
||||||
const {
|
const {
|
||||||
data: authenticatedData,
|
data: authenticatedData,
|
||||||
error: authenticationError,
|
error: authenticationError,
|
||||||
@@ -92,10 +92,10 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (agentData.slug.toLowerCase() === "khoj") {
|
if (agentData.slug.toLowerCase() === "khoj") {
|
||||||
setIsDefaultAgent(true);
|
|
||||||
setSelectedModel(undefined);
|
setSelectedModel(undefined);
|
||||||
setCustomPrompt(undefined);
|
setCustomPrompt(undefined);
|
||||||
} else {
|
} else {
|
||||||
|
setIsDefaultAgent(false);
|
||||||
setCustomPrompt(agentData.persona);
|
setCustomPrompt(agentData.persona);
|
||||||
setSelectedModel(agentData.chat_model);
|
setSelectedModel(agentData.chat_model);
|
||||||
}
|
}
|
||||||
@@ -262,11 +262,10 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
|
|||||||
</SidebarGroupLabel>
|
</SidebarGroupLabel>
|
||||||
<SidebarMenu className="p-0 m-0">
|
<SidebarMenu className="p-0 m-0">
|
||||||
<SidebarMenuItem key={"model"} className="list-none">
|
<SidebarMenuItem key={"model"} className="list-none">
|
||||||
|
|
||||||
<ModelSelector
|
<ModelSelector
|
||||||
disabled={!isEditable || !authenticatedData?.is_active}
|
disabled={!isEditable || !authenticatedData?.is_active}
|
||||||
onSelect={(model, userModification) => handleModelSelect(model.name, userModification)}
|
onSelect={(model, userModification) => handleModelSelect(model.name, userModification)}
|
||||||
initialModel={agentData?.chat_model}
|
initialModel={isDefaultAgent ? '' : agentData?.chat_model}
|
||||||
selectedModel={selectedModel}
|
selectedModel={selectedModel}
|
||||||
/>
|
/>
|
||||||
</SidebarMenuItem>
|
</SidebarMenuItem>
|
||||||
|
|||||||
Reference in New Issue
Block a user