Skip to content

Commit 39a3fd5

Browse files
committed
fix types
1 parent 5bfc40e commit 39a3fd5

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/xl-ai/src/AIExtension.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ import { Plugin, PluginKey } from "prosemirror-state";
1313
import { fixTablesKey } from "prosemirror-tables";
1414
import { createStore, StoreApi } from "zustand/vanilla";
1515
import { CallLLMResult } from "./api/formats/CallLLMResult.js";
16-
import { llm, PromptBuilderInput } from "./api/index.js";
16+
import { PromptBuilderInput } from "./api/formats/PromptBuilder.js";
17+
import { llm } from "./api/index.js";
1718
import { createAgentCursorPlugin } from "./plugins/AgentCursorPlugin.js";
1819

20+
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
21+
1922
type ReadonlyStoreApi<T> = Pick<
2023
StoreApi<T>,
2124
"getState" | "getInitialState" | "subscribe"
@@ -63,10 +66,10 @@ type GlobalLLMCallOptions = {
6366
*/
6467
stream?: boolean;
6568

66-
promptBuilder: (
69+
promptBuilder?: (
6770
editor: BlockNoteEditor<any, any, any>,
6871
opts: PromptBuilderInput,
69-
) => Promise<Array<CoreMessage>> | undefined;
72+
) => Promise<Array<CoreMessage>>;
7073
};
7174

7275
// parameters that are specific to each call
@@ -109,7 +112,11 @@ export class AIExtension extends BlockNoteExtension {
109112
* These options are used across all LLM calls by default when calling {@link callLLM}
110113
*/
111114
public readonly options: ReturnType<
112-
ReturnType<typeof createStore<Required<GlobalLLMCallOptions>>>
115+
ReturnType<
116+
typeof createStore<
117+
MakeOptional<Required<GlobalLLMCallOptions>, "promptBuilder">
118+
>
119+
>
113120
>;
114121

115122
/**
@@ -126,7 +133,9 @@ export class AIExtension extends BlockNoteExtension {
126133
) {
127134
super();
128135

129-
this.options = createStore<Required<GlobalLLMCallOptions>>()((_set) => ({
136+
this.options = createStore<
137+
MakeOptional<Required<GlobalLLMCallOptions>, "promptBuilder">
138+
>()((_set) => ({
130139
dataFormat: "html",
131140
stream: true,
132141
...options,

0 commit comments

Comments
 (0)