Ollama is a project that lets you run models locally, but you can also create an api that can be connected to across your local network. This is how I got it running on a debian box.
Follow the directions on the site to install ollama. They are clear.
But then you have to update a few things. Open a terminal and type the following:
sudo su
Use the editor of your choice if you don't like vi. Change the text to to match the following, replacing 'yourusername' with your own username in both User and Group. I had to do this so it would save models in my own home folder. My root folder was tiny but my home folder is huge. Then add 'Environment="OLLAMA_HOST=0.0.0.0"' line so that the server will listen for network connections on the local network.vi /etc/systemd/system/ollama.service
Then save the file. Once that is done you have to restart the service. Type the following:[Unit]
Description=Ollama Service
After=network-online.target
[Service]
ExecStart=/usr/local/bin/ollama serve
User=yourusername
Group=yourusername
Restart=always
RestartSec=3
Environment="OLLAMA_HOST=0.0.0.0"
[Install]
WantedBy=default.target
systemctl daemon-reload
systemctl enable ollamasystemctl status ollama
exit
ollama pull model_name
ollama list
NAME ID SIZE MODIFIED
zephyr:latest bbe38b81adec 4.1 GB 23 hours ago
So for me to run ollama with a model I have to say:
ollama run zephr:latest
ryzen7mini:~$ ollama run zephyr:latest
>>> hello
Hello, how may I assist you today? Please let me know if you have any questions or requests. Thank you for
choosing our service! If you're just saying hello, I'm glad to hear that you're here and welcome to our
community! Let us know if we can help you with anything else. Have a great day ahead!
>>> /bye
And you can access the web api with shell scripts:
#!/bin/sh
curl http://192.168.1.179:11434/api/generate -d '
{
"model": "zephyr:latest",
"prompt": "Why is the blue sky blue?",
"stream": false,
"options":{
"num_thread": 8,
"num_ctx": 2024
}
}'
And you can tie visual studio code to the web api:
That is using the codellm extension. I just searched for ollama and it was halfway down the first page of the list.
And this is how I configured it:
I want to add another layer to ollama to add RAG and Agents to improve the models and add functions. I also want to learn how to script these models with a python ollama library.
No comments:
Post a Comment