-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
Add Ollama #646
Add Ollama #646
Conversation
I guess it would also be fine to have it as a custom model provider in a separate package, if we don't want to maintain it here in this repo. |
Jeremy, thank you very much for working on this PR and for keeping up with the open source LLM ecosystem. I lack the time to engage there as much as I would like. Let me know when this PR is ready, and I will approve & merge it once I run it locally. 👍 |
Looking forward to this integration. |
Thanks @dlqqq and @lalanikarim! Yeah I'll try to finish the PR soon. It was originally opened early to see if there was interest to have built-in support for Ollama in
Currently jupyter-ai/packages/jupyter-ai/jupyter_ai/extension.py Lines 61 to 75 in 642ac53
Although not sure if that would be enough to use models that have not been added to the list of models in |
🙇 @jtpio excited for this |
@lalanikarim - I am also replicating a similar setup. Just curious are you able to use the /learn, /generate commands in the chat |
I haven't had any luck with
I haven't tried |
@jtpio I am wondering if it would make sense to provide model name in a free form text field for Ollama models and to require %%ai magic code to include model name for ollama models and limit models to a predefined list.
Thoughts? |
Yeah I guess given the number of available models it would be very difficult to pick just a few here in the So yes having a way to let users configure the list of models sounds like a good idea. |
Hi, Thanks for the hack. Its working. But curious.. how/what did you set the OPENAI API key ? Its working inside the chat box (Jupyternaut), but not inside the jupyter notebook. and its asking for OPEN_API_KEY. can u pl help ? |
Anything update on this pr for adding ollama to jupyter ai.. |
I'll try to finish this PR soon, and provide a way to configure the list of models (+ docs). |
@jtpio: Thank you for this ollama integration Jeremy! Also look forward to configurable models. Let me know where I can buy you a coffee. |
@siliconberry You can put any value for OPANAI_API_KEY. It is needed for this hack to work but will be ignored by ollama. |
@lalanikarim in answer to @siliconberry question, have you gotten both the chat/jupyternaut as well as notebook cell (ie magic %%ai) working with ollama? I’m struggling now to get notebook working. When I set the OPENAI_API_KEY environment variable to a dummy key (sk-abcd1234), the notebook gives an error indicating that ChatGPT doesn’t accept the key. Jupyternaut chat works fine. It seems like either jupyter_ai’s notebook is not using the config.json like Jupyternaut or ollama does not support all ChatGPT api…? Idk, maybe I’m missing something |
Nevermind @lalanikarim @siliconberry. The magic %%ai does work. Note: The magic doesn’t use the config.json but uses environment vars for key and url. |
Just joining the chorus of folks who would be excited to see this, especially given the rate at which new open-weights models are regularly appearing for ollama (llama3, phi3, wizardlm2). ollama's use of local GPU seems a lot smoother too than gpt4all too. |
I'm so excited for this! 😍😍😍 |
any updates? |
Thanks @srdas for the heads-up 👍 Looks like #868 lists more models, so we could continue with this PR instead of this one. But it would still be interesting for end users to have a way to configure the models, to avoid having to update Jupyter AI and make a new release each time there is a new model out there. |
Thanks @jtpio -- let me test the new PR locally and also summarize what remains from what you have proposed. The drop down list is becoming really long so keeping on adding new models at the pace they are being included in Ollama may not be ideal both from a maintenance point of view and from an interface one. It may be preferable to handle Ollama in the way HuggingFace models are treated in the drop-down listing, which may address your note above. |
@jtpio Thank you for checking in on this again! Since your PR does not duplicate the LangChain provider implementation and is older than #868, I think this PR (#646) should take precedence. Here are the next steps towards getting this merged:
Let me know if you need assistance! |
@jtpio I agree! This should probably be done in a future PR however, as it is a broader change that is not strictly necessary for Ollama support in Jupyter AI. |
697cf70
to
bfb036a
Compare
@jtpio Awesome - the changes are working nicey. I tested it on the new embedding model list and it all seems to be working well. |
Co-authored-by: Bc <[email protected]>
Co-authored-by: Piyush Jain <[email protected]> Co-authored-by: david qiu <[email protected]>
### Ollama usage | ||
|
||
To get started, follow the instructions on the [Ollama website](https://ollama.com/) to set up `ollama` and download the models locally. To select a model, enter the model name in the settings panel, for example `deepseek-coder-v2`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Ollama
capitalized in line 362 in "... to set up ollama
... "
Suggest adding a few more notes to the docs as follows:
Once Ollama
is installed, download the model using the following command in a terminal:
ollama pull <model_name>
For example: ollama pull llama3
. Do this for both LLM models and embedding models, as many as needed.
Once the models are downloaded, start up the Ollama
server:
ollama serve
The models will then be available in jupyter-ai
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, but wouldn't block on this to merge. Also, this info can change based on ollama
API, so we will be carrying instructions that are available in their docs and will have to update in case this changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3coins Agree. I tested it again and it's all working so merging is predicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the code to enable model choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtpio
Looks great!
Thanks all for the reviews and the merge! |
@pedrogutobjj - it is working at my end. Did you enable Inline completion in settings? |
my configs @srdas |
@srdas Another question, if I enable the "Whether to fetch completions History provider." It doesn't provide suggestions for models, it provides suggestions for what I've used on other notebooks in the past. |
You can use any model - I just used the instruct model as I could not find the version you are using on https://ollama.com/search. It shows this: I have to look into your second question some more. |
This happens when I activate the Whether to fetch completions History provider option, it brings codes that I have already used in the past, it has nothing to do with the model indications, as you mentioned in your post. |
* Add Ollama * mistral:text for embeddings * Add gemma * Update the list of models Co-authored-by: Bc <[email protected]> * Mention Ollama in the docs * Apply suggestions from code review Co-authored-by: Piyush Jain <[email protected]> Co-authored-by: david qiu <[email protected]> --------- Co-authored-by: Bc <[email protected]> Co-authored-by: Piyush Jain <[email protected]> Co-authored-by: david qiu <[email protected]>
Fixes #482
Ollama seems to be getting popular for running models locally, and looks like it would be good to have in Jupyter AI by default.
OllamaProvider
OllamaEmbeddingsProvider