(null)
const { version } = useGetAppVersion()
const { experimentalFeatureEnabed } = useContext(FeatureToggleContext)
@@ -95,8 +92,6 @@ const ExtensionCatalog = () => {
}
}
- if (isLoading) return
-
return (
{extensionCatalog
diff --git a/web/types/index.d.ts b/web/types/index.d.ts
index 5e7b401ae..bd46b8a6f 100644
--- a/web/types/index.d.ts
+++ b/web/types/index.d.ts
@@ -8,6 +8,9 @@ declare global {
declare const VERSION: string
declare const ANALYTICS_ID: string
declare const ANALYTICS_HOST: string
+ declare const isMac: boolean
+ declare const isWindows: boolean
+ declare const isLinux: boolean
interface Core {
api: APIFunctions
events: EventEmitter
diff --git a/web/utils/componentSettings.ts b/web/utils/componentSettings.ts
new file mode 100644
index 000000000..c5cc666b5
--- /dev/null
+++ b/web/utils/componentSettings.ts
@@ -0,0 +1,39 @@
+import { ModelRuntimeParams, ModelSettingParams } from '@janhq/core'
+
+import { presetConfiguration } from '@/screens/Chat/ModelSetting/predefinedComponent'
+
+import { SettingComponentData } from '@/screens/Chat/ModelSetting/settingComponentBuilder'
+
+import { ModelParams } from '@/helpers/atoms/Thread.atom'
+
+export const getConfigurationsData = (
+ settings: ModelSettingParams | ModelRuntimeParams
+) => {
+ const componentData: SettingComponentData[] = []
+ Object.keys(settings).forEach((key: string) => {
+ const componentSetting = presetConfiguration[key]
+
+ if (!componentSetting) {
+ return
+ }
+ if ('slider' === componentSetting.controllerType) {
+ const value = Number(settings[key as keyof ModelParams])
+ if ('value' in componentSetting.controllerData)
+ componentSetting.controllerData.value = value
+ } else if ('input' === componentSetting.controllerType) {
+ const value = settings[key as keyof ModelParams] as string
+ const placeholder = settings[key as keyof ModelParams] as string
+ if ('value' in componentSetting.controllerData)
+ componentSetting.controllerData.value = value
+ if ('placeholder' in componentSetting.controllerData)
+ componentSetting.controllerData.placeholder = placeholder
+ } else if ('checkbox' === componentSetting.controllerType) {
+ const checked = settings[key as keyof ModelParams] as boolean
+
+ if ('checked' in componentSetting.controllerData)
+ componentSetting.controllerData.checked = checked
+ }
+ componentData.push(componentSetting)
+ })
+ return componentData
+}
diff --git a/web/utils/model.ts b/web/utils/model.ts
new file mode 100644
index 000000000..5c5ef1264
--- /dev/null
+++ b/web/utils/model.ts
@@ -0,0 +1,12 @@
+import { basename } from 'path'
+
+import { Model } from '@janhq/core'
+
+export const modelBinFileName = (model: Model) => {
+ const modelFormatExt = '.gguf'
+ const extractedFileName = basename(model.source_url) ?? model.id
+ const fileName = extractedFileName.toLowerCase().endsWith(modelFormatExt)
+ ? extractedFileName
+ : model.id
+ return fileName
+}
diff --git a/web/utils/model_param.ts b/web/utils/model_param.ts
new file mode 100644
index 000000000..7d559c313
--- /dev/null
+++ b/web/utils/model_param.ts
@@ -0,0 +1,53 @@
+import { ModelRuntimeParams, ModelSettingParams } from '@janhq/core'
+
+import { ModelParams } from '@/helpers/atoms/Thread.atom'
+
+export const toRuntimeParams = (
+ modelParams?: ModelParams
+): ModelRuntimeParams => {
+ if (!modelParams) return {}
+ const defaultModelParams: ModelRuntimeParams = {
+ temperature: undefined,
+ token_limit: undefined,
+ top_k: undefined,
+ top_p: undefined,
+ stream: undefined,
+ max_tokens: undefined,
+ stop: undefined,
+ frequency_penalty: undefined,
+ presence_penalty: undefined,
+ }
+
+ const runtimeParams: ModelRuntimeParams = {}
+
+ for (const [key, value] of Object.entries(modelParams)) {
+ if (key in defaultModelParams) {
+ runtimeParams[key as keyof ModelRuntimeParams] = value
+ }
+ }
+
+ return runtimeParams
+}
+
+export const toSettingParams = (
+ modelParams?: ModelParams
+): ModelSettingParams => {
+ if (!modelParams) return {}
+ const defaultSettingParams: ModelSettingParams = {
+ ctx_len: undefined,
+ ngl: undefined,
+ embedding: undefined,
+ n_parallel: undefined,
+ cpu_threads: undefined,
+ prompt_template: undefined,
+ }
+ const settingParams: ModelSettingParams = {}
+
+ for (const [key, value] of Object.entries(modelParams)) {
+ if (key in defaultSettingParams) {
+ settingParams[key as keyof ModelSettingParams] = value
+ }
+ }
+
+ return settingParams
+}