Remove unused code folder
This commit is contained in:
parent
3f0de68c96
commit
2cf9c0f26c
@ -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
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user