llm-exe 2.3.5 → 2.3.7
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 +116 -37
- package/dist/index.d.ts +116 -37
- package/dist/index.js +229 -72
- package/dist/index.mjs +229 -72
- package/package.json +1 -1
- package/readme.md +25 -2
package/dist/index.d.mts
CHANGED
|
@@ -129,7 +129,8 @@ declare class JsonParser<S extends JSONSchema | undefined = undefined> extends B
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
declare class ListToJsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S> {
|
|
132
|
-
|
|
132
|
+
private keyTransform;
|
|
133
|
+
constructor(options?: ListToJsonParserOptions<S>);
|
|
133
134
|
parse(text: string): ParserOutput<BaseParserWithJson<S>>;
|
|
134
135
|
}
|
|
135
136
|
|
|
@@ -292,7 +293,7 @@ declare function createParser<T extends Extract<CreateParserType, "stringExtract
|
|
|
292
293
|
* @param options - The JSON schema.
|
|
293
294
|
* @returns An instance of ListToJsonParser.
|
|
294
295
|
*/
|
|
295
|
-
declare function createParser<T extends Extract<CreateParserType, "listToJson">, S extends JSONSchema | undefined = undefined>(type: T, options?:
|
|
296
|
+
declare function createParser<T extends Extract<CreateParserType, "listToJson">, S extends JSONSchema | undefined = undefined>(type: T, options?: ListToJsonParserOptions<S>): ListToJsonParser<S>;
|
|
296
297
|
/**
|
|
297
298
|
* Creates a parser based on the given type and schema.
|
|
298
299
|
* @template S - JSON schema type.
|
|
@@ -402,8 +403,8 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
|
|
|
402
403
|
_input: any;
|
|
403
404
|
};
|
|
404
405
|
/**
|
|
405
|
-
*
|
|
406
|
-
* @return {boolean} Returns false if the
|
|
406
|
+
* Validates the prompt structure.
|
|
407
|
+
* @return {boolean} Returns false if the prompt has no messages defined.
|
|
407
408
|
*/
|
|
408
409
|
validate(): boolean;
|
|
409
410
|
}
|
|
@@ -521,12 +522,6 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
521
522
|
* @return formatted prompt.
|
|
522
523
|
*/
|
|
523
524
|
formatAsync(values: I): Promise<IChatMessages>;
|
|
524
|
-
/**
|
|
525
|
-
* validate Ensures there are not unresolved tokens in prompt.
|
|
526
|
-
* @TODO Make this work!
|
|
527
|
-
* @return Returns false if the template is not valid.
|
|
528
|
-
*/
|
|
529
|
-
validate(): boolean;
|
|
530
525
|
}
|
|
531
526
|
|
|
532
527
|
type TextPromptType = "text";
|
|
@@ -712,6 +707,33 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
712
707
|
};
|
|
713
708
|
}): this;
|
|
714
709
|
setMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
710
|
+
/**
|
|
711
|
+
* Aliases using `add*` naming to match ChatPrompt's API.
|
|
712
|
+
* These delegate to the corresponding `set*` methods.
|
|
713
|
+
*/
|
|
714
|
+
addUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
|
|
715
|
+
addAssistantMessage(content: string | OutputResultsText): this;
|
|
716
|
+
addSystemMessage(content: string): this;
|
|
717
|
+
addToolMessage(content: string, name: string, id?: string): this;
|
|
718
|
+
addToolCallMessage(input: {
|
|
719
|
+
name: string;
|
|
720
|
+
arguments: string;
|
|
721
|
+
id?: string;
|
|
722
|
+
}): this;
|
|
723
|
+
addFunctionMessage(content: string, name: string, id?: string): this;
|
|
724
|
+
addFunctionCallMessage(input: {
|
|
725
|
+
name: string;
|
|
726
|
+
arguments: string;
|
|
727
|
+
id?: string;
|
|
728
|
+
} | {
|
|
729
|
+
function_call: {
|
|
730
|
+
name: string;
|
|
731
|
+
arguments: string;
|
|
732
|
+
id?: string;
|
|
733
|
+
};
|
|
734
|
+
}): this;
|
|
735
|
+
addMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
736
|
+
addHistory(messages: IChatMessages): this;
|
|
715
737
|
setHistory(messages: IChatMessages): this;
|
|
716
738
|
getHistory(): IChatMessages;
|
|
717
739
|
serialize(): {
|
|
@@ -904,6 +926,9 @@ interface BaseParserOptionsWithSchema<S extends JSONSchema | undefined = undefin
|
|
|
904
926
|
schema?: S;
|
|
905
927
|
validateSchema?: boolean;
|
|
906
928
|
}
|
|
929
|
+
interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends BaseParserOptionsWithSchema<S> {
|
|
930
|
+
keyTransform?: "camelCase" | "preserve";
|
|
931
|
+
}
|
|
907
932
|
|
|
908
933
|
/**
|
|
909
934
|
* Internal Formats
|
|
@@ -971,6 +996,10 @@ interface AmazonEmbeddingOptions extends GenericEmbeddingOptions {
|
|
|
971
996
|
awsSecretKey?: string;
|
|
972
997
|
awsAccessKey?: string;
|
|
973
998
|
}
|
|
999
|
+
interface CohereBedrockEmbeddingOptions extends AmazonEmbeddingOptions {
|
|
1000
|
+
inputType?: "search_document" | "search_query" | "classification" | "clustering";
|
|
1001
|
+
truncate?: "NONE" | "START" | "END" | "LEFT" | "RIGHT";
|
|
1002
|
+
}
|
|
974
1003
|
interface GenericLLm extends BaseLlmOptions {
|
|
975
1004
|
model?: string;
|
|
976
1005
|
system?: string;
|
|
@@ -994,6 +1023,14 @@ interface OpenAiRequest extends GenericLLm {
|
|
|
994
1023
|
openAiApiKey?: string;
|
|
995
1024
|
useJson?: boolean;
|
|
996
1025
|
}
|
|
1026
|
+
interface XAiRequest extends GenericLLm {
|
|
1027
|
+
model: string;
|
|
1028
|
+
frequencyPenalty?: number;
|
|
1029
|
+
logitBias?: Record<string, any> | null;
|
|
1030
|
+
responseFormat?: Record<string, any>;
|
|
1031
|
+
xAiApiKey?: string;
|
|
1032
|
+
useJson?: boolean;
|
|
1033
|
+
}
|
|
997
1034
|
interface AmazonBedrockRequest extends GenericLLm {
|
|
998
1035
|
model: string;
|
|
999
1036
|
awsRegion?: string;
|
|
@@ -1026,6 +1063,9 @@ type AllEmbedding = {
|
|
|
1026
1063
|
"amazon.embedding.v1": {
|
|
1027
1064
|
input: AmazonEmbeddingOptions;
|
|
1028
1065
|
};
|
|
1066
|
+
"amazon:cohere.embedding.v1": {
|
|
1067
|
+
input: CohereBedrockEmbeddingOptions;
|
|
1068
|
+
};
|
|
1029
1069
|
};
|
|
1030
1070
|
type AllLlm = {
|
|
1031
1071
|
"openai.chat.v1": {
|
|
@@ -1044,7 +1084,7 @@ type AllLlm = {
|
|
|
1044
1084
|
input: AmazonBedrockRequest;
|
|
1045
1085
|
};
|
|
1046
1086
|
"xai.chat.v1": {
|
|
1047
|
-
input:
|
|
1087
|
+
input: XAiRequest;
|
|
1048
1088
|
};
|
|
1049
1089
|
"ollama.chat.v1": {
|
|
1050
1090
|
input: GenericLLm;
|
|
@@ -1078,11 +1118,8 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1078
1118
|
"openai.o3": {
|
|
1079
1119
|
input: Omit<OpenAiRequest, "model">;
|
|
1080
1120
|
};
|
|
1081
|
-
"openai.o4-mini": {
|
|
1082
|
-
input: Omit<OpenAiRequest, "model">;
|
|
1083
|
-
};
|
|
1084
1121
|
"openai.gpt-4": {
|
|
1085
|
-
input: OpenAiRequest
|
|
1122
|
+
input: Omit<OpenAiRequest, "model">;
|
|
1086
1123
|
};
|
|
1087
1124
|
"openai.gpt-4o": {
|
|
1088
1125
|
input: Omit<OpenAiRequest, "model">;
|
|
@@ -1090,12 +1127,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1090
1127
|
"openai.gpt-4o-mini": {
|
|
1091
1128
|
input: Omit<OpenAiRequest, "model">;
|
|
1092
1129
|
};
|
|
1130
|
+
"openai.o4-mini": {
|
|
1131
|
+
input: Omit<OpenAiRequest, "model">;
|
|
1132
|
+
};
|
|
1133
|
+
"anthropic.claude-opus-4-7": {
|
|
1134
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1135
|
+
};
|
|
1093
1136
|
"anthropic.claude-opus-4-6": {
|
|
1094
1137
|
input: Omit<AnthropicRequest, "model">;
|
|
1095
1138
|
};
|
|
1096
1139
|
"anthropic.claude-sonnet-4-6": {
|
|
1097
1140
|
input: Omit<AnthropicRequest, "model">;
|
|
1098
1141
|
};
|
|
1142
|
+
"anthropic.claude-haiku-4-5": {
|
|
1143
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1144
|
+
};
|
|
1145
|
+
"anthropic.claude-sonnet-4-5": {
|
|
1146
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1147
|
+
};
|
|
1148
|
+
"anthropic.claude-opus-4-1": {
|
|
1149
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1150
|
+
};
|
|
1099
1151
|
"anthropic.claude-sonnet-4-0": {
|
|
1100
1152
|
input: Omit<AnthropicRequest, "model">;
|
|
1101
1153
|
};
|
|
@@ -1120,44 +1172,41 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1120
1172
|
"anthropic.claude-3-opus": {
|
|
1121
1173
|
input: Omit<AnthropicRequest, "model">;
|
|
1122
1174
|
};
|
|
1123
|
-
"
|
|
1124
|
-
input: Omit<AnthropicRequest, "model">;
|
|
1125
|
-
};
|
|
1126
|
-
"google.gemini-2.5-pro-exp-03-25": {
|
|
1175
|
+
"google.gemini-2.5-flash": {
|
|
1127
1176
|
input: Omit<GeminiRequest, "model">;
|
|
1128
1177
|
};
|
|
1129
|
-
"google.gemini-2.
|
|
1178
|
+
"google.gemini-2.5-flash-lite": {
|
|
1130
1179
|
input: Omit<GeminiRequest, "model">;
|
|
1131
1180
|
};
|
|
1132
|
-
"google.gemini-2.
|
|
1181
|
+
"google.gemini-2.5-pro": {
|
|
1133
1182
|
input: Omit<GeminiRequest, "model">;
|
|
1134
1183
|
};
|
|
1135
|
-
"google.gemini-2.
|
|
1184
|
+
"google.gemini-2.0-flash": {
|
|
1136
1185
|
input: Omit<GeminiRequest, "model">;
|
|
1137
1186
|
};
|
|
1138
|
-
"google.gemini-2.
|
|
1187
|
+
"google.gemini-2.0-flash-lite": {
|
|
1139
1188
|
input: Omit<GeminiRequest, "model">;
|
|
1140
1189
|
};
|
|
1141
1190
|
"google.gemini-1.5-pro": {
|
|
1142
1191
|
input: Omit<GeminiRequest, "model">;
|
|
1143
1192
|
};
|
|
1144
|
-
"google.gemini-2.5-pro": {
|
|
1145
|
-
input: Omit<GeminiRequest, "model">;
|
|
1146
|
-
};
|
|
1147
1193
|
"xai.grok-2": {
|
|
1148
|
-
input:
|
|
1194
|
+
input: Omit<XAiRequest, "model">;
|
|
1149
1195
|
};
|
|
1150
1196
|
"xai.grok-3": {
|
|
1151
|
-
input:
|
|
1197
|
+
input: Omit<XAiRequest, "model">;
|
|
1152
1198
|
};
|
|
1153
1199
|
"xai.grok-3-mini": {
|
|
1154
|
-
input: Omit<
|
|
1200
|
+
input: Omit<XAiRequest, "model">;
|
|
1155
1201
|
};
|
|
1156
1202
|
"xai.grok-4": {
|
|
1157
|
-
input:
|
|
1203
|
+
input: Omit<XAiRequest, "model">;
|
|
1158
1204
|
};
|
|
1159
1205
|
"xai.grok-4-fast": {
|
|
1160
|
-
input: Omit<
|
|
1206
|
+
input: Omit<XAiRequest, "model">;
|
|
1207
|
+
};
|
|
1208
|
+
"xai.grok-4-1-fast": {
|
|
1209
|
+
input: Omit<XAiRequest, "model">;
|
|
1161
1210
|
};
|
|
1162
1211
|
"ollama.deepseek-r1": {
|
|
1163
1212
|
input: GenericLLm;
|
|
@@ -1174,9 +1223,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1174
1223
|
"ollama.qwq": {
|
|
1175
1224
|
input: GenericLLm;
|
|
1176
1225
|
};
|
|
1226
|
+
"ollama.gemma3": {
|
|
1227
|
+
input: GenericLLm;
|
|
1228
|
+
};
|
|
1229
|
+
"ollama.mistral": {
|
|
1230
|
+
input: GenericLLm;
|
|
1231
|
+
};
|
|
1232
|
+
"ollama.qwen2.5": {
|
|
1233
|
+
input: GenericLLm;
|
|
1234
|
+
};
|
|
1235
|
+
"ollama.qwen3": {
|
|
1236
|
+
input: GenericLLm;
|
|
1237
|
+
};
|
|
1177
1238
|
"deepseek.chat": {
|
|
1178
1239
|
input: DeepseekRequest;
|
|
1179
1240
|
};
|
|
1241
|
+
"deepseek.v4-flash": {
|
|
1242
|
+
input: Omit<DeepseekRequest, "model">;
|
|
1243
|
+
};
|
|
1244
|
+
"deepseek.v4-pro": {
|
|
1245
|
+
input: Omit<DeepseekRequest, "model">;
|
|
1246
|
+
};
|
|
1180
1247
|
};
|
|
1181
1248
|
type LlmProviderKey = keyof AllLlm;
|
|
1182
1249
|
type EmbeddingProviderKey = keyof AllEmbedding;
|
|
@@ -1195,7 +1262,7 @@ interface BaseRequest<_T extends Record<string, any>> {
|
|
|
1195
1262
|
interface BaseLlm<_T extends BaseLlCall = BaseLlCall> extends BaseRequest<_T> {
|
|
1196
1263
|
}
|
|
1197
1264
|
|
|
1198
|
-
type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
|
|
1265
|
+
type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "amazon:cohere.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
|
|
1199
1266
|
interface Config<Pk = LlmProviderKey> {
|
|
1200
1267
|
/**
|
|
1201
1268
|
* Unique identifier for this configuration (e.g., "openai.chat.v1", "anthropic.claude-3-opus")
|
|
@@ -1486,37 +1553,47 @@ declare namespace guards {
|
|
|
1486
1553
|
declare const configs: {
|
|
1487
1554
|
"deepseek.chat.v1": Config<keyof AllLlm>;
|
|
1488
1555
|
"deepseek.chat": Config<keyof AllLlm>;
|
|
1556
|
+
"deepseek.v4-flash": Config<keyof AllLlm>;
|
|
1557
|
+
"deepseek.v4-pro": Config<keyof AllLlm>;
|
|
1489
1558
|
"google.chat.v1": Config<keyof AllLlm>;
|
|
1490
|
-
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1491
|
-
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1492
1559
|
"google.gemini-2.5-flash": Config<keyof AllLlm>;
|
|
1493
1560
|
"google.gemini-2.5-flash-lite": Config<keyof AllLlm>;
|
|
1494
|
-
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1495
1561
|
"google.gemini-2.5-pro": Config<keyof AllLlm>;
|
|
1562
|
+
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1563
|
+
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1564
|
+
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1496
1565
|
"ollama.chat.v1": Config<keyof AllLlm>;
|
|
1497
1566
|
"ollama.deepseek-r1": Config<keyof AllLlm>;
|
|
1498
1567
|
"ollama.llama3.3": Config<keyof AllLlm>;
|
|
1499
1568
|
"ollama.llama3.2": Config<keyof AllLlm>;
|
|
1500
1569
|
"ollama.llama3.1": Config<keyof AllLlm>;
|
|
1501
1570
|
"ollama.qwq": Config<keyof AllLlm>;
|
|
1571
|
+
"ollama.gemma3": Config<keyof AllLlm>;
|
|
1572
|
+
"ollama.mistral": Config<keyof AllLlm>;
|
|
1573
|
+
"ollama.qwen2.5": Config<keyof AllLlm>;
|
|
1574
|
+
"ollama.qwen3": Config<keyof AllLlm>;
|
|
1502
1575
|
"xai.chat.v1": Config<keyof AllLlm>;
|
|
1503
1576
|
"xai.grok-2": Config<keyof AllLlm>;
|
|
1504
1577
|
"xai.grok-3": Config<keyof AllLlm>;
|
|
1505
1578
|
"xai.grok-3-mini": Config<keyof AllLlm>;
|
|
1506
1579
|
"xai.grok-4": Config<keyof AllLlm>;
|
|
1507
1580
|
"xai.grok-4-fast": Config<keyof AllLlm>;
|
|
1581
|
+
"xai.grok-4-1-fast": Config<keyof AllLlm>;
|
|
1508
1582
|
"amazon:anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1509
1583
|
"amazon:meta.chat.v1": Config<keyof AllLlm>;
|
|
1510
1584
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1585
|
+
"anthropic.claude-opus-4-7": Config<keyof AllLlm>;
|
|
1511
1586
|
"anthropic.claude-opus-4-6": Config<keyof AllLlm>;
|
|
1512
1587
|
"anthropic.claude-sonnet-4-6": Config<keyof AllLlm>;
|
|
1588
|
+
"anthropic.claude-haiku-4-5": Config<keyof AllLlm>;
|
|
1589
|
+
"anthropic.claude-sonnet-4-5": Config<keyof AllLlm>;
|
|
1590
|
+
"anthropic.claude-opus-4-1": Config<keyof AllLlm>;
|
|
1513
1591
|
"anthropic.claude-sonnet-4": Config<keyof AllLlm>;
|
|
1514
1592
|
"anthropic.claude-opus-4": Config<keyof AllLlm>;
|
|
1515
1593
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1516
1594
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1517
1595
|
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
|
1518
1596
|
"anthropic.claude-3-opus": Config<keyof AllLlm>;
|
|
1519
|
-
"anthropic.claude-3-haiku": Config<keyof AllLlm>;
|
|
1520
1597
|
"openai.chat.v1": Config<keyof AllLlm>;
|
|
1521
1598
|
"openai.chat-mock.v1": Config<keyof AllLlm>;
|
|
1522
1599
|
"openai.gpt-5.2": Config<keyof AllLlm>;
|
|
@@ -1526,9 +1603,10 @@ declare const configs: {
|
|
|
1526
1603
|
"openai.gpt-4.1-mini": Config<keyof AllLlm>;
|
|
1527
1604
|
"openai.gpt-4.1-nano": Config<keyof AllLlm>;
|
|
1528
1605
|
"openai.o3": Config<keyof AllLlm>;
|
|
1529
|
-
"openai.
|
|
1606
|
+
"openai.gpt-4": Config<keyof AllLlm>;
|
|
1530
1607
|
"openai.gpt-4o": Config<keyof AllLlm>;
|
|
1531
1608
|
"openai.gpt-4o-mini": Config<keyof AllLlm>;
|
|
1609
|
+
"openai.o4-mini": Config<keyof AllLlm>;
|
|
1532
1610
|
};
|
|
1533
1611
|
|
|
1534
1612
|
declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): BaseLlm;
|
|
@@ -1557,6 +1635,7 @@ declare function createOpenAiCompatibleConfiguration<K extends Config["key"]>(ov
|
|
|
1557
1635
|
provider: string;
|
|
1558
1636
|
endpoint: string;
|
|
1559
1637
|
apiKeyMapping: [string, string];
|
|
1638
|
+
isReasoningModel?: (model: string) => boolean;
|
|
1560
1639
|
transformResponse?: any;
|
|
1561
1640
|
}): Config<keyof AllLlm>;
|
|
1562
1641
|
|
package/dist/index.d.ts
CHANGED
|
@@ -129,7 +129,8 @@ declare class JsonParser<S extends JSONSchema | undefined = undefined> extends B
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
declare class ListToJsonParser<S extends JSONSchema | undefined = undefined> extends BaseParserWithJson<S> {
|
|
132
|
-
|
|
132
|
+
private keyTransform;
|
|
133
|
+
constructor(options?: ListToJsonParserOptions<S>);
|
|
133
134
|
parse(text: string): ParserOutput<BaseParserWithJson<S>>;
|
|
134
135
|
}
|
|
135
136
|
|
|
@@ -292,7 +293,7 @@ declare function createParser<T extends Extract<CreateParserType, "stringExtract
|
|
|
292
293
|
* @param options - The JSON schema.
|
|
293
294
|
* @returns An instance of ListToJsonParser.
|
|
294
295
|
*/
|
|
295
|
-
declare function createParser<T extends Extract<CreateParserType, "listToJson">, S extends JSONSchema | undefined = undefined>(type: T, options?:
|
|
296
|
+
declare function createParser<T extends Extract<CreateParserType, "listToJson">, S extends JSONSchema | undefined = undefined>(type: T, options?: ListToJsonParserOptions<S>): ListToJsonParser<S>;
|
|
296
297
|
/**
|
|
297
298
|
* Creates a parser based on the given type and schema.
|
|
298
299
|
* @template S - JSON schema type.
|
|
@@ -402,8 +403,8 @@ declare abstract class BasePrompt<I extends Record<string, any>> {
|
|
|
402
403
|
_input: any;
|
|
403
404
|
};
|
|
404
405
|
/**
|
|
405
|
-
*
|
|
406
|
-
* @return {boolean} Returns false if the
|
|
406
|
+
* Validates the prompt structure.
|
|
407
|
+
* @return {boolean} Returns false if the prompt has no messages defined.
|
|
407
408
|
*/
|
|
408
409
|
validate(): boolean;
|
|
409
410
|
}
|
|
@@ -521,12 +522,6 @@ declare class ChatPrompt<I extends Record<string, any>> extends BasePrompt<I> {
|
|
|
521
522
|
* @return formatted prompt.
|
|
522
523
|
*/
|
|
523
524
|
formatAsync(values: I): Promise<IChatMessages>;
|
|
524
|
-
/**
|
|
525
|
-
* validate Ensures there are not unresolved tokens in prompt.
|
|
526
|
-
* @TODO Make this work!
|
|
527
|
-
* @return Returns false if the template is not valid.
|
|
528
|
-
*/
|
|
529
|
-
validate(): boolean;
|
|
530
525
|
}
|
|
531
526
|
|
|
532
527
|
type TextPromptType = "text";
|
|
@@ -712,6 +707,33 @@ declare class Dialogue extends BaseStateItem<IChatMessages> {
|
|
|
712
707
|
};
|
|
713
708
|
}): this;
|
|
714
709
|
setMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
710
|
+
/**
|
|
711
|
+
* Aliases using `add*` naming to match ChatPrompt's API.
|
|
712
|
+
* These delegate to the corresponding `set*` methods.
|
|
713
|
+
*/
|
|
714
|
+
addUserMessage(content: string | IChatMessageContentDetailed[], name?: string): this;
|
|
715
|
+
addAssistantMessage(content: string | OutputResultsText): this;
|
|
716
|
+
addSystemMessage(content: string): this;
|
|
717
|
+
addToolMessage(content: string, name: string, id?: string): this;
|
|
718
|
+
addToolCallMessage(input: {
|
|
719
|
+
name: string;
|
|
720
|
+
arguments: string;
|
|
721
|
+
id?: string;
|
|
722
|
+
}): this;
|
|
723
|
+
addFunctionMessage(content: string, name: string, id?: string): this;
|
|
724
|
+
addFunctionCallMessage(input: {
|
|
725
|
+
name: string;
|
|
726
|
+
arguments: string;
|
|
727
|
+
id?: string;
|
|
728
|
+
} | {
|
|
729
|
+
function_call: {
|
|
730
|
+
name: string;
|
|
731
|
+
arguments: string;
|
|
732
|
+
id?: string;
|
|
733
|
+
};
|
|
734
|
+
}): this;
|
|
735
|
+
addMessageTurn(userMessage: string, assistantMessage: string, systemMessage?: string): this;
|
|
736
|
+
addHistory(messages: IChatMessages): this;
|
|
715
737
|
setHistory(messages: IChatMessages): this;
|
|
716
738
|
getHistory(): IChatMessages;
|
|
717
739
|
serialize(): {
|
|
@@ -904,6 +926,9 @@ interface BaseParserOptionsWithSchema<S extends JSONSchema | undefined = undefin
|
|
|
904
926
|
schema?: S;
|
|
905
927
|
validateSchema?: boolean;
|
|
906
928
|
}
|
|
929
|
+
interface ListToJsonParserOptions<S extends JSONSchema | undefined = undefined> extends BaseParserOptionsWithSchema<S> {
|
|
930
|
+
keyTransform?: "camelCase" | "preserve";
|
|
931
|
+
}
|
|
907
932
|
|
|
908
933
|
/**
|
|
909
934
|
* Internal Formats
|
|
@@ -971,6 +996,10 @@ interface AmazonEmbeddingOptions extends GenericEmbeddingOptions {
|
|
|
971
996
|
awsSecretKey?: string;
|
|
972
997
|
awsAccessKey?: string;
|
|
973
998
|
}
|
|
999
|
+
interface CohereBedrockEmbeddingOptions extends AmazonEmbeddingOptions {
|
|
1000
|
+
inputType?: "search_document" | "search_query" | "classification" | "clustering";
|
|
1001
|
+
truncate?: "NONE" | "START" | "END" | "LEFT" | "RIGHT";
|
|
1002
|
+
}
|
|
974
1003
|
interface GenericLLm extends BaseLlmOptions {
|
|
975
1004
|
model?: string;
|
|
976
1005
|
system?: string;
|
|
@@ -994,6 +1023,14 @@ interface OpenAiRequest extends GenericLLm {
|
|
|
994
1023
|
openAiApiKey?: string;
|
|
995
1024
|
useJson?: boolean;
|
|
996
1025
|
}
|
|
1026
|
+
interface XAiRequest extends GenericLLm {
|
|
1027
|
+
model: string;
|
|
1028
|
+
frequencyPenalty?: number;
|
|
1029
|
+
logitBias?: Record<string, any> | null;
|
|
1030
|
+
responseFormat?: Record<string, any>;
|
|
1031
|
+
xAiApiKey?: string;
|
|
1032
|
+
useJson?: boolean;
|
|
1033
|
+
}
|
|
997
1034
|
interface AmazonBedrockRequest extends GenericLLm {
|
|
998
1035
|
model: string;
|
|
999
1036
|
awsRegion?: string;
|
|
@@ -1026,6 +1063,9 @@ type AllEmbedding = {
|
|
|
1026
1063
|
"amazon.embedding.v1": {
|
|
1027
1064
|
input: AmazonEmbeddingOptions;
|
|
1028
1065
|
};
|
|
1066
|
+
"amazon:cohere.embedding.v1": {
|
|
1067
|
+
input: CohereBedrockEmbeddingOptions;
|
|
1068
|
+
};
|
|
1029
1069
|
};
|
|
1030
1070
|
type AllLlm = {
|
|
1031
1071
|
"openai.chat.v1": {
|
|
@@ -1044,7 +1084,7 @@ type AllLlm = {
|
|
|
1044
1084
|
input: AmazonBedrockRequest;
|
|
1045
1085
|
};
|
|
1046
1086
|
"xai.chat.v1": {
|
|
1047
|
-
input:
|
|
1087
|
+
input: XAiRequest;
|
|
1048
1088
|
};
|
|
1049
1089
|
"ollama.chat.v1": {
|
|
1050
1090
|
input: GenericLLm;
|
|
@@ -1078,11 +1118,8 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1078
1118
|
"openai.o3": {
|
|
1079
1119
|
input: Omit<OpenAiRequest, "model">;
|
|
1080
1120
|
};
|
|
1081
|
-
"openai.o4-mini": {
|
|
1082
|
-
input: Omit<OpenAiRequest, "model">;
|
|
1083
|
-
};
|
|
1084
1121
|
"openai.gpt-4": {
|
|
1085
|
-
input: OpenAiRequest
|
|
1122
|
+
input: Omit<OpenAiRequest, "model">;
|
|
1086
1123
|
};
|
|
1087
1124
|
"openai.gpt-4o": {
|
|
1088
1125
|
input: Omit<OpenAiRequest, "model">;
|
|
@@ -1090,12 +1127,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1090
1127
|
"openai.gpt-4o-mini": {
|
|
1091
1128
|
input: Omit<OpenAiRequest, "model">;
|
|
1092
1129
|
};
|
|
1130
|
+
"openai.o4-mini": {
|
|
1131
|
+
input: Omit<OpenAiRequest, "model">;
|
|
1132
|
+
};
|
|
1133
|
+
"anthropic.claude-opus-4-7": {
|
|
1134
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1135
|
+
};
|
|
1093
1136
|
"anthropic.claude-opus-4-6": {
|
|
1094
1137
|
input: Omit<AnthropicRequest, "model">;
|
|
1095
1138
|
};
|
|
1096
1139
|
"anthropic.claude-sonnet-4-6": {
|
|
1097
1140
|
input: Omit<AnthropicRequest, "model">;
|
|
1098
1141
|
};
|
|
1142
|
+
"anthropic.claude-haiku-4-5": {
|
|
1143
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1144
|
+
};
|
|
1145
|
+
"anthropic.claude-sonnet-4-5": {
|
|
1146
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1147
|
+
};
|
|
1148
|
+
"anthropic.claude-opus-4-1": {
|
|
1149
|
+
input: Omit<AnthropicRequest, "model">;
|
|
1150
|
+
};
|
|
1099
1151
|
"anthropic.claude-sonnet-4-0": {
|
|
1100
1152
|
input: Omit<AnthropicRequest, "model">;
|
|
1101
1153
|
};
|
|
@@ -1120,44 +1172,41 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1120
1172
|
"anthropic.claude-3-opus": {
|
|
1121
1173
|
input: Omit<AnthropicRequest, "model">;
|
|
1122
1174
|
};
|
|
1123
|
-
"
|
|
1124
|
-
input: Omit<AnthropicRequest, "model">;
|
|
1125
|
-
};
|
|
1126
|
-
"google.gemini-2.5-pro-exp-03-25": {
|
|
1175
|
+
"google.gemini-2.5-flash": {
|
|
1127
1176
|
input: Omit<GeminiRequest, "model">;
|
|
1128
1177
|
};
|
|
1129
|
-
"google.gemini-2.
|
|
1178
|
+
"google.gemini-2.5-flash-lite": {
|
|
1130
1179
|
input: Omit<GeminiRequest, "model">;
|
|
1131
1180
|
};
|
|
1132
|
-
"google.gemini-2.
|
|
1181
|
+
"google.gemini-2.5-pro": {
|
|
1133
1182
|
input: Omit<GeminiRequest, "model">;
|
|
1134
1183
|
};
|
|
1135
|
-
"google.gemini-2.
|
|
1184
|
+
"google.gemini-2.0-flash": {
|
|
1136
1185
|
input: Omit<GeminiRequest, "model">;
|
|
1137
1186
|
};
|
|
1138
|
-
"google.gemini-2.
|
|
1187
|
+
"google.gemini-2.0-flash-lite": {
|
|
1139
1188
|
input: Omit<GeminiRequest, "model">;
|
|
1140
1189
|
};
|
|
1141
1190
|
"google.gemini-1.5-pro": {
|
|
1142
1191
|
input: Omit<GeminiRequest, "model">;
|
|
1143
1192
|
};
|
|
1144
|
-
"google.gemini-2.5-pro": {
|
|
1145
|
-
input: Omit<GeminiRequest, "model">;
|
|
1146
|
-
};
|
|
1147
1193
|
"xai.grok-2": {
|
|
1148
|
-
input:
|
|
1194
|
+
input: Omit<XAiRequest, "model">;
|
|
1149
1195
|
};
|
|
1150
1196
|
"xai.grok-3": {
|
|
1151
|
-
input:
|
|
1197
|
+
input: Omit<XAiRequest, "model">;
|
|
1152
1198
|
};
|
|
1153
1199
|
"xai.grok-3-mini": {
|
|
1154
|
-
input: Omit<
|
|
1200
|
+
input: Omit<XAiRequest, "model">;
|
|
1155
1201
|
};
|
|
1156
1202
|
"xai.grok-4": {
|
|
1157
|
-
input:
|
|
1203
|
+
input: Omit<XAiRequest, "model">;
|
|
1158
1204
|
};
|
|
1159
1205
|
"xai.grok-4-fast": {
|
|
1160
|
-
input: Omit<
|
|
1206
|
+
input: Omit<XAiRequest, "model">;
|
|
1207
|
+
};
|
|
1208
|
+
"xai.grok-4-1-fast": {
|
|
1209
|
+
input: Omit<XAiRequest, "model">;
|
|
1161
1210
|
};
|
|
1162
1211
|
"ollama.deepseek-r1": {
|
|
1163
1212
|
input: GenericLLm;
|
|
@@ -1174,9 +1223,27 @@ type AllUseLlmOptions = AllLlm & {
|
|
|
1174
1223
|
"ollama.qwq": {
|
|
1175
1224
|
input: GenericLLm;
|
|
1176
1225
|
};
|
|
1226
|
+
"ollama.gemma3": {
|
|
1227
|
+
input: GenericLLm;
|
|
1228
|
+
};
|
|
1229
|
+
"ollama.mistral": {
|
|
1230
|
+
input: GenericLLm;
|
|
1231
|
+
};
|
|
1232
|
+
"ollama.qwen2.5": {
|
|
1233
|
+
input: GenericLLm;
|
|
1234
|
+
};
|
|
1235
|
+
"ollama.qwen3": {
|
|
1236
|
+
input: GenericLLm;
|
|
1237
|
+
};
|
|
1177
1238
|
"deepseek.chat": {
|
|
1178
1239
|
input: DeepseekRequest;
|
|
1179
1240
|
};
|
|
1241
|
+
"deepseek.v4-flash": {
|
|
1242
|
+
input: Omit<DeepseekRequest, "model">;
|
|
1243
|
+
};
|
|
1244
|
+
"deepseek.v4-pro": {
|
|
1245
|
+
input: Omit<DeepseekRequest, "model">;
|
|
1246
|
+
};
|
|
1180
1247
|
};
|
|
1181
1248
|
type LlmProviderKey = keyof AllLlm;
|
|
1182
1249
|
type EmbeddingProviderKey = keyof AllEmbedding;
|
|
@@ -1195,7 +1262,7 @@ interface BaseRequest<_T extends Record<string, any>> {
|
|
|
1195
1262
|
interface BaseLlm<_T extends BaseLlCall = BaseLlCall> extends BaseRequest<_T> {
|
|
1196
1263
|
}
|
|
1197
1264
|
|
|
1198
|
-
type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
|
|
1265
|
+
type LlmProvider = "openai.chat" | "openai.embedding" | "google.embedding" | "openai.chat-mock" | "anthropic.chat" | "amazon:anthropic.chat" | "amazon:meta.chat" | "amazon:nova.chat" | "amazon.embedding" | "amazon:cohere.embedding" | "xai.chat" | "google.chat" | "ollama.chat" | "deepseek.chat";
|
|
1199
1266
|
interface Config<Pk = LlmProviderKey> {
|
|
1200
1267
|
/**
|
|
1201
1268
|
* Unique identifier for this configuration (e.g., "openai.chat.v1", "anthropic.claude-3-opus")
|
|
@@ -1486,37 +1553,47 @@ declare namespace guards {
|
|
|
1486
1553
|
declare const configs: {
|
|
1487
1554
|
"deepseek.chat.v1": Config<keyof AllLlm>;
|
|
1488
1555
|
"deepseek.chat": Config<keyof AllLlm>;
|
|
1556
|
+
"deepseek.v4-flash": Config<keyof AllLlm>;
|
|
1557
|
+
"deepseek.v4-pro": Config<keyof AllLlm>;
|
|
1489
1558
|
"google.chat.v1": Config<keyof AllLlm>;
|
|
1490
|
-
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1491
|
-
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1492
1559
|
"google.gemini-2.5-flash": Config<keyof AllLlm>;
|
|
1493
1560
|
"google.gemini-2.5-flash-lite": Config<keyof AllLlm>;
|
|
1494
|
-
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1495
1561
|
"google.gemini-2.5-pro": Config<keyof AllLlm>;
|
|
1562
|
+
"google.gemini-2.0-flash": Config<keyof AllLlm>;
|
|
1563
|
+
"google.gemini-2.0-flash-lite": Config<keyof AllLlm>;
|
|
1564
|
+
"google.gemini-1.5-pro": Config<keyof AllLlm>;
|
|
1496
1565
|
"ollama.chat.v1": Config<keyof AllLlm>;
|
|
1497
1566
|
"ollama.deepseek-r1": Config<keyof AllLlm>;
|
|
1498
1567
|
"ollama.llama3.3": Config<keyof AllLlm>;
|
|
1499
1568
|
"ollama.llama3.2": Config<keyof AllLlm>;
|
|
1500
1569
|
"ollama.llama3.1": Config<keyof AllLlm>;
|
|
1501
1570
|
"ollama.qwq": Config<keyof AllLlm>;
|
|
1571
|
+
"ollama.gemma3": Config<keyof AllLlm>;
|
|
1572
|
+
"ollama.mistral": Config<keyof AllLlm>;
|
|
1573
|
+
"ollama.qwen2.5": Config<keyof AllLlm>;
|
|
1574
|
+
"ollama.qwen3": Config<keyof AllLlm>;
|
|
1502
1575
|
"xai.chat.v1": Config<keyof AllLlm>;
|
|
1503
1576
|
"xai.grok-2": Config<keyof AllLlm>;
|
|
1504
1577
|
"xai.grok-3": Config<keyof AllLlm>;
|
|
1505
1578
|
"xai.grok-3-mini": Config<keyof AllLlm>;
|
|
1506
1579
|
"xai.grok-4": Config<keyof AllLlm>;
|
|
1507
1580
|
"xai.grok-4-fast": Config<keyof AllLlm>;
|
|
1581
|
+
"xai.grok-4-1-fast": Config<keyof AllLlm>;
|
|
1508
1582
|
"amazon:anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1509
1583
|
"amazon:meta.chat.v1": Config<keyof AllLlm>;
|
|
1510
1584
|
"anthropic.chat.v1": Config<keyof AllLlm>;
|
|
1585
|
+
"anthropic.claude-opus-4-7": Config<keyof AllLlm>;
|
|
1511
1586
|
"anthropic.claude-opus-4-6": Config<keyof AllLlm>;
|
|
1512
1587
|
"anthropic.claude-sonnet-4-6": Config<keyof AllLlm>;
|
|
1588
|
+
"anthropic.claude-haiku-4-5": Config<keyof AllLlm>;
|
|
1589
|
+
"anthropic.claude-sonnet-4-5": Config<keyof AllLlm>;
|
|
1590
|
+
"anthropic.claude-opus-4-1": Config<keyof AllLlm>;
|
|
1513
1591
|
"anthropic.claude-sonnet-4": Config<keyof AllLlm>;
|
|
1514
1592
|
"anthropic.claude-opus-4": Config<keyof AllLlm>;
|
|
1515
1593
|
"anthropic.claude-3-7-sonnet": Config<keyof AllLlm>;
|
|
1516
1594
|
"anthropic.claude-3-5-sonnet": Config<keyof AllLlm>;
|
|
1517
1595
|
"anthropic.claude-3-5-haiku": Config<keyof AllLlm>;
|
|
1518
1596
|
"anthropic.claude-3-opus": Config<keyof AllLlm>;
|
|
1519
|
-
"anthropic.claude-3-haiku": Config<keyof AllLlm>;
|
|
1520
1597
|
"openai.chat.v1": Config<keyof AllLlm>;
|
|
1521
1598
|
"openai.chat-mock.v1": Config<keyof AllLlm>;
|
|
1522
1599
|
"openai.gpt-5.2": Config<keyof AllLlm>;
|
|
@@ -1526,9 +1603,10 @@ declare const configs: {
|
|
|
1526
1603
|
"openai.gpt-4.1-mini": Config<keyof AllLlm>;
|
|
1527
1604
|
"openai.gpt-4.1-nano": Config<keyof AllLlm>;
|
|
1528
1605
|
"openai.o3": Config<keyof AllLlm>;
|
|
1529
|
-
"openai.
|
|
1606
|
+
"openai.gpt-4": Config<keyof AllLlm>;
|
|
1530
1607
|
"openai.gpt-4o": Config<keyof AllLlm>;
|
|
1531
1608
|
"openai.gpt-4o-mini": Config<keyof AllLlm>;
|
|
1609
|
+
"openai.o4-mini": Config<keyof AllLlm>;
|
|
1532
1610
|
};
|
|
1533
1611
|
|
|
1534
1612
|
declare function useLlm<T extends keyof typeof configs>(provider: T, options?: AllUseLlmOptions[T]["input"]): BaseLlm;
|
|
@@ -1557,6 +1635,7 @@ declare function createOpenAiCompatibleConfiguration<K extends Config["key"]>(ov
|
|
|
1557
1635
|
provider: string;
|
|
1558
1636
|
endpoint: string;
|
|
1559
1637
|
apiKeyMapping: [string, string];
|
|
1638
|
+
isReasoningModel?: (model: string) => boolean;
|
|
1560
1639
|
transformResponse?: any;
|
|
1561
1640
|
}): Config<keyof AllLlm>;
|
|
1562
1641
|
|