Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: max_tokens revert back to 8192 automatically when creating a new thread #4397

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/hooks/useCreateNewThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
ExtensionTypeEnum,
Thread,
ThreadAssistantInfo,
ThreadState,

Check warning on line 8 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

'ThreadState' is defined but never used

Check warning on line 8 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

'ThreadState' is defined but never used

Check warning on line 8 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

'ThreadState' is defined but never used
AssistantTool,
Model,
Assistant,
} from '@janhq/core'
import { atom, useAtom, useAtomValue, useSetAtom } from 'jotai'

Check warning on line 13 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

'atom' is defined but never used

Check warning on line 13 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

'atom' is defined but never used

Check warning on line 13 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

'atom' is defined but never used

import { useDebouncedCallback } from 'use-debounce'

Expand All @@ -33,7 +33,7 @@
threadsAtom,
updateThreadAtom,
setThreadModelParamsAtom,
isGeneratingResponseAtom,

Check warning on line 36 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

'isGeneratingResponseAtom' is defined but never used

Check warning on line 36 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

'isGeneratingResponseAtom' is defined but never used

Check warning on line 36 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / test-on-macos

'isGeneratingResponseAtom' is defined but never used
createNewThreadAtom,
} from '@/helpers/atoms/Thread.atom'

Expand Down Expand Up @@ -98,7 +98,7 @@
// Use ctx length by default
const overriddenParameters = {
max_tokens: !isLocalEngine(defaultModel?.engine)
? (defaultModel?.parameters.token_limit ?? 8192)
? (defaultModel?.parameters.max_tokens ?? 8192)
: defaultContextLength,
}

Expand Down Expand Up @@ -136,19 +136,19 @@
//TODO: Why do we have thread list then thread states? Should combine them
try {
const createdThread = await persistNewThread(thread, assistantInfo)
if (!createdThread) throw 'Thread created failed.'
createNewThread(createdThread)

Check warning on line 140 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

139-140 lines are not covered with tests

setSelectedModel(defaultModel)
setThreadModelParams(createdThread.id, {

Check warning on line 143 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

142-143 lines are not covered with tests
...defaultModel?.settings,
...defaultModel?.parameters,
...overriddenSettings,
})

// Delete the file upload state
setFileUpload(undefined)
setActiveThread(createdThread)

Check warning on line 151 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

150-151 lines are not covered with tests
} catch (ex) {
return toaster({
title: 'Thread created failed.',
Expand All @@ -159,7 +159,7 @@
}

const updateThreadExtension = (thread: Thread) => {
return extensionManager

Check warning on line 162 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

162 line is not covered with tests
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.modifyThread(thread)
}
Expand All @@ -168,7 +168,7 @@
threadId: string,
assistant: ThreadAssistantInfo
) => {
return extensionManager

Check warning on line 171 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

171 line is not covered with tests
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.modifyThreadAssistant(threadId, assistant)
}
Expand Down Expand Up @@ -205,13 +205,13 @@
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.createThread(thread)
.then(async (thread) => {
await extensionManager

Check warning on line 208 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

208 line is not covered with tests
.get<ConversationalExtension>(ExtensionTypeEnum.Conversational)
?.createThreadAssistant(thread.id, assistantInfo)
.catch(console.error)
return thread

Check warning on line 212 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

212 line is not covered with tests
})
.catch(() => undefined)

Check warning on line 214 in web/hooks/useCreateNewThread.ts

View workflow job for this annotation

GitHub Actions / coverage-check

214 line is not covered with tests
}

return {
Expand Down
Loading