Skip to content

Commit

Permalink
fix: 4238 - fix default max_tokens set on remote models
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 12, 2024
1 parent 09bfc05 commit aac2216
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions extensions/inference-openai-extension/resources/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@
"format": "api",
"settings": {},
"parameters": {
"max_tokens": 32768,
"temperature": 1,
"top_p": 1,
"stream": true,
"max_tokens": 32768,
"frequency_penalty": 0,
"presence_penalty": 0
},
Expand All @@ -126,9 +126,9 @@
"format": "api",
"settings": {},
"parameters": {
"max_tokens": 65536,
"temperature": 1,
"top_p": 1,
"max_tokens": 65536,
"stream": true,
"frequency_penalty": 0,
"presence_penalty": 0
Expand Down
8 changes: 6 additions & 2 deletions web/containers/ModelDropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ const ModelDropdown = ({
model?.settings.ctx_len ?? 8192
)
const overriddenParameters = {
ctx_len: Math.min(8192, model?.settings.ctx_len ?? 8192),
max_tokens: defaultContextLength,
ctx_len: !isLocalEngine(model?.engine)
? undefined
: defaultContextLength,
max_tokens: !isLocalEngine(model?.engine)
? (model?.parameters.max_tokens ?? 8192)
: defaultContextLength,
}

const modelParams = {
Expand Down
7 changes: 5 additions & 2 deletions web/hooks/useCreateNewThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { fileUploadAtom } from '@/containers/Providers/Jotai'

import { toaster } from '@/containers/Toast'

import { isLocalEngine } from '@/utils/modelEngine'
import { generateThreadId } from '@/utils/thread'

import { useActiveModel } from './useActiveModel'
Expand Down Expand Up @@ -113,12 +114,14 @@ export const useCreateNewThread = () => {
)

const overriddenSettings = {
ctx_len: defaultContextLength,
ctx_len: !isLocalEngine(model?.engine) ? undefined : defaultContextLength,
}

// Use ctx length by default
const overriddenParameters = {
max_tokens: defaultContextLength,
max_tokens: !isLocalEngine(model?.engine)
? (model?.parameters.token_limit ?? 8192)
: defaultContextLength,
}

const createdAt = Date.now()
Expand Down
4 changes: 3 additions & 1 deletion web/utils/modelEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ export const getLogoEngine = (engine: InferenceEngine) => {
* @param engine
* @returns
*/
export const isLocalEngine = (engine: string) => {
export const isLocalEngine = (engine?: string) => {
if (!engine) return false

const engineObj = EngineManager.instance().get(engine)
if (!engineObj) return false
return (
Expand Down

0 comments on commit aac2216

Please sign in to comment.