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

Browser support via a separate export (Fixes #25) #47

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

samwillis
Copy link
Contributor

@samwillis samwillis commented Feb 13, 2024

This splits the main Ollama class into a base class which supports browser environments, and a subclass for full Node support. Currently the .create() method is only on the subclass.

To use in the browser:

import ollama from "ollama/browser";

Using in Node not changed at all.

It may be possible to also add support for .create() in the browser too but I haven't investigated much yet.

Fixes #25
Fixes #13

@samwillis samwillis changed the title Browser support via a separate export (Fixes #13 #25) Browser support via a separate export (Fixes #25) Feb 13, 2024
@cdolek
Copy link

cdolek commented Feb 15, 2024

is there a timeline for this? thank you

@BruceMacD
Copy link
Collaborator

BruceMacD commented Feb 16, 2024

Hi @samwillis, thanks for doing this. Do you have any experience with dynamic imports? If possible I'd prefer to use a dynamic import so importing the library looks the same no matter what environment you're in. I'll be taking a look at building dynamic imports on this existing work you have here next week in any case.

Edit: After trying my idea, I now see that this is the correct way to do this.

Copy link
Collaborator

@BruceMacD BruceMacD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this contribution. Merging this now, and then doing some slight tweaks to allow for creating from the browser also.

@BruceMacD BruceMacD merged commit 2aa838c into ollama:main Feb 27, 2024
@samwillis
Copy link
Contributor Author

No worries, sorry I didn't get back to you, been a busy week!

@Dunya-8a
Copy link

@samwillis Could you please expand on the documentation for how to use the browser version? I'm trying to use ollama in a static HTML + JS file setup but the CDN isn't working due to the fs import (see #13).

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

Successfully merging this pull request may close these issues.

allow client-side library use Browser compatible?
4 participants