From 6ed5857158ca23949e06bb2f8163a5a347b1990b Mon Sep 17 00:00:00 2001 From: Thomas Beverley Date: Mon, 9 Dec 2024 16:10:04 +0000 Subject: [PATCH] Refactor a global usage of IPC from the coremodel --- .../contentscript-main/AICoreModel/AICoreModel.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/extension/contentscript-main/AICoreModel/AICoreModel.ts b/src/extension/contentscript-main/AICoreModel/AICoreModel.ts index 2e5bc92..579beba 100644 --- a/src/extension/contentscript-main/AICoreModel/AICoreModel.ts +++ b/src/extension/contentscript-main/AICoreModel/AICoreModel.ts @@ -4,7 +4,6 @@ import { AICoreModelProps, AICoreModelCloneOptions } from '#Shared/API/AICoreModel/AICoreModelTypes' -import IPC from '../IPC' import { kCoreModelCreate, kCoreModelPrompt, kCoreModelCountTokens } from '#Shared/API/AICoreModel/AICoreModelIPCTypes' import { kSessionDestroyed } from '#Shared/Errors' import { readablePromptStreamToString } from '../AIHelpers' @@ -42,7 +41,7 @@ class AICoreModel extends AIRootModel { this.#guardDestroyed() const signal = AbortSignal.any([options.signal, this.#signal].filter(Boolean)) - const data = (await IPC.request(kCoreModelCreate, this.#props, { signal })) as AICoreModelData + const data = (await this.#ipc.request(kCoreModelCreate, this.#props, { signal })) as AICoreModelData const session = new AICoreModel(this.#ipc, data) return session } @@ -78,7 +77,7 @@ class AICoreModel extends AIRootModel { return new ReadableStream({ start: (controller) => { let buffer = '' - IPC.stream( + this.#ipc.stream( kCoreModelPrompt, { sessionId: this.#sessionId, @@ -106,7 +105,7 @@ class AICoreModel extends AIRootModel { this.#guardDestroyed() const signal = AbortSignal.any([options.signal, this.#signal].filter(Boolean)) - const count = (await IPC.request(kCoreModelCountTokens, { props: this.#props, input: prompt }, { signal })) as number + const count = (await this.#ipc.request(kCoreModelCountTokens, { props: this.#props, input: prompt }, { signal })) as number return count } }