Chainlit / literalai-typescript

https://docs.literalai.com
Apache License 2.0
4 stars 0 forks source link

fix(types): getXXX methods return instances #38

Closed Dam-Buty closed 2 months ago

linear[bot] commented 2 months ago
ENG-1585 TS SDK : getXXX methods should return instances

There are some inconsistencies in there, for example : * `getStep` is typed as returning a `Step` , but in fact it returns a plain object of shape `StepFields` * `getThread` is typed as returning `any`, returns a `ThreadFields` object * there are probably more inconsistencies The fact that these methods don't return actionable instances (with the `.send` method, etc…) is a bit of a missed opportunity. In scenarios where you want to work on an already created entity, you have to do [that little dance](https://github.com/Chainlit/literal-cookbook/blob/main/typescript/speech-to-emoji/with-literal/src/app/api/emojify/route.ts#L28-L33) which is annoying. # Dod * types are fixed * entities are instantiated as their respective class * this is non-breaking for existing project which might already do the little dance. Basically just check that re-instantiating an instance is okay.