Skip to content

Commit

Permalink
Refactor a global usage of IPC from the coremodel
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas101 committed Dec 9, 2024
1 parent 098fb89 commit 6ed5857
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/extension/contentscript-main/AICoreModel/AICoreModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -78,7 +77,7 @@ class AICoreModel extends AIRootModel {
return new ReadableStream({
start: (controller) => {
let buffer = ''
IPC.stream(
this.#ipc.stream(
kCoreModelPrompt,
{
sessionId: this.#sessionId,
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 6ed5857

Please sign in to comment.