Skip to content

Commit b8d0ba5

Browse files
authored
Merge pull request #1213 from narengogi/fix/cohere-embed-handle-null-encoding-format
Fix/cohere embed handle null encoding format
2 parents 09dcc86 + 542d4ac commit b8d0ba5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/providers/bedrock/embed.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ export const BedrockCohereEmbedConfig: ProviderConfig = {
5252
encoding_format: {
5353
param: 'embedding_types',
5454
required: false,
55-
transform: (params: any): string[] => {
55+
transform: (params: any): string[] | undefined => {
5656
if (Array.isArray(params.encoding_format)) return params.encoding_format;
57-
return [params.encoding_format];
57+
else if (typeof params.encoding_format === 'string')
58+
return [params.encoding_format];
5859
},
5960
},
6061
};
@@ -115,9 +116,10 @@ export const BedrockTitanEmbedConfig: ProviderConfig = {
115116
encoding_format: {
116117
param: 'embeddingTypes',
117118
required: false,
118-
transform: (params: any): string[] => {
119+
transform: (params: any): string[] | undefined => {
119120
if (Array.isArray(params.encoding_format)) return params.encoding_format;
120-
return [params.encoding_format];
121+
else if (typeof params.encoding_format === 'string')
122+
return [params.encoding_format];
121123
},
122124
},
123125
// Titan specific parameters

src/providers/cohere/embed.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ export const CohereEmbedConfig: ProviderConfig = {
5050
encoding_format: {
5151
param: 'embedding_types',
5252
required: false,
53-
transform: (params: any): string[] => {
53+
transform: (params: any): string[] | undefined => {
5454
if (Array.isArray(params.encoding_format)) return params.encoding_format;
55-
return [params.encoding_format];
55+
else if (typeof params.encoding_format === 'string')
56+
return [params.encoding_format];
5657
},
5758
},
5859
//backwards compatibility

0 commit comments

Comments
 (0)