cohere-ai / cohere-typescript

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

Using "cohere-ai": "^5.0.2" in NodeJS, I'm getting an unexpected response from the classify endpoint #70

Closed netpoe closed 10 months ago

netpoe commented 1 year ago

Using "cohere-ai": "^5.0.2" in NodeJS, I'm getting an unexpected response from the classify endpoint:

{
  statusCode: 404,
  body: {
    message: "could not find preset by the ID of 60a0705a-5231-4d4a-b62f-...",
  },
}

I've tried several combinations (see attachments) to send the data by specifying a model, but I get typescript errors:

error TS2345: Argument of type '{ model: string; inputs: string[]; }' is not assignable to parameter of type 'classifyRequest'.
  Property 'preset' is missing in type '{ model: string; inputs: string[]; }' but required in type 'classifyWithPresetRequest'.

This is the data being sent:

{
  model: "60a0705a-5231-4d4a-b62f-...",
  inputs: [
    "crear wallet mxn",
  ],
  preset: "60a0705a-5231-4d4a-b62f-...",
}

By testing in https://docs.cohere.ai/reference/classify, I do get the expected results with almost the same args and the API Call even excludes preset.

Screen Shot 2023-02-17 at 10 13 18 Screen Shot 2023-02-17 at 10 13 07 Screen Shot 2023-02-17 at 10 07 56 Screen Shot 2023-02-17 at 10 03 03 Screen Shot 2023-02-17 at 10 01 47 Screen Shot 2023-02-17 at 10 01 41
netpoe commented 1 year ago

I did a hack:

const response = await cohere.client.classify({
        model: "60a0705a-5231-4d4a-b62f-8be55def74a5-ft",
        inputs: [input],
      });

And was able to get a 200 by extending the model:

interface classifyWithModelRequest extends classifyBaseRequest {
}

export type classifyRequest =
  | classifyWithInputsRequest
  | classifyWithPresetRequest
  | classifyWithModelRequest;
dsinghvi commented 10 months ago

@netpoe The updated ClassifyRequest now has an optional preset!