jan/web/hooks/useGetModelById.ts
Louis 37c36363d8
refactor: plugin manager and execution as ts (#504)
* refactor: plugin manager and execution as ts

* chore: refactoring
2023-11-01 09:48:28 +07:00

24 lines
527 B
TypeScript

import { ModelManagementService } from '@janhq/core'
import { executeSerial } from '@plugin/extension-manager'
export default function useGetModelById() {
const getModelById = async (
modelId: string
): Promise<AssistantModel | undefined> => {
return queryModelById(modelId)
}
return { getModelById }
}
const queryModelById = async (
modelId: string
): Promise<AssistantModel | undefined> => {
const model = await executeSerial(
ModelManagementService.GetModelById,
modelId
)
return model
}