llm-exe 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +130 -50
- package/dist/index.d.ts +130 -50
- package/dist/index.js +525 -240
- package/dist/index.mjs +521 -240
- package/package.json +6 -5
- package/readme.md +122 -52
package/dist/index.d.mts
CHANGED
|
@@ -31,21 +31,23 @@ interface IChatUserMessage extends IChatMessageBase {
|
|
|
31
31
|
name?: string;
|
|
32
32
|
}
|
|
33
33
|
interface IChatFunctionMessage extends IChatMessageBase {
|
|
34
|
+
id?: string;
|
|
34
35
|
role: Extract<IChatMessageRole, "function">;
|
|
35
36
|
content: string;
|
|
36
37
|
name: string;
|
|
37
38
|
}
|
|
38
39
|
interface IChatAssistantMessage extends IChatMessageBase {
|
|
39
|
-
role: Extract<IChatMessageRole, "assistant">;
|
|
40
|
+
role: Extract<IChatMessageRole, "assistant" | "model">;
|
|
40
41
|
content: string;
|
|
41
42
|
function_call?: undefined;
|
|
42
43
|
}
|
|
43
|
-
interface
|
|
44
|
-
role: Extract<IChatMessageRole, "
|
|
44
|
+
interface IChatFunctionCallMessage extends IChatMessageBase {
|
|
45
|
+
role: Extract<IChatMessageRole, "function_call">;
|
|
45
46
|
content: null;
|
|
46
|
-
function_call
|
|
47
|
+
function_call: {
|
|
47
48
|
name: string;
|
|
48
49
|
arguments: string;
|
|
50
|
+
id?: string;
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
interface IChatSystemMessage extends IChatMessageBase {
|
|
@@ -57,29 +59,16 @@ interface IChatMessagesPlaceholder {
|
|
|
57
59
|
content: string;
|
|
58
60
|
}
|
|
59
61
|
type IPromptMessages = (IChatSystemMessage | IChatMessagesPlaceholder)[];
|
|
60
|
-
type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage |
|
|
61
|
-
type IChatMessage = IChatUserMessage | IChatAssistantMessage |
|
|
62
|
+
type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatMessagesPlaceholder | IChatFunctionMessage)[];
|
|
63
|
+
type IChatMessage = IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatFunctionMessage;
|
|
62
64
|
type IChatMessages = IChatMessage[];
|
|
63
65
|
|
|
64
66
|
type OpenAIChatModelName = "gpt-3.5-turbo" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-16k" | "gpt-4-0613" | "gpt-4" | "gpt-4o" | "gpt-4o-mini" | "gpt-4-0613" | "gpt-4-32k-0613" | `gpt-4${string}` | `gpt-3.5-turbo-${string}`;
|
|
65
67
|
type OpenAIConversationModelName = "davinci" | "text-curie-001" | "text-babbage-001" | "text-ada-001";
|
|
66
68
|
type OpenAIEmbeddingModelName = "text-embedding-ada-002";
|
|
67
69
|
type OpenAIModelName = OpenAIChatModelName | OpenAIConversationModelName | OpenAIEmbeddingModelName;
|
|
68
|
-
interface LlmExecutorExecuteOptions {
|
|
69
|
-
functions?: CallableExecutorCore[];
|
|
70
|
-
functionCall?: any;
|
|
71
|
-
jsonSchema?: Record<string, any>;
|
|
72
|
-
}
|
|
73
|
-
type GenericFunctionCall = "auto" | "none" | "any" | {
|
|
74
|
-
name: string;
|
|
75
|
-
};
|
|
76
|
-
interface OpenAiLlmExecutorOptions<T extends GenericFunctionCall = "auto"> extends LlmExecutorExecuteOptions {
|
|
77
|
-
functions?: CallableExecutorCore[];
|
|
78
|
-
functionCall?: T;
|
|
79
|
-
functionCallStrictInput?: boolean;
|
|
80
|
-
jsonSchema?: Record<string, any>;
|
|
81
|
-
}
|
|
82
70
|
|
|
71
|
+
type ParserInput = string | OutputResult;
|
|
83
72
|
/**
|
|
84
73
|
* BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
|
|
85
74
|
*/
|
|
@@ -100,7 +89,7 @@ declare abstract class BaseParser<T = any> {
|
|
|
100
89
|
* @param [attributes] - Optional attributes to use during parsing.
|
|
101
90
|
* @returns The parsed data.
|
|
102
91
|
*/
|
|
103
|
-
abstract parse(text:
|
|
92
|
+
abstract parse(text: ParserInput, attributes?: Record<string, any>): T;
|
|
104
93
|
}
|
|
105
94
|
declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>> extends BaseParser<T> {
|
|
106
95
|
schema: S;
|
|
@@ -113,26 +102,11 @@ declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = und
|
|
|
113
102
|
constructor(name: string, options: BaseParserOptionsWithSchema<S>);
|
|
114
103
|
}
|
|
115
104
|
|
|
116
|
-
interface OpenAiFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
117
|
-
parser: T;
|
|
118
|
-
}
|
|
119
|
-
declare class OpenAiFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
|
|
120
|
-
name: any;
|
|
121
|
-
arguments: any;
|
|
122
|
-
}> {
|
|
123
|
-
parser: T;
|
|
124
|
-
constructor(options: OpenAiFunctionParserOptions<T>);
|
|
125
|
-
parse(text: OutputResultContent[], _options?: Record<string, any>): ParserOutput<T> | {
|
|
126
|
-
name: string;
|
|
127
|
-
arguments: any;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
105
|
interface StringParserOptions extends BaseParserOptions {
|
|
132
106
|
}
|
|
133
107
|
declare class StringParser extends BaseParser<string> {
|
|
134
108
|
constructor(options?: StringParserOptions);
|
|
135
|
-
parse(text: string |
|
|
109
|
+
parse(text: string | OutputResult, _options?: Record<string, any>): string;
|
|
136
110
|
}
|
|
137
111
|
|
|
138
112
|
interface BooleanParserOptions extends BaseParserOptions {
|
|
@@ -330,6 +304,36 @@ declare function createParser<T extends Extract<CreateParserType, "json">, S ext
|
|
|
330
304
|
declare function createParser<T extends CreateParserType, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptionsWithSchema<S> | BaseParserOptions): JsonParser<S> | ListToJsonParser<S> | StringParser | NumberParser | BooleanParser | ListToArrayParser | ListToKeyValueParser | ReplaceStringTemplateParser | MarkdownCodeBlockParser | MarkdownCodeBlocksParser | StringExtractParser;
|
|
331
305
|
declare function createCustomParser<O>(name: string, parserFn: (text: string, inputValues: ExecutorContext<any, any>) => O): CustomParser<ReturnType<typeof parserFn>>;
|
|
332
306
|
|
|
307
|
+
declare class LlmFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | OutputResultContent[]> {
|
|
308
|
+
parser: T;
|
|
309
|
+
constructor(options: LlmNativeFunctionParserOptions<T>);
|
|
310
|
+
parse(text: OutputResult, _options?: Record<string, any>): OutputResultContent[] | ParserOutput<T>;
|
|
311
|
+
}
|
|
312
|
+
interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
313
|
+
parser: T;
|
|
314
|
+
}
|
|
315
|
+
interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
316
|
+
parser: T;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @deprecated Use `LlmFunctionParser` instead.
|
|
320
|
+
*/
|
|
321
|
+
declare class LlmNativeFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
|
|
322
|
+
name: any;
|
|
323
|
+
arguments: any;
|
|
324
|
+
}> {
|
|
325
|
+
parser: T;
|
|
326
|
+
constructor(options: LlmNativeFunctionParserOptions<T>);
|
|
327
|
+
parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | {
|
|
328
|
+
name: string;
|
|
329
|
+
arguments: any;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @deprecated Use `LlmExecutorWithFunctions` instead.
|
|
334
|
+
*/
|
|
335
|
+
declare const OpenAiFunctionParser: typeof LlmNativeFunctionParser;
|
|
336
|
+
|
|
333
337
|
declare function replaceTemplateString(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): string;
|
|
334
338
|
|
|
335
339
|
declare function replaceTemplateStringAsync(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): Promise<string>;
|
|
@@ -445,7 +449,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
445
449
|
* @param name (optional) The name of the user. Only accepted if role is `user`.
|
|
446
450
|
* @return instance of ChatPrompt.
|
|
447
451
|
*/
|
|
448
|
-
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant">, name?: undefined): ChatPrompt<I>;
|
|
452
|
+
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant" | "model">, name?: undefined): ChatPrompt<I>;
|
|
449
453
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "system">, name?: undefined): ChatPrompt<I>;
|
|
450
454
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "user">, name?: string): ChatPrompt<I>;
|
|
451
455
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "function">, name: string): ChatPrompt<I>;
|
|
@@ -468,7 +472,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
468
472
|
* @param content The message content.
|
|
469
473
|
* @return ChatPrompt so it can be chained.
|
|
470
474
|
*/
|
|
471
|
-
addFunctionMessage(content: string, name: string): ChatPrompt<I>;
|
|
475
|
+
addFunctionMessage(content: string, name: string, id?: string): ChatPrompt<I>;
|
|
472
476
|
/**
|
|
473
477
|
* addFunctionCallMessage Helper to add an assistant message to the prompt.
|
|
474
478
|
* @param content The message content.
|
|
@@ -477,6 +481,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
477
481
|
addFunctionCallMessage(function_call?: {
|
|
478
482
|
name: string;
|
|
479
483
|
arguments: string;
|
|
484
|
+
id?: string;
|
|
480
485
|
}): this;
|
|
481
486
|
/**
|
|
482
487
|
* addFromHistory Adds multiple messages at one time.
|
|
@@ -667,13 +672,27 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
667
672
|
name: string;
|
|
668
673
|
constructor(name: string);
|
|
669
674
|
setUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
|
|
670
|
-
setAssistantMessage(content: string): this;
|
|
675
|
+
setAssistantMessage(content: string | OutputResultsText): this;
|
|
671
676
|
setSystemMessage(content: string): this;
|
|
672
|
-
|
|
677
|
+
setToolMessage(content: string, name: string, id?: string): void;
|
|
678
|
+
setFunctionMessage(content: string, name: string, id?: string): this;
|
|
679
|
+
/**
|
|
680
|
+
* Set
|
|
681
|
+
*/
|
|
682
|
+
setToolCallMessage(input: {
|
|
683
|
+
name: string;
|
|
684
|
+
arguments: string;
|
|
685
|
+
id?: string;
|
|
686
|
+
}): void;
|
|
673
687
|
setFunctionCallMessage(input: {
|
|
688
|
+
name: string;
|
|
689
|
+
arguments: string;
|
|
690
|
+
id?: string;
|
|
691
|
+
} | {
|
|
674
692
|
function_call: {
|
|
675
693
|
name: string;
|
|
676
694
|
arguments: string;
|
|
695
|
+
id?: string;
|
|
677
696
|
};
|
|
678
697
|
}): this;
|
|
679
698
|
setMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
@@ -684,6 +703,13 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
684
703
|
name: string;
|
|
685
704
|
value: IChatMessage[];
|
|
686
705
|
};
|
|
706
|
+
/**
|
|
707
|
+
* Add LLM output to dialogue history in the order it was returned
|
|
708
|
+
*
|
|
709
|
+
* @param output - The LLM output result from llm.call()
|
|
710
|
+
* @returns this for chaining
|
|
711
|
+
*/
|
|
712
|
+
addFromOutput(output: OutputResult | BaseLlCall): this;
|
|
687
713
|
}
|
|
688
714
|
|
|
689
715
|
declare abstract class BaseState {
|
|
@@ -740,9 +766,19 @@ declare class LlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<Re
|
|
|
740
766
|
/**
|
|
741
767
|
* Core Executor With LLM
|
|
742
768
|
*/
|
|
743
|
-
declare class
|
|
769
|
+
declare class LlmExecutorWithFunctions<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState = BaseState> extends LlmExecutor<Llm, Prompt, LlmFunctionParser<Parser>, State> {
|
|
744
770
|
constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
|
|
745
|
-
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options:
|
|
771
|
+
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options: LlmExecutorWithFunctionsOptions<T>): Promise<OutputResultContent[] | ParserOutput<Parser>>;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* @deprecated Use `LlmExecutorWithFunctions` instead.
|
|
775
|
+
*/
|
|
776
|
+
declare class LlmExecutorOpenAiFunctions<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState = BaseState> extends LlmExecutor<Llm, Prompt, LlmNativeFunctionParser<Parser>, State> {
|
|
777
|
+
constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
|
|
778
|
+
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options: LlmExecutorWithFunctionsOptions<T>): Promise<ParserOutput<Parser> | {
|
|
779
|
+
name: string;
|
|
780
|
+
arguments: any;
|
|
781
|
+
}>;
|
|
746
782
|
}
|
|
747
783
|
|
|
748
784
|
/**
|
|
@@ -763,6 +799,7 @@ declare function createCoreExecutor<I extends PlainObject, O>(handler: (input: I
|
|
|
763
799
|
* @returns - A new LlmExecutor instance.
|
|
764
800
|
*/
|
|
765
801
|
declare function createLlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<any>, Parser extends BaseParser, State extends BaseState>(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>): LlmExecutor<Llm, Prompt, Parser, State>;
|
|
802
|
+
declare function createLlmFunctionExecutor<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState>(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>): LlmExecutorWithFunctions<Llm, Prompt, Parser, State>;
|
|
766
803
|
|
|
767
804
|
declare const hookOnComplete = "onComplete";
|
|
768
805
|
declare const hookOnError = "onError";
|
|
@@ -829,6 +866,20 @@ interface CallableExecutorCore {
|
|
|
829
866
|
description: string;
|
|
830
867
|
parameters?: Record<string, any>;
|
|
831
868
|
}
|
|
869
|
+
interface LlmExecutorExecuteOptions {
|
|
870
|
+
functions?: CallableExecutorCore[];
|
|
871
|
+
functionCall?: any;
|
|
872
|
+
jsonSchema?: Record<string, any>;
|
|
873
|
+
}
|
|
874
|
+
type GenericFunctionCall = "auto" | "none" | "any" | {
|
|
875
|
+
name: string;
|
|
876
|
+
};
|
|
877
|
+
interface LlmExecutorWithFunctionsOptions<T extends GenericFunctionCall = "auto"> extends LlmExecutorExecuteOptions {
|
|
878
|
+
functions?: CallableExecutorCore[];
|
|
879
|
+
functionCall?: T;
|
|
880
|
+
functionCallStrictInput?: boolean;
|
|
881
|
+
jsonSchema?: Record<string, any>;
|
|
882
|
+
}
|
|
832
883
|
|
|
833
884
|
type CreateParserType = "json" | "string" | "boolean" | "number" | "stringExtract" | "listToArray" | "listToJson" | "listToKeyValue" | "replaceStringTemplate" | "markdownCodeBlocks" | "markdownCodeBlock";
|
|
834
885
|
interface BaseParserOptions {
|
|
@@ -838,6 +889,9 @@ interface BaseParserOptionsWithSchema<S extends JSONSchema | undefined = undefin
|
|
|
838
889
|
validateSchema?: boolean;
|
|
839
890
|
}
|
|
840
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Internal Formats
|
|
894
|
+
*/
|
|
841
895
|
interface OutputResultsBase {
|
|
842
896
|
type: "text" | "function_use";
|
|
843
897
|
text?: string;
|
|
@@ -850,6 +904,7 @@ interface OutputResultsFunction extends OutputResultsBase {
|
|
|
850
904
|
type: "function_use";
|
|
851
905
|
name: string;
|
|
852
906
|
input: Record<string, any>;
|
|
907
|
+
functionId: string;
|
|
853
908
|
}
|
|
854
909
|
type OutputResultContent = OutputResultsText | OutputResultsFunction;
|
|
855
910
|
interface OutputResult {
|
|
@@ -1231,6 +1286,35 @@ declare namespace index {
|
|
|
1231
1286
|
export { index_assert as assert, index_asyncCallWithTimeout as asyncCallWithTimeout, index_defineSchema as defineSchema, index_filterObjectOnSchema as filterObjectOnSchema, index_guessProviderFromModel as guessProviderFromModel, index_importHelpers as importHelpers, index_importPartials as importPartials, index_isObjectStringified as isObjectStringified, index_maybeParseJSON as maybeParseJSON, index_maybeStringifyJSON as maybeStringifyJSON, index_registerHelpers as registerHelpers, index_registerPartials as registerPartials, index_replaceTemplateString as replaceTemplateString, index_replaceTemplateStringAsync as replaceTemplateStringAsync };
|
|
1232
1287
|
}
|
|
1233
1288
|
|
|
1289
|
+
declare function isOutputResult(obj: any): obj is OutputResult;
|
|
1290
|
+
declare function isOutputResultContentText(obj: any): obj is OutputResultsText;
|
|
1291
|
+
/**
|
|
1292
|
+
* Does a llm response have a tool/function call?
|
|
1293
|
+
*/
|
|
1294
|
+
declare function isFunctionCall(result: any): result is OutputResultsFunction;
|
|
1295
|
+
declare function isToolCall(result: any): result is OutputResultsFunction;
|
|
1296
|
+
/**
|
|
1297
|
+
* Is it a tool/function Call
|
|
1298
|
+
*/
|
|
1299
|
+
declare function hasFunctionCall(results: any): boolean;
|
|
1300
|
+
declare function hasToolCall(results: any): boolean;
|
|
1301
|
+
declare function isUserMessage(message: IChatMessage): message is IChatUserMessage;
|
|
1302
|
+
declare function isAssistantMessage(message: IChatMessage): message is IChatAssistantMessage;
|
|
1303
|
+
declare function isSystemMessage(message: IChatMessage): message is IChatSystemMessage;
|
|
1304
|
+
|
|
1305
|
+
declare const guards_hasFunctionCall: typeof hasFunctionCall;
|
|
1306
|
+
declare const guards_hasToolCall: typeof hasToolCall;
|
|
1307
|
+
declare const guards_isAssistantMessage: typeof isAssistantMessage;
|
|
1308
|
+
declare const guards_isFunctionCall: typeof isFunctionCall;
|
|
1309
|
+
declare const guards_isOutputResult: typeof isOutputResult;
|
|
1310
|
+
declare const guards_isOutputResultContentText: typeof isOutputResultContentText;
|
|
1311
|
+
declare const guards_isSystemMessage: typeof isSystemMessage;
|
|
1312
|
+
declare const guards_isToolCall: typeof isToolCall;
|
|
1313
|
+
declare const guards_isUserMessage: typeof isUserMessage;
|
|
1314
|
+
declare namespace guards {
|
|
1315
|
+
export { guards_hasFunctionCall as hasFunctionCall, guards_hasToolCall as hasToolCall, guards_isAssistantMessage as isAssistantMessage, guards_isFunctionCall as isFunctionCall, guards_isOutputResult as isOutputResult, guards_isOutputResultContentText as isOutputResultContentText, guards_isSystemMessage as isSystemMessage, guards_isToolCall as isToolCall, guards_isUserMessage as isUserMessage };
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1234
1318
|
declare const configs: {
|
|
1235
1319
|
"deepseek.chat.v1": Config<keyof AllLlm>;
|
|
1236
1320
|
"deepseek.chat": Config<keyof AllLlm>;
|
|
@@ -1260,11 +1344,7 @@ declare const configs: {
|
|
|
1260
1344
|
};
|
|
1261
1345
|
|
|
1262
1346
|
declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): {
|
|
1263
|
-
call: (messages: string | IChatMessages, options?:
|
|
1264
|
-
getResultContent: (index?: number) => OutputResultContent[];
|
|
1265
|
-
getResultText: () => string;
|
|
1266
|
-
getResult: () => OutputResult;
|
|
1267
|
-
}>;
|
|
1347
|
+
call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions) => Promise<BaseLlCall>;
|
|
1268
1348
|
getTraceId: () => string | null;
|
|
1269
1349
|
withTraceId: (id: string) => void;
|
|
1270
1350
|
getMetadata: () => {
|
|
@@ -1280,7 +1360,7 @@ declare function useLlm<T extends keyof typeof configs>(provider: T, options?: A
|
|
|
1280
1360
|
};
|
|
1281
1361
|
|
|
1282
1362
|
declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, options: AllEmbedding[T]["input"]): {
|
|
1283
|
-
call: (messages: string | string[], options?:
|
|
1363
|
+
call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions) => Promise<{
|
|
1284
1364
|
getEmbedding: (index?: number) => number[];
|
|
1285
1365
|
getResult: () => EmbeddingOutputResult;
|
|
1286
1366
|
}>;
|
|
@@ -1298,4 +1378,4 @@ declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, op
|
|
|
1298
1378
|
};
|
|
1299
1379
|
};
|
|
1300
1380
|
|
|
1301
|
-
export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ExecutorContext, type IChatMessages, LlmExecutorOpenAiFunctions, type LlmProvider, type LlmProviderKey, type OpenAIModelName, OpenAiFunctionParser, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createParser, createPrompt, createState, createStateItem, defineSchema, registerHelpers, registerPartials, useExecutors, useLlm, index as utils };
|
|
1381
|
+
export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ExecutorContext, type IChatMessages, LlmExecutorOpenAiFunctions, LlmExecutorWithFunctions, LlmNativeFunctionParser, type LlmProvider, type LlmProviderKey, type OpenAIModelName, OpenAiFunctionParser, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createLlmFunctionExecutor, createParser, createPrompt, createState, createStateItem, defineSchema, guards, registerHelpers, registerPartials, useExecutors, useLlm, index as utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,21 +31,23 @@ interface IChatUserMessage extends IChatMessageBase {
|
|
|
31
31
|
name?: string;
|
|
32
32
|
}
|
|
33
33
|
interface IChatFunctionMessage extends IChatMessageBase {
|
|
34
|
+
id?: string;
|
|
34
35
|
role: Extract<IChatMessageRole, "function">;
|
|
35
36
|
content: string;
|
|
36
37
|
name: string;
|
|
37
38
|
}
|
|
38
39
|
interface IChatAssistantMessage extends IChatMessageBase {
|
|
39
|
-
role: Extract<IChatMessageRole, "assistant">;
|
|
40
|
+
role: Extract<IChatMessageRole, "assistant" | "model">;
|
|
40
41
|
content: string;
|
|
41
42
|
function_call?: undefined;
|
|
42
43
|
}
|
|
43
|
-
interface
|
|
44
|
-
role: Extract<IChatMessageRole, "
|
|
44
|
+
interface IChatFunctionCallMessage extends IChatMessageBase {
|
|
45
|
+
role: Extract<IChatMessageRole, "function_call">;
|
|
45
46
|
content: null;
|
|
46
|
-
function_call
|
|
47
|
+
function_call: {
|
|
47
48
|
name: string;
|
|
48
49
|
arguments: string;
|
|
50
|
+
id?: string;
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
interface IChatSystemMessage extends IChatMessageBase {
|
|
@@ -57,29 +59,16 @@ interface IChatMessagesPlaceholder {
|
|
|
57
59
|
content: string;
|
|
58
60
|
}
|
|
59
61
|
type IPromptMessages = (IChatSystemMessage | IChatMessagesPlaceholder)[];
|
|
60
|
-
type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage |
|
|
61
|
-
type IChatMessage = IChatUserMessage | IChatAssistantMessage |
|
|
62
|
+
type IPromptChatMessages = (IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatMessagesPlaceholder | IChatFunctionMessage)[];
|
|
63
|
+
type IChatMessage = IChatUserMessage | IChatAssistantMessage | IChatFunctionCallMessage | IChatSystemMessage | IChatFunctionMessage;
|
|
62
64
|
type IChatMessages = IChatMessage[];
|
|
63
65
|
|
|
64
66
|
type OpenAIChatModelName = "gpt-3.5-turbo" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-16k" | "gpt-4-0613" | "gpt-4" | "gpt-4o" | "gpt-4o-mini" | "gpt-4-0613" | "gpt-4-32k-0613" | `gpt-4${string}` | `gpt-3.5-turbo-${string}`;
|
|
65
67
|
type OpenAIConversationModelName = "davinci" | "text-curie-001" | "text-babbage-001" | "text-ada-001";
|
|
66
68
|
type OpenAIEmbeddingModelName = "text-embedding-ada-002";
|
|
67
69
|
type OpenAIModelName = OpenAIChatModelName | OpenAIConversationModelName | OpenAIEmbeddingModelName;
|
|
68
|
-
interface LlmExecutorExecuteOptions {
|
|
69
|
-
functions?: CallableExecutorCore[];
|
|
70
|
-
functionCall?: any;
|
|
71
|
-
jsonSchema?: Record<string, any>;
|
|
72
|
-
}
|
|
73
|
-
type GenericFunctionCall = "auto" | "none" | "any" | {
|
|
74
|
-
name: string;
|
|
75
|
-
};
|
|
76
|
-
interface OpenAiLlmExecutorOptions<T extends GenericFunctionCall = "auto"> extends LlmExecutorExecuteOptions {
|
|
77
|
-
functions?: CallableExecutorCore[];
|
|
78
|
-
functionCall?: T;
|
|
79
|
-
functionCallStrictInput?: boolean;
|
|
80
|
-
jsonSchema?: Record<string, any>;
|
|
81
|
-
}
|
|
82
70
|
|
|
71
|
+
type ParserInput = string | OutputResult;
|
|
83
72
|
/**
|
|
84
73
|
* BaseParser is an abstract class for parsing text and enforcing JSON schema on the parsed data.
|
|
85
74
|
*/
|
|
@@ -100,7 +89,7 @@ declare abstract class BaseParser<T = any> {
|
|
|
100
89
|
* @param [attributes] - Optional attributes to use during parsing.
|
|
101
90
|
* @returns The parsed data.
|
|
102
91
|
*/
|
|
103
|
-
abstract parse(text:
|
|
92
|
+
abstract parse(text: ParserInput, attributes?: Record<string, any>): T;
|
|
104
93
|
}
|
|
105
94
|
declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = undefined, T = S extends JSONSchema ? FromSchema<S> : Record<string, any>> extends BaseParser<T> {
|
|
106
95
|
schema: S;
|
|
@@ -113,26 +102,11 @@ declare abstract class BaseParserWithJson<S extends JSONSchema | undefined = und
|
|
|
113
102
|
constructor(name: string, options: BaseParserOptionsWithSchema<S>);
|
|
114
103
|
}
|
|
115
104
|
|
|
116
|
-
interface OpenAiFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
117
|
-
parser: T;
|
|
118
|
-
}
|
|
119
|
-
declare class OpenAiFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
|
|
120
|
-
name: any;
|
|
121
|
-
arguments: any;
|
|
122
|
-
}> {
|
|
123
|
-
parser: T;
|
|
124
|
-
constructor(options: OpenAiFunctionParserOptions<T>);
|
|
125
|
-
parse(text: OutputResultContent[], _options?: Record<string, any>): ParserOutput<T> | {
|
|
126
|
-
name: string;
|
|
127
|
-
arguments: any;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
105
|
interface StringParserOptions extends BaseParserOptions {
|
|
132
106
|
}
|
|
133
107
|
declare class StringParser extends BaseParser<string> {
|
|
134
108
|
constructor(options?: StringParserOptions);
|
|
135
|
-
parse(text: string |
|
|
109
|
+
parse(text: string | OutputResult, _options?: Record<string, any>): string;
|
|
136
110
|
}
|
|
137
111
|
|
|
138
112
|
interface BooleanParserOptions extends BaseParserOptions {
|
|
@@ -330,6 +304,36 @@ declare function createParser<T extends Extract<CreateParserType, "json">, S ext
|
|
|
330
304
|
declare function createParser<T extends CreateParserType, S extends JSONSchema | undefined = undefined>(type: T, options?: BaseParserOptionsWithSchema<S> | BaseParserOptions): JsonParser<S> | ListToJsonParser<S> | StringParser | NumberParser | BooleanParser | ListToArrayParser | ListToKeyValueParser | ReplaceStringTemplateParser | MarkdownCodeBlockParser | MarkdownCodeBlocksParser | StringExtractParser;
|
|
331
305
|
declare function createCustomParser<O>(name: string, parserFn: (text: string, inputValues: ExecutorContext<any, any>) => O): CustomParser<ReturnType<typeof parserFn>>;
|
|
332
306
|
|
|
307
|
+
declare class LlmFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | OutputResultContent[]> {
|
|
308
|
+
parser: T;
|
|
309
|
+
constructor(options: LlmNativeFunctionParserOptions<T>);
|
|
310
|
+
parse(text: OutputResult, _options?: Record<string, any>): OutputResultContent[] | ParserOutput<T>;
|
|
311
|
+
}
|
|
312
|
+
interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
313
|
+
parser: T;
|
|
314
|
+
}
|
|
315
|
+
interface LlmNativeFunctionParserOptions<T extends BaseParser<any>> extends BaseParserOptions {
|
|
316
|
+
parser: T;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @deprecated Use `LlmFunctionParser` instead.
|
|
320
|
+
*/
|
|
321
|
+
declare class LlmNativeFunctionParser<T extends BaseParser<any>> extends BaseParser<ParserOutput<T> | {
|
|
322
|
+
name: any;
|
|
323
|
+
arguments: any;
|
|
324
|
+
}> {
|
|
325
|
+
parser: T;
|
|
326
|
+
constructor(options: LlmNativeFunctionParserOptions<T>);
|
|
327
|
+
parse(text: OutputResult, _options?: Record<string, any>): ParserOutput<T> | {
|
|
328
|
+
name: string;
|
|
329
|
+
arguments: any;
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* @deprecated Use `LlmExecutorWithFunctions` instead.
|
|
334
|
+
*/
|
|
335
|
+
declare const OpenAiFunctionParser: typeof LlmNativeFunctionParser;
|
|
336
|
+
|
|
333
337
|
declare function replaceTemplateString(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): string;
|
|
334
338
|
|
|
335
339
|
declare function replaceTemplateStringAsync(templateString?: string, substitutions?: Record<string, any>, configuration?: PromptTemplateOptions): Promise<string>;
|
|
@@ -445,7 +449,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
445
449
|
* @param name (optional) The name of the user. Only accepted if role is `user`.
|
|
446
450
|
* @return instance of ChatPrompt.
|
|
447
451
|
*/
|
|
448
|
-
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant">, name?: undefined): ChatPrompt<I>;
|
|
452
|
+
addToPrompt(content: string, role: Extract<IChatMessageRole, "assistant" | "model">, name?: undefined): ChatPrompt<I>;
|
|
449
453
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "system">, name?: undefined): ChatPrompt<I>;
|
|
450
454
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "user">, name?: string): ChatPrompt<I>;
|
|
451
455
|
addToPrompt(content: string, role: Extract<IChatMessageRole, "function">, name: string): ChatPrompt<I>;
|
|
@@ -468,7 +472,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
468
472
|
* @param content The message content.
|
|
469
473
|
* @return ChatPrompt so it can be chained.
|
|
470
474
|
*/
|
|
471
|
-
addFunctionMessage(content: string, name: string): ChatPrompt<I>;
|
|
475
|
+
addFunctionMessage(content: string, name: string, id?: string): ChatPrompt<I>;
|
|
472
476
|
/**
|
|
473
477
|
* addFunctionCallMessage Helper to add an assistant message to the prompt.
|
|
474
478
|
* @param content The message content.
|
|
@@ -477,6 +481,7 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
477
481
|
addFunctionCallMessage(function_call?: {
|
|
478
482
|
name: string;
|
|
479
483
|
arguments: string;
|
|
484
|
+
id?: string;
|
|
480
485
|
}): this;
|
|
481
486
|
/**
|
|
482
487
|
* addFromHistory Adds multiple messages at one time.
|
|
@@ -667,13 +672,27 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
667
672
|
name: string;
|
|
668
673
|
constructor(name: string);
|
|
669
674
|
setUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
|
|
670
|
-
setAssistantMessage(content: string): this;
|
|
675
|
+
setAssistantMessage(content: string | OutputResultsText): this;
|
|
671
676
|
setSystemMessage(content: string): this;
|
|
672
|
-
|
|
677
|
+
setToolMessage(content: string, name: string, id?: string): void;
|
|
678
|
+
setFunctionMessage(content: string, name: string, id?: string): this;
|
|
679
|
+
/**
|
|
680
|
+
* Set
|
|
681
|
+
*/
|
|
682
|
+
setToolCallMessage(input: {
|
|
683
|
+
name: string;
|
|
684
|
+
arguments: string;
|
|
685
|
+
id?: string;
|
|
686
|
+
}): void;
|
|
673
687
|
setFunctionCallMessage(input: {
|
|
688
|
+
name: string;
|
|
689
|
+
arguments: string;
|
|
690
|
+
id?: string;
|
|
691
|
+
} | {
|
|
674
692
|
function_call: {
|
|
675
693
|
name: string;
|
|
676
694
|
arguments: string;
|
|
695
|
+
id?: string;
|
|
677
696
|
};
|
|
678
697
|
}): this;
|
|
679
698
|
setMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
@@ -684,6 +703,13 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
684
703
|
name: string;
|
|
685
704
|
value: IChatMessage[];
|
|
686
705
|
};
|
|
706
|
+
/**
|
|
707
|
+
* Add LLM output to dialogue history in the order it was returned
|
|
708
|
+
*
|
|
709
|
+
* @param output - The LLM output result from llm.call()
|
|
710
|
+
* @returns this for chaining
|
|
711
|
+
*/
|
|
712
|
+
addFromOutput(output: OutputResult | BaseLlCall): this;
|
|
687
713
|
}
|
|
688
714
|
|
|
689
715
|
declare abstract class BaseState {
|
|
@@ -740,9 +766,19 @@ declare class LlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<Re
|
|
|
740
766
|
/**
|
|
741
767
|
* Core Executor With LLM
|
|
742
768
|
*/
|
|
743
|
-
declare class
|
|
769
|
+
declare class LlmExecutorWithFunctions<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState = BaseState> extends LlmExecutor<Llm, Prompt, LlmFunctionParser<Parser>, State> {
|
|
744
770
|
constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
|
|
745
|
-
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options:
|
|
771
|
+
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options: LlmExecutorWithFunctionsOptions<T>): Promise<OutputResultContent[] | ParserOutput<Parser>>;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* @deprecated Use `LlmExecutorWithFunctions` instead.
|
|
775
|
+
*/
|
|
776
|
+
declare class LlmExecutorOpenAiFunctions<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState = BaseState> extends LlmExecutor<Llm, Prompt, LlmNativeFunctionParser<Parser>, State> {
|
|
777
|
+
constructor(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>);
|
|
778
|
+
execute<T extends GenericFunctionCall>(_input: PromptInput<Prompt>, _options: LlmExecutorWithFunctionsOptions<T>): Promise<ParserOutput<Parser> | {
|
|
779
|
+
name: string;
|
|
780
|
+
arguments: any;
|
|
781
|
+
}>;
|
|
746
782
|
}
|
|
747
783
|
|
|
748
784
|
/**
|
|
@@ -763,6 +799,7 @@ declare function createCoreExecutor<I extends PlainObject, O>(handler: (input: I
|
|
|
763
799
|
* @returns - A new LlmExecutor instance.
|
|
764
800
|
*/
|
|
765
801
|
declare function createLlmExecutor<Llm extends BaseLlm<any>, Prompt extends BasePrompt<any>, Parser extends BaseParser, State extends BaseState>(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>): LlmExecutor<Llm, Prompt, Parser, State>;
|
|
802
|
+
declare function createLlmFunctionExecutor<Llm extends BaseLlm, Prompt extends BasePrompt<Record<string, any>>, Parser extends BaseParser, State extends BaseState>(llmConfiguration: ExecutorWithLlmOptions<Llm, Prompt, Parser, State>, options?: CoreExecutorExecuteOptions<LlmExecutorHooks>): LlmExecutorWithFunctions<Llm, Prompt, Parser, State>;
|
|
766
803
|
|
|
767
804
|
declare const hookOnComplete = "onComplete";
|
|
768
805
|
declare const hookOnError = "onError";
|
|
@@ -829,6 +866,20 @@ interface CallableExecutorCore {
|
|
|
829
866
|
description: string;
|
|
830
867
|
parameters?: Record<string, any>;
|
|
831
868
|
}
|
|
869
|
+
interface LlmExecutorExecuteOptions {
|
|
870
|
+
functions?: CallableExecutorCore[];
|
|
871
|
+
functionCall?: any;
|
|
872
|
+
jsonSchema?: Record<string, any>;
|
|
873
|
+
}
|
|
874
|
+
type GenericFunctionCall = "auto" | "none" | "any" | {
|
|
875
|
+
name: string;
|
|
876
|
+
};
|
|
877
|
+
interface LlmExecutorWithFunctionsOptions<T extends GenericFunctionCall = "auto"> extends LlmExecutorExecuteOptions {
|
|
878
|
+
functions?: CallableExecutorCore[];
|
|
879
|
+
functionCall?: T;
|
|
880
|
+
functionCallStrictInput?: boolean;
|
|
881
|
+
jsonSchema?: Record<string, any>;
|
|
882
|
+
}
|
|
832
883
|
|
|
833
884
|
type CreateParserType = "json" | "string" | "boolean" | "number" | "stringExtract" | "listToArray" | "listToJson" | "listToKeyValue" | "replaceStringTemplate" | "markdownCodeBlocks" | "markdownCodeBlock";
|
|
834
885
|
interface BaseParserOptions {
|
|
@@ -838,6 +889,9 @@ interface BaseParserOptionsWithSchema<S extends JSONSchema | undefined = undefin
|
|
|
838
889
|
validateSchema?: boolean;
|
|
839
890
|
}
|
|
840
891
|
|
|
892
|
+
/**
|
|
893
|
+
* Internal Formats
|
|
894
|
+
*/
|
|
841
895
|
interface OutputResultsBase {
|
|
842
896
|
type: "text" | "function_use";
|
|
843
897
|
text?: string;
|
|
@@ -850,6 +904,7 @@ interface OutputResultsFunction extends OutputResultsBase {
|
|
|
850
904
|
type: "function_use";
|
|
851
905
|
name: string;
|
|
852
906
|
input: Record<string, any>;
|
|
907
|
+
functionId: string;
|
|
853
908
|
}
|
|
854
909
|
type OutputResultContent = OutputResultsText | OutputResultsFunction;
|
|
855
910
|
interface OutputResult {
|
|
@@ -1231,6 +1286,35 @@ declare namespace index {
|
|
|
1231
1286
|
export { index_assert as assert, index_asyncCallWithTimeout as asyncCallWithTimeout, index_defineSchema as defineSchema, index_filterObjectOnSchema as filterObjectOnSchema, index_guessProviderFromModel as guessProviderFromModel, index_importHelpers as importHelpers, index_importPartials as importPartials, index_isObjectStringified as isObjectStringified, index_maybeParseJSON as maybeParseJSON, index_maybeStringifyJSON as maybeStringifyJSON, index_registerHelpers as registerHelpers, index_registerPartials as registerPartials, index_replaceTemplateString as replaceTemplateString, index_replaceTemplateStringAsync as replaceTemplateStringAsync };
|
|
1232
1287
|
}
|
|
1233
1288
|
|
|
1289
|
+
declare function isOutputResult(obj: any): obj is OutputResult;
|
|
1290
|
+
declare function isOutputResultContentText(obj: any): obj is OutputResultsText;
|
|
1291
|
+
/**
|
|
1292
|
+
* Does a llm response have a tool/function call?
|
|
1293
|
+
*/
|
|
1294
|
+
declare function isFunctionCall(result: any): result is OutputResultsFunction;
|
|
1295
|
+
declare function isToolCall(result: any): result is OutputResultsFunction;
|
|
1296
|
+
/**
|
|
1297
|
+
* Is it a tool/function Call
|
|
1298
|
+
*/
|
|
1299
|
+
declare function hasFunctionCall(results: any): boolean;
|
|
1300
|
+
declare function hasToolCall(results: any): boolean;
|
|
1301
|
+
declare function isUserMessage(message: IChatMessage): message is IChatUserMessage;
|
|
1302
|
+
declare function isAssistantMessage(message: IChatMessage): message is IChatAssistantMessage;
|
|
1303
|
+
declare function isSystemMessage(message: IChatMessage): message is IChatSystemMessage;
|
|
1304
|
+
|
|
1305
|
+
declare const guards_hasFunctionCall: typeof hasFunctionCall;
|
|
1306
|
+
declare const guards_hasToolCall: typeof hasToolCall;
|
|
1307
|
+
declare const guards_isAssistantMessage: typeof isAssistantMessage;
|
|
1308
|
+
declare const guards_isFunctionCall: typeof isFunctionCall;
|
|
1309
|
+
declare const guards_isOutputResult: typeof isOutputResult;
|
|
1310
|
+
declare const guards_isOutputResultContentText: typeof isOutputResultContentText;
|
|
1311
|
+
declare const guards_isSystemMessage: typeof isSystemMessage;
|
|
1312
|
+
declare const guards_isToolCall: typeof isToolCall;
|
|
1313
|
+
declare const guards_isUserMessage: typeof isUserMessage;
|
|
1314
|
+
declare namespace guards {
|
|
1315
|
+
export { guards_hasFunctionCall as hasFunctionCall, guards_hasToolCall as hasToolCall, guards_isAssistantMessage as isAssistantMessage, guards_isFunctionCall as isFunctionCall, guards_isOutputResult as isOutputResult, guards_isOutputResultContentText as isOutputResultContentText, guards_isSystemMessage as isSystemMessage, guards_isToolCall as isToolCall, guards_isUserMessage as isUserMessage };
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1234
1318
|
declare const configs: {
|
|
1235
1319
|
"deepseek.chat.v1": Config<keyof AllLlm>;
|
|
1236
1320
|
"deepseek.chat": Config<keyof AllLlm>;
|
|
@@ -1260,11 +1344,7 @@ declare const configs: {
|
|
|
1260
1344
|
};
|
|
1261
1345
|
|
|
1262
1346
|
declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): {
|
|
1263
|
-
call: (messages: string | IChatMessages, options?:
|
|
1264
|
-
getResultContent: (index?: number) => OutputResultContent[];
|
|
1265
|
-
getResultText: () => string;
|
|
1266
|
-
getResult: () => OutputResult;
|
|
1267
|
-
}>;
|
|
1347
|
+
call: (messages: string | IChatMessages, options?: LlmExecutorWithFunctionsOptions) => Promise<BaseLlCall>;
|
|
1268
1348
|
getTraceId: () => string | null;
|
|
1269
1349
|
withTraceId: (id: string) => void;
|
|
1270
1350
|
getMetadata: () => {
|
|
@@ -1280,7 +1360,7 @@ declare function useLlm<T extends keyof typeof configs>(provider: T, options?: A
|
|
|
1280
1360
|
};
|
|
1281
1361
|
|
|
1282
1362
|
declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, options: AllEmbedding[T]["input"]): {
|
|
1283
|
-
call: (messages: string | string[], options?:
|
|
1363
|
+
call: (messages: string | string[], options?: LlmExecutorWithFunctionsOptions) => Promise<{
|
|
1284
1364
|
getEmbedding: (index?: number) => number[];
|
|
1285
1365
|
getResult: () => EmbeddingOutputResult;
|
|
1286
1366
|
}>;
|
|
@@ -1298,4 +1378,4 @@ declare function createEmbedding<T extends EmbeddingProviderKey>(provider: T, op
|
|
|
1298
1378
|
};
|
|
1299
1379
|
};
|
|
1300
1380
|
|
|
1301
|
-
export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ExecutorContext, type IChatMessages, LlmExecutorOpenAiFunctions, type LlmProvider, type LlmProviderKey, type OpenAIModelName, OpenAiFunctionParser, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createParser, createPrompt, createState, createStateItem, defineSchema, registerHelpers, registerPartials, useExecutors, useLlm, index as utils };
|
|
1381
|
+
export { BaseExecutor, type BaseLlm, BaseParser, BasePrompt, BaseStateItem, ChatPrompt, CustomParser, DefaultState, DefaultStateItem, type EmbeddingProviderKey, type ExecutorContext, type IChatMessages, LlmExecutorOpenAiFunctions, LlmExecutorWithFunctions, LlmNativeFunctionParser, type LlmProvider, type LlmProviderKey, type OpenAIModelName, OpenAiFunctionParser, TextPrompt, type UseLlmKey, createCallableExecutor, createChatPrompt, createCoreExecutor, createCustomParser, createDialogue, createEmbedding, createLlmExecutor, createLlmFunctionExecutor, createParser, createPrompt, createState, createStateItem, defineSchema, guards, registerHelpers, registerPartials, useExecutors, useLlm, index as utils };
|