Merge pull request #434 from janhq/fix/update-version

fix: app version and cleanup unused code
This commit is contained in:
Faisal Amir 2023-10-24 22:04:06 +07:00 committed by GitHub
commit e0dd07c0f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 2 additions and 140 deletions

View File

@ -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 }
}

View File

@ -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 }
}

View File

@ -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 }
}

View File

@ -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
}

View File

@ -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
}

View File

@ -1,18 +1,15 @@
import React from 'react' import React from 'react'
import SystemItem from '@containers/SystemItem' import SystemItem from '@containers/SystemItem'
import { useAtomValue } from 'jotai'
import useGetAppVersion from '@hooks/useGetAppVersion'
import useGetSystemResources from '@hooks/useGetSystemResources' import useGetSystemResources from '@hooks/useGetSystemResources'
import { useAtomValue } from 'jotai'
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom' import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
import { formatDownloadPercentage } from '@utils/converter' import { formatDownloadPercentage } from '@utils/converter'
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom' import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
const BottomBar = () => { const BottomBar = () => {
const activeModel = useAtomValue(activeAssistantModelAtom) const activeModel = useAtomValue(activeAssistantModelAtom)
const { version } = useGetAppVersion()
const { ram, cpu } = useGetSystemResources() const { ram, cpu } = useGetSystemResources()
const modelDownloadStates = useAtomValue(modelDownloadStateAtom) const modelDownloadStates = useAtomValue(modelDownloadStateAtom)
const getCurrentYear = new Date().getFullYear()
const downloadStates: DownloadState[] = [] const downloadStates: DownloadState[] = []
for (const [, value] of Object.entries(modelDownloadStates)) { for (const [, value] of Object.entries(modelDownloadStates)) {
@ -35,9 +32,7 @@ const BottomBar = () => {
<div className="flex gap-x-2"> <div className="flex gap-x-2">
<SystemItem name="CPU:" value={`${cpu}%`} /> <SystemItem name="CPU:" value={`${cpu}%`} />
<SystemItem name="Mem:" value={`${ram}%`} /> <SystemItem name="Mem:" value={`${ram}%`} />
<p className="text-xs text-muted-foreground"> <p className="text-xs font-semibold">Jan v0.2.0</p>
&copy;{getCurrentYear}&nbsp;Jan AI Pte Ltd. v{version}
</p>
</div> </div>
</div> </div>
) )