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

Provide a type-safe way to call generate without a prompt (to pre-load a model) #162

Open
hopperelec opened this issue Nov 11, 2024 · 0 comments

Comments

@hopperelec
Copy link
Contributor

From the Ollama docs, "If an empty prompt is provided [to the generate endpoint], the model will be loaded into memory.". This is useful so that, for example, the user can be shown that the model is loading, and the user can continue to edit their prompt before a response actually starts being generated.

Technically, this could be solved by just making the prompt attribute of the GenerateRequest interface, shown below, optional

prompt: string

However, I think it would be sensible for there to be a dedicated function, probably of the below form

async loadModel(model: string): Promise<ProgressResponse>`) { ... }

This way, it is clearer why the prompt argument is optional (since someone might assume it would behave the same as providing an empty string as the prompt), and so that it is clear that none of the other attributes for GenerateRequest will have an effect when doing this.

But, because I understand that ollama-js is generally supposed to be 1:1 with the actual API, I want to get some feedback on this first before I file a PR.

@hopperelec hopperelec changed the title Provide a type-safe way to generate from an empty prompt (to pre-load a model) Provide a type-safe way to call generate without a prompt (to pre-load a model) Nov 11, 2024
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