Skip to content

Commit

Permalink
set initial model of default state
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Feb 4, 2025
1 parent 51874c2 commit 4409a58
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/interface/web/app/components/chatSidebar/chatSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export function ChatSidebar({ ...props }: ChatSideBarProps) {

function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
const [isEditable, setIsEditable] = useState<boolean>(false);
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(false);
const [isDefaultAgent, setIsDefaultAgent] = useState<boolean>(true);
const { data: agentConfigurationOptions, error: agentConfigurationOptionsError } =
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 {
data: authenticatedData,
error: authenticationError,
Expand Down Expand Up @@ -92,10 +92,10 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
}

if (agentData.slug.toLowerCase() === "khoj") {
setIsDefaultAgent(true);
setSelectedModel(undefined);
setCustomPrompt(undefined);
} else {
setIsDefaultAgent(false);
setCustomPrompt(agentData.persona);
setSelectedModel(agentData.chat_model);
}
Expand Down Expand Up @@ -262,11 +262,10 @@ function ChatSidebarInternal({ ...props }: ChatSideBarProps) {
</SidebarGroupLabel>
<SidebarMenu className="p-0 m-0">
<SidebarMenuItem key={"model"} className="list-none">

<ModelSelector
disabled={!isEditable || !authenticatedData?.is_active}
onSelect={(model, userModification) => handleModelSelect(model.name, userModification)}
initialModel={agentData?.chat_model}
initialModel={isDefaultAgent ? '' : agentData?.chat_model}
selectedModel={selectedModel}
/>
</SidebarMenuItem>
Expand Down

0 comments on commit 4409a58

Please sign in to comment.