Merge pull request #434 from janhq/fix/update-version
fix: app version and cleanup unused code
This commit is contained in:
commit
e0dd07c0f8
@ -1,14 +0,0 @@
|
||||
import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
|
||||
export default function useCreateBot() {
|
||||
const createBot = async (bot: Bot) => {
|
||||
try {
|
||||
await executeSerial('createBot', bot)
|
||||
} catch (err) {
|
||||
alert(err)
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
return { createBot }
|
||||
}
|
||||
@ -1,24 +0,0 @@
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import { rightSideBarExpandStateAtom } from '@helpers/atoms/SideBarExpand.atom'
|
||||
|
||||
export default function useDeleteBot() {
|
||||
const setActiveBot = useSetAtom(activeBotAtom)
|
||||
const setRightPanelVisibility = useSetAtom(rightSideBarExpandStateAtom)
|
||||
|
||||
const deleteBot = async (botId: string): Promise<'success' | 'failed'> => {
|
||||
try {
|
||||
await executeSerial('deleteBot', botId)
|
||||
setRightPanelVisibility(false)
|
||||
setActiveBot(undefined)
|
||||
return 'success'
|
||||
} catch (err) {
|
||||
alert(`Failed to delete bot ${botId}: ${err}`)
|
||||
console.error(err)
|
||||
return 'failed'
|
||||
}
|
||||
}
|
||||
|
||||
return { deleteBot }
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
|
||||
export default function useGetBots() {
|
||||
const getAllBots = async (): Promise<Bot[]> => {
|
||||
try {
|
||||
const bots = await executeSerial('getBots')
|
||||
return bots
|
||||
} catch (err) {
|
||||
alert(`Failed to get bots: ${err}`)
|
||||
console.error(err)
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const getBotById = async (botId: string): Promise<Bot | undefined> => {
|
||||
try {
|
||||
const bot: Bot = await executeSerial('getBotById', botId)
|
||||
return bot
|
||||
} catch (err) {
|
||||
alert(`Failed to get bot ${botId}: ${err}`)
|
||||
console.error(err)
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
return { getBotById, getAllBots }
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
import { executeSerial } from '../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
|
||||
export default function useUpdateBot() {
|
||||
const updateBot = async (
|
||||
bot: Bot,
|
||||
updatableField: UpdatableField
|
||||
): Promise<void> => {
|
||||
try {
|
||||
// TODO: if bot does not changed, no need to update
|
||||
|
||||
for (const [key, value] of Object.entries(updatableField)) {
|
||||
if (value !== undefined) {
|
||||
//@ts-ignore
|
||||
bot[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
await executeSerial('updateBot', bot)
|
||||
console.debug('Bot updated', JSON.stringify(bot, null, 2))
|
||||
} catch (err) {
|
||||
alert(`Update bot error: ${err}`)
|
||||
console.error(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
return { updateBot }
|
||||
}
|
||||
|
||||
export type UpdatableField = {
|
||||
presencePenalty?: number
|
||||
frequencyPenalty?: number
|
||||
maxTokens?: number
|
||||
customTemperature?: number
|
||||
systemPrompt?: number
|
||||
}
|
||||
@ -1,32 +0,0 @@
|
||||
export type Bot = {
|
||||
_id: string
|
||||
name: string
|
||||
description: string
|
||||
visibleFromBotProfile: boolean
|
||||
systemPrompt: string
|
||||
welcomeMessage: string
|
||||
publiclyAccessible: boolean
|
||||
suggestReplies: boolean
|
||||
renderMarkdownContent: boolean
|
||||
|
||||
/**
|
||||
* If true, the bot will use the custom temperature value instead of the
|
||||
* default temperature value.
|
||||
*/
|
||||
enableCustomTemperature: boolean
|
||||
|
||||
/**
|
||||
* Default is 0.7.
|
||||
*/
|
||||
customTemperature: number
|
||||
|
||||
maxTokens: number
|
||||
|
||||
frequencyPenalty: number
|
||||
|
||||
presencePenalty: number
|
||||
|
||||
modelId: string
|
||||
createdAt?: number
|
||||
updatedAt?: number
|
||||
}
|
||||
@ -1,18 +1,15 @@
|
||||
import React from 'react'
|
||||
import SystemItem from '@containers/SystemItem'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import useGetAppVersion from '@hooks/useGetAppVersion'
|
||||
import useGetSystemResources from '@hooks/useGetSystemResources'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
import { formatDownloadPercentage } from '@utils/converter'
|
||||
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
|
||||
|
||||
const BottomBar = () => {
|
||||
const activeModel = useAtomValue(activeAssistantModelAtom)
|
||||
const { version } = useGetAppVersion()
|
||||
const { ram, cpu } = useGetSystemResources()
|
||||
const modelDownloadStates = useAtomValue(modelDownloadStateAtom)
|
||||
const getCurrentYear = new Date().getFullYear()
|
||||
|
||||
const downloadStates: DownloadState[] = []
|
||||
for (const [, value] of Object.entries(modelDownloadStates)) {
|
||||
@ -35,9 +32,7 @@ const BottomBar = () => {
|
||||
<div className="flex gap-x-2">
|
||||
<SystemItem name="CPU:" value={`${cpu}%`} />
|
||||
<SystemItem name="Mem:" value={`${ram}%`} />
|
||||
<p className="text-xs text-muted-foreground">
|
||||
©{getCurrentYear} Jan AI Pte Ltd. v{version}
|
||||
</p>
|
||||
<p className="text-xs font-semibold">Jan v0.2.0</p>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user