Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different interfaces for an un-streamed "streamable" response, a streamed response and the final (done) response from a stream #96

Open
hopperelec opened this issue May 25, 2024 · 0 comments

Comments

@hopperelec
Copy link
Contributor

hopperelec commented May 25, 2024

While using ollama-js, I've found myself referring to the Ollama API docs to see exactly when certain fields are provided in the response, but I believe ollama-js should be aiming to abstract away the API. Currently, the types for optional fields aren't actually optional. While documentation on the response interfaces would help with this, I think it would be even better if they were treated as different types of responses altogether.

There's three ways I think the final response could be handled

  • Alongside Streamable requests should return an iterable class containing their own AbortController and corresponding abort method #95, these responses could be taken using different parts of that class
  • done could be an object instead of a boolean, where the object contains all the fields which are only accessible when done is truthy. This would still allow for if (done), since objects are considered truthy and undefined is not. This would require restructuring the response received from the API, though.
  • Using a type along the lines of partField & ({ done: false} | { done: true, ... ). This would not require any changes outside of the interface
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant