fix: remove redundant gpu detection prompt event (#1254)

This commit is contained in:
Louis 2023-12-29 16:37:34 +07:00 committed by GitHub
parent 28f8832950
commit a9579a3cbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 23 deletions

View File

@ -59,9 +59,11 @@ export default class JanInferenceNitroExtension implements InferenceExtension {
/**
* Subscribes to events emitted by the @janhq/core package.
*/
async onLoad(): Promise<void> {
async onLoad() {
if (!(await fs.existsSync(JanInferenceNitroExtension._homeDir))) {
await fs.mkdirSync(JanInferenceNitroExtension._homeDir).catch((err) => console.debug(err));
await fs
.mkdirSync(JanInferenceNitroExtension._homeDir)
.catch((err) => console.debug(err));
}
if (!(await fs.existsSync(JanInferenceNitroExtension._settingsDir)))
@ -87,21 +89,6 @@ export default class JanInferenceNitroExtension implements InferenceExtension {
// Attempt to fetch nvidia info
await executeOnMain(MODULE, "updateNvidiaInfo", {});
const gpuDriverConf = await fs.readFileSync(
join(JanInferenceNitroExtension._settingsDir, "settings.json")
);
if (gpuDriverConf.notify && gpuDriverConf.run_mode === "cpu") {
// Driver is fully installed, but not in use
if (gpuDriverConf.nvidia_driver?.exist && gpuDriverConf.cuda?.exist) {
events.emit("OnGPUCompatiblePrompt", {});
// Prompt user to switch
} else if (gpuDriverConf.nvidia_driver?.exist) {
// Prompt user to install cuda toolkit
events.emit("OnGPUDriverMissingPrompt", {});
}
}
Promise.resolve()
}
/**

View File

@ -53,7 +53,7 @@ export default class JanInferenceOpenAIExtension implements InferenceExtension {
/**
* Subscribes to events emitted by the @janhq/core package.
*/
async onLoad(): Promise<void> {
async onLoad() {
if (!(await fs.existsSync(JanInferenceOpenAIExtension._homeDir))) {
await fs
.mkdirSync(JanInferenceOpenAIExtension._homeDir)
@ -77,7 +77,6 @@ export default class JanInferenceOpenAIExtension implements InferenceExtension {
events.on(EventName.OnInferenceStopped, () => {
JanInferenceOpenAIExtension.handleInferenceStopped(this);
});
Promise.resolve();
}
/**

View File

@ -119,8 +119,6 @@ export default function EventHandler({ children }: { children: ReactNode }) {
}
}
}
function handleGpuCompatiblePrompt() {}
function handleGpuDriverMissingPrompt() {}
useEffect(() => {
if (window.core?.events) {
@ -129,8 +127,6 @@ export default function EventHandler({ children }: { children: ReactNode }) {
events.on(EventName.OnModelReady, handleModelReady)
events.on(EventName.OnModelFail, handleModelFail)
events.on(EventName.OnModelStopped, handleModelStopped)
events.on('OnGPUCompatiblePrompt', handleGpuCompatiblePrompt)
events.on('OnGPUDriverMissingPrompt', handleGpuDriverMissingPrompt)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])