- Use AI models in terminal, VSCode and Obsidian locally, free and without a connection
This is a simple api that runs locally and can be used to run ai models locally without internet connection and for free. It uses Hugging Face transformers library to load the models and FastAPI to serve the api. It also uses Docker to run the api in a container.
- Docker
- Docker-compose
- Make
Wont demonize the process, so you can see the logs (Also debug mode is on)
make start
This will take a while to download the models for the first time. Wait until this is done before making a request.
make get_models
Give it a few seconds to stop the container and start it again.
make restart
That will take a while to load the model for the first time
make test
- Zsh
- Oh-my-zsh
- Python3
cp -r zsh-local-ai ~/.oh-my-zsh/custom/plugins/
Where plugins=() add zsh-local-ai to the list Add a key binding to create_completion function
......
plugins=(....... zsh-local-ai .......)
bindkey '^X' create_completion
source ~/.zshrc
Start typing the command or a comment and press ctrl+x to get the completion. Then press enter to run the command.
- VS Code
- Continue - Claude, CodeLlama, GPT-4, and more extension
Download and install VSCode, then from the extensions search and install the Continue plugin.
-
At you vscode Toolbar click on the new Continue icon, then click on the gear icon at the bottom right to open the settings.
-
In the models array add the following first
{
"title": "Monday AI",
"provider": "openai",
"model": "gpt4all-j",
"apiBase": "http://localhost:8085/v1/"
},
- Replace the "tabAutocompleteModel" Object with the following
"tabAutocompleteModel": {
"title": "Tab Autocomplete Model",
"provider": "openai",
"model": "gpt4all-j",
"apiBase": "http://localhost:8085/v1/"
},
"tabAutocompleteOptions": {
"useCopyBuffer": false,
"maxPromptTokens": 400,
"prefixPercentage": 0.5,
"debounceDelay": 2000
},
Save the config and now you can chat with Monday in the continue chat and use it as autocompletion..... it is slow and depends on your setup
- Obsidian
- Text Generator plugin
You can find obsidian here. In the settings, go to community plugins and install text generator.
-
In the settings under community plugins settings, select text generator. Then in LLM Providers select Custom and add the url of the local api. This will be
http://localhost:8085/v1/chat/completions
. -
Toggle advance mode and in Header section remove the bearer token header. Headers should look like that:
{
"Content-Type": "application/json",
}
-
In the Variables section, change the model to be
gpt4all-j
-
Lastly, enable CORS Bypass.
Now you can use the text generator plugin to generate text in your notes.