diff --git a/web/hooks/useCreateNewThread.ts b/web/hooks/useCreateNewThread.ts index aeef2754f7..4901b9846a 100644 --- a/web/hooks/useCreateNewThread.ts +++ b/web/hooks/useCreateNewThread.ts @@ -51,11 +51,13 @@ export const useCreateNewThread = () => { const { recommendedModel } = useRecommendedModel() + const selectedModel = useAtomValue(selectedModelAtom) + const requestCreateNewThread = async ( assistant: (ThreadAssistantInfo & { id: string; name: string }) | Assistant, model?: Model | undefined ) => { - const defaultModel = model || recommendedModel + const defaultModel = model || selectedModel || recommendedModel if (!model) { // if we have model, which means user wants to create new thread from Model hub. Allow them. @@ -82,12 +84,12 @@ export const useCreateNewThread = () => { // Default context length is 8192 const defaultContextLength = Math.min( 8192, - defaultModel?.settings.ctx_len ?? 8192 + defaultModel?.settings?.ctx_len ?? 8192 ) const overriddenSettings = { - ctx_len: defaultModel?.settings.ctx_len - ? Math.min(8192, defaultModel.settings.ctx_len) + ctx_len: defaultModel?.settings?.ctx_len + ? Math.min(8192, defaultModel?.settings?.ctx_len) : undefined, } @@ -95,10 +97,10 @@ export const useCreateNewThread = () => { const overriddenParameters = { max_tokens: defaultContextLength ? Math.min( - defaultModel?.parameters.max_tokens ?? 8192, + defaultModel?.parameters?.max_tokens ?? 8192, defaultContextLength ) - : defaultModel?.parameters.max_tokens, + : defaultModel?.parameters?.max_tokens, } const createdAt = Date.now()