Skip to content
Merged
Show file tree
Hide file tree
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
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 @@ -99,7 +99,7 @@
)

const isModelSupportRagAndTools = useCallback((model: Model) => {
return (

Check warning on line 102 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

102 line is not covered with tests
model?.engine === InferenceEngine.openai ||
isLocalEngine(model?.engine as InferenceEngine)
)
Expand All @@ -110,7 +110,7 @@
configuredModels
.concat(
downloadedModels.filter(
(e) => !configuredModels.some((x) => x.id === e.id)

Check warning on line 113 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

113 line is not covered with tests
)
)
.filter((e) =>
Expand All @@ -120,24 +120,24 @@
if (searchFilter === 'local') {
return isLocalEngine(e.engine)
}
if (searchFilter === 'remote') {
return !isLocalEngine(e.engine)

Check warning on line 124 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

123-124 lines are not covered with tests
}
})
.sort((a, b) => a.name.localeCompare(b.name))

Check warning on line 127 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

127 line is not covered with tests
.sort((a, b) => {
const aInDownloadedModels = downloadedModels.some(
(item) => item.id === a.id

Check warning on line 130 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

129-130 lines are not covered with tests
)
const bInDownloadedModels = downloadedModels.some(
(item) => item.id === b.id

Check warning on line 133 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

132-133 lines are not covered with tests
)
if (aInDownloadedModels && !bInDownloadedModels) {
return -1
} else if (!aInDownloadedModels && bInDownloadedModels) {
return 1

Check warning on line 138 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

135-138 lines are not covered with tests
} else {
return 0

Check warning on line 140 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

140 line is not covered with tests
}
}),
[configuredModels, searchText, searchFilter, downloadedModels]
Expand All @@ -145,7 +145,7 @@

useEffect(() => {
if (open && searchInputRef.current) {
searchInputRef.current.focus()

Check warning on line 148 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

148 line is not covered with tests
}
}, [open])

Expand All @@ -162,9 +162,9 @@

const onClickModelItem = useCallback(
async (modelId: string) => {
const model = downloadedModels.find((m) => m.id === modelId)
setSelectedModel(model)
setOpen(false)

Check warning on line 167 in web/containers/ModelDropdown/index.tsx

View workflow job for this annotation

GitHub Actions / coverage-check

165-167 lines are not covered with tests

if (activeThread) {
// Change assistand tools based on model support RAG
Expand Down Expand Up @@ -192,8 +192,12 @@
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
Loading