Cohere: Update embeddings to v2 #2962
| @@ -17,7 +17,7 @@ async function getCohereBatchVector(texts, isQuery, directories, model) { | ||
| 17 | 17 | throw new Error('No API key found'); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | const response = await fetch('https://api.cohere.ai/v1v2/embed', { |
| 21 | 21 | method: 'POST', |
| 22 | 22 | headers: { |
| 23 | 23 | 'Content-Type': 'application/json', |
| @@ -26,6 +26,7 @@ async function getCohereBatchVector(texts, isQuery, directories, model) { | ||
| 26 | 26 | body: JSON.stringify({ |
| 27 | 27 | texts: texts, |
| 28 | 28 | model: model, |
| 29 | + embedding_types: ['float'], | |
| 29 | 30 | input_type: isQuery ? 'search_query' : 'search_document', |
| 30 | 31 | truncate: 'END', |
| 31 | 32 | }), |
| @@ -38,12 +39,12 @@ async function getCohereBatchVector(texts, isQuery, directories, model) { | ||
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | const data = await response.json(); |
| 41 | 42 | if (!Array.isArray(data?.embeddings?.float)) { |
| 42 | 43 | console.log('API response was not an array'); |
| 43 | 44 | throw new Error('API response was not an array'); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | return data.embeddings.float; |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | 50 | /** |