cohere-ai / cohere-typescript

The Cohere TypeScript SDK
https://docs.cohere.ai
MIT License
127 stars 18 forks source link

v7.12.0 contains breaking change due to extraneous /v1/ segment in URL #195

Closed mtharrison closed 3 months ago

mtharrison commented 3 months ago

Here is code that worked < v7.12.0:

import { CohereClient } from "cohere-ai";

const cohere = new CohereClient({
  environment: "https://api.cohere.com/v1",
  token: "...",
});

const main = async () => {
  const rerank = await cohere.rerank({
    documents: [{ text: "a white hat" }, { text: "and old trinket" }],
    query: "a gray blouse",
    topN: 2,
    model: "rerank-multilingual-v3.0",
  });

  console.log(rerank);
};

main();

= v7.12.0 this throws the following error:

NotFoundError: NotFoundError
Status code: 404
Body: {
"ok": false,
"error": {
"reason": "non-json",
"statusCode": 404,
"rawBody": "404 page not found\n"
}
}
at CohereClient.<anonymous> ([...]/Desktop/reranker-test/node_modules/cohere-ai/Client.js:811:31)
at Generator.next (<anonymous>)
at fulfilled ([...]//Desktop/reranker-test/node_modules/cohere-ai/Client.js:31:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
statusCode: 404,
body: {
ok: false,
error: {
reason: 'non-json',
statusCode: 404,
rawBody: '404 page not found\n'
}
}
}

The reason is that this latest version appends an additional v1 segment to the URL path which is unexpected by your API.

billytrend-cohere commented 3 months ago

hey @mtharrison thanks for flagging this, will fix asap

billytrend-cohere commented 3 months ago

got a fix here which is backward and forward compatible https://github.com/cohere-ai/cohere-typescript/pull/196

mtharrison commented 3 months ago

Ok great, I'll test on my end too.

mtharrison commented 3 months ago

The fix looks good to me, are you making a release?

billytrend-cohere commented 3 months ago

yeah just released 7.12.1, should be available shortly. Thanks for reporting this!!