@@ -7,15 +7,16 @@ class CohereEmbedder {
77 this . className = "CohereEmbedder" ;
88
99 // Cohere exposes an OpenAI-compatible API which lets us reuse the OpenAI SDK
10- // across the app instead of the cohere-ai package. https://docs.cohere.com/docs/compatibility-api
10+ // across the app instead of the cohere-ai package. The compatibility endpoint
11+ // manages the embedding `input_type` internally so we do not set it ourselves.
12+ // https://docs.cohere.com/docs/compatibility-api
1113 const { OpenAI : OpenAIApi } = require ( "openai" ) ;
1214 this . openai = new OpenAIApi ( {
1315 baseURL : "https://api.cohere.ai/compatibility/v1" ,
1416 apiKey : process . env . COHERE_API_KEY ,
1517 } ) ;
1618
1719 this . model = process . env . EMBEDDING_MODEL_PREF || "embed-english-v3.0" ;
18- this . inputType = "search_document" ;
1920
2021 // Limit of how many strings we can process in a single pass to stay with resource or network limits
2122 this . maxConcurrentChunks = 96 ; // Cohere's limit per request is 96
@@ -27,7 +28,6 @@ class CohereEmbedder {
2728 }
2829
2930 async embedTextInput ( textInput ) {
30- this . inputType = "search_query" ;
3131 const result = await this . embedChunks (
3232 Array . isArray ( textInput ) ? textInput : [ textInput ]
3333 ) ;
@@ -36,7 +36,6 @@ class CohereEmbedder {
3636
3737 async embedChunks ( textChunks = [ ] ) {
3838 const embeddingRequests = [ ] ;
39- this . inputType = "search_document" ;
4039 let chunksProcessed = 0 ;
4140
4241 for ( const chunk of toChunks ( textChunks , this . maxConcurrentChunks ) ) {
@@ -46,7 +45,6 @@ class CohereEmbedder {
4645 . create ( {
4746 model : this . model ,
4847 input : chunk ,
49- input_type : this . inputType ,
5048 } )
5149 . then ( ( result ) => {
5250 chunksProcessed += chunk . length ;
0 commit comments