cohere-ai / cohere-typescript

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

fix the length of the content being sent with http requests #27

Closed kravse closed 2 years ago

kravse commented 2 years ago

Resolves #25.

Looks like the content length of the string was not correctly matching with utf-8 encodings when special characters were involved.

I set a slightly stricter utf-8 encoding to the Content-Type, req.write() and use Buffer.byteLength for length rather than just javascripts length

Should work with characters like now.