llm-exe 2.3.7 → 2.3.9
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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +111 -98
- package/dist/index.mjs +111 -98
- package/package.json +2 -2
- package/readme.md +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1363,7 +1363,13 @@ interface Config<Pk = LlmProviderKey> {
|
|
|
1363
1363
|
*/
|
|
1364
1364
|
functions?: (functions: any[], options?: any, currentInput?: Record<string, any>, config?: Config) => Record<string, any>;
|
|
1365
1365
|
};
|
|
1366
|
-
|
|
1366
|
+
/**
|
|
1367
|
+
* Optional response transformer for chat/LLM configs. The LLM call path
|
|
1368
|
+
* (`llm.call.ts`) defaults to `OutputDefault` when this is omitted.
|
|
1369
|
+
* Embedding configs do not use this — their flow dispatches via
|
|
1370
|
+
* `getEmbeddingOutputParser` instead.
|
|
1371
|
+
*/
|
|
1372
|
+
transformResponse?: (result: any, _config?: Config<any>) => OutputResult;
|
|
1367
1373
|
}
|
|
1368
1374
|
|
|
1369
1375
|
declare function enforceResultAttributes<O>(input: any): {
|
package/dist/index.d.ts
CHANGED
|
@@ -1363,7 +1363,13 @@ interface Config<Pk = LlmProviderKey> {
|
|
|
1363
1363
|
*/
|
|
1364
1364
|
functions?: (functions: any[], options?: any, currentInput?: Record<string, any>, config?: Config) => Record<string, any>;
|
|
1365
1365
|
};
|
|
1366
|
-
|
|
1366
|
+
/**
|
|
1367
|
+
* Optional response transformer for chat/LLM configs. The LLM call path
|
|
1368
|
+
* (`llm.call.ts`) defaults to `OutputDefault` when this is omitted.
|
|
1369
|
+
* Embedding configs do not use this — their flow dispatches via
|
|
1370
|
+
* `getEmbeddingOutputParser` instead.
|
|
1371
|
+
*/
|
|
1372
|
+
transformResponse?: (result: any, _config?: Config<any>) => OutputResult;
|
|
1367
1373
|
}
|
|
1368
1374
|
|
|
1369
1375
|
declare function enforceResultAttributes<O>(input: any): {
|
package/dist/index.js
CHANGED
|
@@ -3903,97 +3903,6 @@ function useLlmConfiguration(config) {
|
|
|
3903
3903
|
return (options = {}) => apiRequestWrapper(config, options, useLlm_call);
|
|
3904
3904
|
}
|
|
3905
3905
|
|
|
3906
|
-
// src/embedding/output/BaseEmbeddingOutput.ts
|
|
3907
|
-
function BaseEmbeddingOutput(result) {
|
|
3908
|
-
const __result = Object.freeze({
|
|
3909
|
-
id: result.id || (0, import_uuid.v4)(),
|
|
3910
|
-
model: result.model,
|
|
3911
|
-
usage: result.usage,
|
|
3912
|
-
embedding: [...result?.embedding || []],
|
|
3913
|
-
created: result?.created || (/* @__PURE__ */ new Date()).getTime()
|
|
3914
|
-
});
|
|
3915
|
-
function getResult() {
|
|
3916
|
-
return {
|
|
3917
|
-
id: __result.id,
|
|
3918
|
-
model: __result.model,
|
|
3919
|
-
created: __result.created,
|
|
3920
|
-
usage: __result.usage,
|
|
3921
|
-
embedding: __result.embedding
|
|
3922
|
-
};
|
|
3923
|
-
}
|
|
3924
|
-
function getEmbedding(index) {
|
|
3925
|
-
if (index && index > 0) {
|
|
3926
|
-
const arr = __result?.embedding;
|
|
3927
|
-
const val = arr[index];
|
|
3928
|
-
return val ? val : [];
|
|
3929
|
-
}
|
|
3930
|
-
return __result.embedding[0];
|
|
3931
|
-
}
|
|
3932
|
-
return {
|
|
3933
|
-
getEmbedding,
|
|
3934
|
-
getResult
|
|
3935
|
-
};
|
|
3936
|
-
}
|
|
3937
|
-
|
|
3938
|
-
// src/embedding/output/OpenAiEmbedding.ts
|
|
3939
|
-
function OpenAiEmbedding(result, config) {
|
|
3940
|
-
const __result = deepClone(result);
|
|
3941
|
-
const model = __result.model || config.model || "openai.unknown";
|
|
3942
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3943
|
-
const results = result?.data || [];
|
|
3944
|
-
const embedding = results.map((a) => a.embedding);
|
|
3945
|
-
const usage = {
|
|
3946
|
-
output_tokens: 0,
|
|
3947
|
-
input_tokens: result?.usage?.prompt_tokens,
|
|
3948
|
-
total_tokens: result?.usage?.total_tokens
|
|
3949
|
-
};
|
|
3950
|
-
return BaseEmbeddingOutput({
|
|
3951
|
-
model,
|
|
3952
|
-
created,
|
|
3953
|
-
usage,
|
|
3954
|
-
embedding
|
|
3955
|
-
});
|
|
3956
|
-
}
|
|
3957
|
-
|
|
3958
|
-
// src/embedding/output/AmazonTitan.ts
|
|
3959
|
-
function AmazonTitanEmbedding(result, config) {
|
|
3960
|
-
const __result = deepClone(result);
|
|
3961
|
-
const model = config.model || "amazon.unknown";
|
|
3962
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3963
|
-
const embedding = [__result.embedding];
|
|
3964
|
-
const usage = {
|
|
3965
|
-
output_tokens: 0,
|
|
3966
|
-
input_tokens: __result.inputTextTokenCount,
|
|
3967
|
-
total_tokens: __result.inputTextTokenCount
|
|
3968
|
-
};
|
|
3969
|
-
return BaseEmbeddingOutput({
|
|
3970
|
-
model,
|
|
3971
|
-
created,
|
|
3972
|
-
usage,
|
|
3973
|
-
embedding
|
|
3974
|
-
});
|
|
3975
|
-
}
|
|
3976
|
-
|
|
3977
|
-
// src/embedding/output/CohereBedrockEmbedding.ts
|
|
3978
|
-
function CohereBedrockEmbedding(result, config) {
|
|
3979
|
-
const __result = deepClone(result);
|
|
3980
|
-
const model = config.model || "cohere.unknown";
|
|
3981
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3982
|
-
const embedding = Array.isArray(__result.embeddings) ? __result.embeddings : [];
|
|
3983
|
-
const usage = {
|
|
3984
|
-
output_tokens: 0,
|
|
3985
|
-
input_tokens: 0,
|
|
3986
|
-
total_tokens: 0
|
|
3987
|
-
};
|
|
3988
|
-
return BaseEmbeddingOutput({
|
|
3989
|
-
id: __result.id,
|
|
3990
|
-
model,
|
|
3991
|
-
created,
|
|
3992
|
-
usage,
|
|
3993
|
-
embedding
|
|
3994
|
-
});
|
|
3995
|
-
}
|
|
3996
|
-
|
|
3997
3906
|
// src/embedding/config.ts
|
|
3998
3907
|
var embeddingConfigs = {
|
|
3999
3908
|
"openai.embedding.v1": {
|
|
@@ -4025,8 +3934,7 @@ var embeddingConfigs = {
|
|
|
4025
3934
|
encodingFormat: {
|
|
4026
3935
|
key: "encoding_format"
|
|
4027
3936
|
}
|
|
4028
|
-
}
|
|
4029
|
-
transformResponse: OpenAiEmbedding
|
|
3937
|
+
}
|
|
4030
3938
|
},
|
|
4031
3939
|
"amazon.embedding.v1": {
|
|
4032
3940
|
key: "amazon.embedding.v1",
|
|
@@ -4053,8 +3961,7 @@ var embeddingConfigs = {
|
|
|
4053
3961
|
dimensions: {
|
|
4054
3962
|
key: "dimensions"
|
|
4055
3963
|
}
|
|
4056
|
-
}
|
|
4057
|
-
transformResponse: AmazonTitanEmbedding
|
|
3964
|
+
}
|
|
4058
3965
|
},
|
|
4059
3966
|
"amazon:cohere.embedding.v1": {
|
|
4060
3967
|
key: "amazon:cohere.embedding.v1",
|
|
@@ -4088,10 +3995,25 @@ var embeddingConfigs = {
|
|
|
4088
3995
|
key: "truncate"
|
|
4089
3996
|
},
|
|
4090
3997
|
dimensions: {
|
|
4091
|
-
key: "output_dimension"
|
|
3998
|
+
key: "output_dimension",
|
|
3999
|
+
// Embed v3 has a fixed 1024-dim output and rejects the output_dimension
|
|
4000
|
+
// field entirely — even when the value matches. Drop the field for v3
|
|
4001
|
+
// when the user asked for the natural 1024; throw for any other value
|
|
4002
|
+
// so we don't silently mutate user intent.
|
|
4003
|
+
transform: (value, state) => {
|
|
4004
|
+
if (typeof value === "undefined") return void 0;
|
|
4005
|
+
const model = state?.model || "";
|
|
4006
|
+
const isV3 = /embed-(english|multilingual)-v3/.test(model);
|
|
4007
|
+
if (isV3) {
|
|
4008
|
+
if (value === 1024) return void 0;
|
|
4009
|
+
throw new Error(
|
|
4010
|
+
`Cohere Embed v3 only supports 1024-dimensional output (model: "${model}", requested: ${value}). Use cohere.embed-v4:0 for configurable dimensions.`
|
|
4011
|
+
);
|
|
4012
|
+
}
|
|
4013
|
+
return value;
|
|
4014
|
+
}
|
|
4092
4015
|
}
|
|
4093
|
-
}
|
|
4094
|
-
transformResponse: CohereBedrockEmbedding
|
|
4016
|
+
}
|
|
4095
4017
|
}
|
|
4096
4018
|
};
|
|
4097
4019
|
function getEmbeddingConfig(provider) {
|
|
@@ -4105,6 +4027,97 @@ function getEmbeddingConfig(provider) {
|
|
|
4105
4027
|
throw new Error(`Invalid provider: ${provider}`);
|
|
4106
4028
|
}
|
|
4107
4029
|
|
|
4030
|
+
// src/embedding/output/BaseEmbeddingOutput.ts
|
|
4031
|
+
function BaseEmbeddingOutput(result) {
|
|
4032
|
+
const __result = Object.freeze({
|
|
4033
|
+
id: result.id || (0, import_uuid.v4)(),
|
|
4034
|
+
model: result.model,
|
|
4035
|
+
usage: result.usage,
|
|
4036
|
+
embedding: [...result?.embedding || []],
|
|
4037
|
+
created: result?.created || (/* @__PURE__ */ new Date()).getTime()
|
|
4038
|
+
});
|
|
4039
|
+
function getResult() {
|
|
4040
|
+
return {
|
|
4041
|
+
id: __result.id,
|
|
4042
|
+
model: __result.model,
|
|
4043
|
+
created: __result.created,
|
|
4044
|
+
usage: __result.usage,
|
|
4045
|
+
embedding: __result.embedding
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
function getEmbedding(index) {
|
|
4049
|
+
if (index && index > 0) {
|
|
4050
|
+
const arr = __result?.embedding;
|
|
4051
|
+
const val = arr[index];
|
|
4052
|
+
return val ? val : [];
|
|
4053
|
+
}
|
|
4054
|
+
return __result.embedding[0];
|
|
4055
|
+
}
|
|
4056
|
+
return {
|
|
4057
|
+
getEmbedding,
|
|
4058
|
+
getResult
|
|
4059
|
+
};
|
|
4060
|
+
}
|
|
4061
|
+
|
|
4062
|
+
// src/embedding/output/AmazonTitan.ts
|
|
4063
|
+
function AmazonTitanEmbedding(result, config) {
|
|
4064
|
+
const __result = deepClone(result);
|
|
4065
|
+
const model = config.model || "amazon.unknown";
|
|
4066
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4067
|
+
const embedding = [__result.embedding];
|
|
4068
|
+
const usage = {
|
|
4069
|
+
output_tokens: 0,
|
|
4070
|
+
input_tokens: __result.inputTextTokenCount,
|
|
4071
|
+
total_tokens: __result.inputTextTokenCount
|
|
4072
|
+
};
|
|
4073
|
+
return BaseEmbeddingOutput({
|
|
4074
|
+
model,
|
|
4075
|
+
created,
|
|
4076
|
+
usage,
|
|
4077
|
+
embedding
|
|
4078
|
+
});
|
|
4079
|
+
}
|
|
4080
|
+
|
|
4081
|
+
// src/embedding/output/CohereBedrockEmbedding.ts
|
|
4082
|
+
function CohereBedrockEmbedding(result, config) {
|
|
4083
|
+
const __result = deepClone(result);
|
|
4084
|
+
const model = config.model || "cohere.unknown";
|
|
4085
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4086
|
+
const embedding = Array.isArray(__result.embeddings) ? __result.embeddings : [];
|
|
4087
|
+
const usage = {
|
|
4088
|
+
output_tokens: 0,
|
|
4089
|
+
input_tokens: 0,
|
|
4090
|
+
total_tokens: 0
|
|
4091
|
+
};
|
|
4092
|
+
return BaseEmbeddingOutput({
|
|
4093
|
+
id: __result.id,
|
|
4094
|
+
model,
|
|
4095
|
+
created,
|
|
4096
|
+
usage,
|
|
4097
|
+
embedding
|
|
4098
|
+
});
|
|
4099
|
+
}
|
|
4100
|
+
|
|
4101
|
+
// src/embedding/output/OpenAiEmbedding.ts
|
|
4102
|
+
function OpenAiEmbedding(result, config) {
|
|
4103
|
+
const __result = deepClone(result);
|
|
4104
|
+
const model = __result.model || config.model || "openai.unknown";
|
|
4105
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4106
|
+
const results = result?.data || [];
|
|
4107
|
+
const embedding = results.map((a) => a.embedding);
|
|
4108
|
+
const usage = {
|
|
4109
|
+
output_tokens: 0,
|
|
4110
|
+
input_tokens: result?.usage?.prompt_tokens,
|
|
4111
|
+
total_tokens: result?.usage?.total_tokens
|
|
4112
|
+
};
|
|
4113
|
+
return BaseEmbeddingOutput({
|
|
4114
|
+
model,
|
|
4115
|
+
created,
|
|
4116
|
+
usage,
|
|
4117
|
+
embedding
|
|
4118
|
+
});
|
|
4119
|
+
}
|
|
4120
|
+
|
|
4108
4121
|
// src/embedding/output/getEmbeddingOutputParser.ts
|
|
4109
4122
|
function getEmbeddingOutputParser(config, response) {
|
|
4110
4123
|
switch (config.key) {
|
package/dist/index.mjs
CHANGED
|
@@ -3840,97 +3840,6 @@ function useLlmConfiguration(config) {
|
|
|
3840
3840
|
return (options = {}) => apiRequestWrapper(config, options, useLlm_call);
|
|
3841
3841
|
}
|
|
3842
3842
|
|
|
3843
|
-
// src/embedding/output/BaseEmbeddingOutput.ts
|
|
3844
|
-
function BaseEmbeddingOutput(result) {
|
|
3845
|
-
const __result = Object.freeze({
|
|
3846
|
-
id: result.id || uuidv4(),
|
|
3847
|
-
model: result.model,
|
|
3848
|
-
usage: result.usage,
|
|
3849
|
-
embedding: [...result?.embedding || []],
|
|
3850
|
-
created: result?.created || (/* @__PURE__ */ new Date()).getTime()
|
|
3851
|
-
});
|
|
3852
|
-
function getResult() {
|
|
3853
|
-
return {
|
|
3854
|
-
id: __result.id,
|
|
3855
|
-
model: __result.model,
|
|
3856
|
-
created: __result.created,
|
|
3857
|
-
usage: __result.usage,
|
|
3858
|
-
embedding: __result.embedding
|
|
3859
|
-
};
|
|
3860
|
-
}
|
|
3861
|
-
function getEmbedding(index) {
|
|
3862
|
-
if (index && index > 0) {
|
|
3863
|
-
const arr = __result?.embedding;
|
|
3864
|
-
const val = arr[index];
|
|
3865
|
-
return val ? val : [];
|
|
3866
|
-
}
|
|
3867
|
-
return __result.embedding[0];
|
|
3868
|
-
}
|
|
3869
|
-
return {
|
|
3870
|
-
getEmbedding,
|
|
3871
|
-
getResult
|
|
3872
|
-
};
|
|
3873
|
-
}
|
|
3874
|
-
|
|
3875
|
-
// src/embedding/output/OpenAiEmbedding.ts
|
|
3876
|
-
function OpenAiEmbedding(result, config) {
|
|
3877
|
-
const __result = deepClone(result);
|
|
3878
|
-
const model = __result.model || config.model || "openai.unknown";
|
|
3879
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3880
|
-
const results = result?.data || [];
|
|
3881
|
-
const embedding = results.map((a) => a.embedding);
|
|
3882
|
-
const usage = {
|
|
3883
|
-
output_tokens: 0,
|
|
3884
|
-
input_tokens: result?.usage?.prompt_tokens,
|
|
3885
|
-
total_tokens: result?.usage?.total_tokens
|
|
3886
|
-
};
|
|
3887
|
-
return BaseEmbeddingOutput({
|
|
3888
|
-
model,
|
|
3889
|
-
created,
|
|
3890
|
-
usage,
|
|
3891
|
-
embedding
|
|
3892
|
-
});
|
|
3893
|
-
}
|
|
3894
|
-
|
|
3895
|
-
// src/embedding/output/AmazonTitan.ts
|
|
3896
|
-
function AmazonTitanEmbedding(result, config) {
|
|
3897
|
-
const __result = deepClone(result);
|
|
3898
|
-
const model = config.model || "amazon.unknown";
|
|
3899
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3900
|
-
const embedding = [__result.embedding];
|
|
3901
|
-
const usage = {
|
|
3902
|
-
output_tokens: 0,
|
|
3903
|
-
input_tokens: __result.inputTextTokenCount,
|
|
3904
|
-
total_tokens: __result.inputTextTokenCount
|
|
3905
|
-
};
|
|
3906
|
-
return BaseEmbeddingOutput({
|
|
3907
|
-
model,
|
|
3908
|
-
created,
|
|
3909
|
-
usage,
|
|
3910
|
-
embedding
|
|
3911
|
-
});
|
|
3912
|
-
}
|
|
3913
|
-
|
|
3914
|
-
// src/embedding/output/CohereBedrockEmbedding.ts
|
|
3915
|
-
function CohereBedrockEmbedding(result, config) {
|
|
3916
|
-
const __result = deepClone(result);
|
|
3917
|
-
const model = config.model || "cohere.unknown";
|
|
3918
|
-
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
3919
|
-
const embedding = Array.isArray(__result.embeddings) ? __result.embeddings : [];
|
|
3920
|
-
const usage = {
|
|
3921
|
-
output_tokens: 0,
|
|
3922
|
-
input_tokens: 0,
|
|
3923
|
-
total_tokens: 0
|
|
3924
|
-
};
|
|
3925
|
-
return BaseEmbeddingOutput({
|
|
3926
|
-
id: __result.id,
|
|
3927
|
-
model,
|
|
3928
|
-
created,
|
|
3929
|
-
usage,
|
|
3930
|
-
embedding
|
|
3931
|
-
});
|
|
3932
|
-
}
|
|
3933
|
-
|
|
3934
3843
|
// src/embedding/config.ts
|
|
3935
3844
|
var embeddingConfigs = {
|
|
3936
3845
|
"openai.embedding.v1": {
|
|
@@ -3962,8 +3871,7 @@ var embeddingConfigs = {
|
|
|
3962
3871
|
encodingFormat: {
|
|
3963
3872
|
key: "encoding_format"
|
|
3964
3873
|
}
|
|
3965
|
-
}
|
|
3966
|
-
transformResponse: OpenAiEmbedding
|
|
3874
|
+
}
|
|
3967
3875
|
},
|
|
3968
3876
|
"amazon.embedding.v1": {
|
|
3969
3877
|
key: "amazon.embedding.v1",
|
|
@@ -3990,8 +3898,7 @@ var embeddingConfigs = {
|
|
|
3990
3898
|
dimensions: {
|
|
3991
3899
|
key: "dimensions"
|
|
3992
3900
|
}
|
|
3993
|
-
}
|
|
3994
|
-
transformResponse: AmazonTitanEmbedding
|
|
3901
|
+
}
|
|
3995
3902
|
},
|
|
3996
3903
|
"amazon:cohere.embedding.v1": {
|
|
3997
3904
|
key: "amazon:cohere.embedding.v1",
|
|
@@ -4025,10 +3932,25 @@ var embeddingConfigs = {
|
|
|
4025
3932
|
key: "truncate"
|
|
4026
3933
|
},
|
|
4027
3934
|
dimensions: {
|
|
4028
|
-
key: "output_dimension"
|
|
3935
|
+
key: "output_dimension",
|
|
3936
|
+
// Embed v3 has a fixed 1024-dim output and rejects the output_dimension
|
|
3937
|
+
// field entirely — even when the value matches. Drop the field for v3
|
|
3938
|
+
// when the user asked for the natural 1024; throw for any other value
|
|
3939
|
+
// so we don't silently mutate user intent.
|
|
3940
|
+
transform: (value, state) => {
|
|
3941
|
+
if (typeof value === "undefined") return void 0;
|
|
3942
|
+
const model = state?.model || "";
|
|
3943
|
+
const isV3 = /embed-(english|multilingual)-v3/.test(model);
|
|
3944
|
+
if (isV3) {
|
|
3945
|
+
if (value === 1024) return void 0;
|
|
3946
|
+
throw new Error(
|
|
3947
|
+
`Cohere Embed v3 only supports 1024-dimensional output (model: "${model}", requested: ${value}). Use cohere.embed-v4:0 for configurable dimensions.`
|
|
3948
|
+
);
|
|
3949
|
+
}
|
|
3950
|
+
return value;
|
|
3951
|
+
}
|
|
4029
3952
|
}
|
|
4030
|
-
}
|
|
4031
|
-
transformResponse: CohereBedrockEmbedding
|
|
3953
|
+
}
|
|
4032
3954
|
}
|
|
4033
3955
|
};
|
|
4034
3956
|
function getEmbeddingConfig(provider) {
|
|
@@ -4042,6 +3964,97 @@ function getEmbeddingConfig(provider) {
|
|
|
4042
3964
|
throw new Error(`Invalid provider: ${provider}`);
|
|
4043
3965
|
}
|
|
4044
3966
|
|
|
3967
|
+
// src/embedding/output/BaseEmbeddingOutput.ts
|
|
3968
|
+
function BaseEmbeddingOutput(result) {
|
|
3969
|
+
const __result = Object.freeze({
|
|
3970
|
+
id: result.id || uuidv4(),
|
|
3971
|
+
model: result.model,
|
|
3972
|
+
usage: result.usage,
|
|
3973
|
+
embedding: [...result?.embedding || []],
|
|
3974
|
+
created: result?.created || (/* @__PURE__ */ new Date()).getTime()
|
|
3975
|
+
});
|
|
3976
|
+
function getResult() {
|
|
3977
|
+
return {
|
|
3978
|
+
id: __result.id,
|
|
3979
|
+
model: __result.model,
|
|
3980
|
+
created: __result.created,
|
|
3981
|
+
usage: __result.usage,
|
|
3982
|
+
embedding: __result.embedding
|
|
3983
|
+
};
|
|
3984
|
+
}
|
|
3985
|
+
function getEmbedding(index) {
|
|
3986
|
+
if (index && index > 0) {
|
|
3987
|
+
const arr = __result?.embedding;
|
|
3988
|
+
const val = arr[index];
|
|
3989
|
+
return val ? val : [];
|
|
3990
|
+
}
|
|
3991
|
+
return __result.embedding[0];
|
|
3992
|
+
}
|
|
3993
|
+
return {
|
|
3994
|
+
getEmbedding,
|
|
3995
|
+
getResult
|
|
3996
|
+
};
|
|
3997
|
+
}
|
|
3998
|
+
|
|
3999
|
+
// src/embedding/output/AmazonTitan.ts
|
|
4000
|
+
function AmazonTitanEmbedding(result, config) {
|
|
4001
|
+
const __result = deepClone(result);
|
|
4002
|
+
const model = config.model || "amazon.unknown";
|
|
4003
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4004
|
+
const embedding = [__result.embedding];
|
|
4005
|
+
const usage = {
|
|
4006
|
+
output_tokens: 0,
|
|
4007
|
+
input_tokens: __result.inputTextTokenCount,
|
|
4008
|
+
total_tokens: __result.inputTextTokenCount
|
|
4009
|
+
};
|
|
4010
|
+
return BaseEmbeddingOutput({
|
|
4011
|
+
model,
|
|
4012
|
+
created,
|
|
4013
|
+
usage,
|
|
4014
|
+
embedding
|
|
4015
|
+
});
|
|
4016
|
+
}
|
|
4017
|
+
|
|
4018
|
+
// src/embedding/output/CohereBedrockEmbedding.ts
|
|
4019
|
+
function CohereBedrockEmbedding(result, config) {
|
|
4020
|
+
const __result = deepClone(result);
|
|
4021
|
+
const model = config.model || "cohere.unknown";
|
|
4022
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4023
|
+
const embedding = Array.isArray(__result.embeddings) ? __result.embeddings : [];
|
|
4024
|
+
const usage = {
|
|
4025
|
+
output_tokens: 0,
|
|
4026
|
+
input_tokens: 0,
|
|
4027
|
+
total_tokens: 0
|
|
4028
|
+
};
|
|
4029
|
+
return BaseEmbeddingOutput({
|
|
4030
|
+
id: __result.id,
|
|
4031
|
+
model,
|
|
4032
|
+
created,
|
|
4033
|
+
usage,
|
|
4034
|
+
embedding
|
|
4035
|
+
});
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
// src/embedding/output/OpenAiEmbedding.ts
|
|
4039
|
+
function OpenAiEmbedding(result, config) {
|
|
4040
|
+
const __result = deepClone(result);
|
|
4041
|
+
const model = __result.model || config.model || "openai.unknown";
|
|
4042
|
+
const created = (/* @__PURE__ */ new Date()).getTime();
|
|
4043
|
+
const results = result?.data || [];
|
|
4044
|
+
const embedding = results.map((a) => a.embedding);
|
|
4045
|
+
const usage = {
|
|
4046
|
+
output_tokens: 0,
|
|
4047
|
+
input_tokens: result?.usage?.prompt_tokens,
|
|
4048
|
+
total_tokens: result?.usage?.total_tokens
|
|
4049
|
+
};
|
|
4050
|
+
return BaseEmbeddingOutput({
|
|
4051
|
+
model,
|
|
4052
|
+
created,
|
|
4053
|
+
usage,
|
|
4054
|
+
embedding
|
|
4055
|
+
});
|
|
4056
|
+
}
|
|
4057
|
+
|
|
4045
4058
|
// src/embedding/output/getEmbeddingOutputParser.ts
|
|
4046
4059
|
function getEmbeddingOutputParser(config, response) {
|
|
4047
4060
|
switch (config.key) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "llm-exe",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.9",
|
|
4
4
|
"description": "Simplify building LLM-powered apps with easy-to-use base components, supporting text and chat-based prompts with handlebars template engine, output parsers, and flexible function calling capabilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
},
|
|
96
96
|
"repository": {
|
|
97
97
|
"type": "git",
|
|
98
|
-
"url": "https://github.com/
|
|
98
|
+
"url": "https://github.com/llm-exe/llm-exe"
|
|
99
99
|
},
|
|
100
100
|
"homepage": "https://llm-exe.com"
|
|
101
101
|
}
|
package/readme.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# llm-exe
|
|
2
2
|
|
|
3
|
-
[](https://github.com/llm-exe/llm-exe/actions/workflows/tests.yml) [](https://coveralls.io/github/llm-exe/llm-exe?branch=main) [](https://badge.fury.io/js/llm-exe)
|
|
4
4
|
|
|
5
5
|
A package that provides simplified base components to make building and maintaining LLM-powered applications easier.
|
|
6
6
|
|