Skip to content

BlockSuite API Documentation / @blocksuite/presets / AIProvider

Class: AIProvider

AI provider for the block suite

To use it, downstream (affine) has to provide AI actions implementation, user info etc

todo: breakdown into different parts?

Constructors

new AIProvider()

new AIProvider(): AIProvider

Returns

AIProvider

Properties

actionHistory

private readonly actionHistory: object[] = []

Source

packages/presets/src/ai/provider.ts:64


actions

private readonly actions: Partial<AIActions> = {}

Source

packages/presets/src/ai/provider.ts:38


histories

private histories: null | AIHistoryService = null

Source

packages/presets/src/ai/provider.ts:42


photoEngine

private photoEngine: null | AIPhotoEngineService = null

Source

packages/presets/src/ai/provider.ts:41


slots

private readonly slots: object

actions

actions: Slot<object>

Type declaration
action

action: keyof AIActions

event

event: ActionEventType

options

options: AITextActionOptions

requestContinueInChat

requestContinueInChat: Slot<object>

Type declaration
host

host: EditorHost

show

show: boolean

requestLogin

requestLogin: Slot<object>

Type declaration
host

host: EditorHost

requestRunInEdgeless

requestRunInEdgeless: Slot<object>

Type declaration
host

host: EditorHost

requestUpgradePlan

requestUpgradePlan: Slot<object>

Type declaration
host

host: EditorHost

userInfo

userInfo: Slot<null | AIUserInfo>

Source

packages/presets/src/ai/provider.ts:43


userInfoFn()

private userInfoFn: () => null | AIUserInfo | Promise<AIUserInfo>

Returns

null | AIUserInfo | Promise<AIUserInfo>

Source

packages/presets/src/ai/provider.ts:39


MAX_LOCAL_HISTORY

static MAX_LOCAL_HISTORY: number = 10

Source

packages/presets/src/ai/provider.ts:62


instance

private static readonly instance: AIProvider

Source

packages/presets/src/ai/provider.ts:37

Accessors

actionHistory

get static actionHistory(): object[]

Returns

object[]

Source

packages/presets/src/ai/provider.ts:227


actions

get static actions(): Partial<AIActions>

Returns

Partial<AIActions>

Source

packages/presets/src/ai/provider.ts:211


histories

get static histories(): null | AIHistoryService

Returns

null | AIHistoryService

Source

packages/presets/src/ai/provider.ts:223


photoEngine

get static photoEngine(): null | AIPhotoEngineService

Returns

null | AIPhotoEngineService

Source

packages/presets/src/ai/provider.ts:219


slots

get static slots(): object

Returns

object

actions

actions: Slot<object>

Type declaration
action

action: keyof AIActions

event

event: ActionEventType

options

options: AITextActionOptions

requestContinueInChat

requestContinueInChat: Slot<object>

Type declaration
host

host: EditorHost

show

show: boolean

requestLogin

requestLogin: Slot<object>

Type declaration
host

host: EditorHost

requestRunInEdgeless

requestRunInEdgeless: Slot<object>

Type declaration
host

host: EditorHost

requestUpgradePlan

requestUpgradePlan: Slot<object>

Type declaration
host

host: EditorHost

userInfo

userInfo: Slot<null | AIUserInfo>

Source

packages/presets/src/ai/provider.ts:207


userInfo

get static userInfo(): null | AIUserInfo | Promise<AIUserInfo>

Returns

null | AIUserInfo | Promise<AIUserInfo>

Source

packages/presets/src/ai/provider.ts:215

Methods

provideAction()

private provideAction<T>(id, action): void

Type parameters

T extends keyof AIActions

Parameters

id: T

action

Returns

void

Source

packages/presets/src/ai/provider.ts:107


provide()

provide(id, fn)

static provide(id, fn): void

Parameters

id: "userInfo"

fn

Returns

void

Source

packages/presets/src/ai/provider.ts:69

provide(id, service)

static provide(id, service): void

Parameters

id: "histories"

service: AIHistoryService

Returns

void

Source

packages/presets/src/ai/provider.ts:74

provide(id, engine)

static provide(id, engine): void

Parameters

id: "photoEngine"

engine: AIPhotoEngineService

Returns

void

Source

packages/presets/src/ai/provider.ts:79

provide(id, action)

static provide<T>(id, action): void

Type parameters

T extends keyof AIActions

Parameters

id: T

action

Returns

void

Source

packages/presets/src/ai/provider.ts:85