There is a ChatGPT API tranform action. This requires web access and potential privacy violations etc.
GPT4All (nomic.ai) offers a free local app with multiple open source LLM model options optimised to run on a laptop. It has an API server that runs locally, and so BTT could use that API in a manner similar to the existing ChatGPT action without any privacy concerns etc. That would be really great!
I haven't looked at GPT4all yet, but it's probably easy to integrate using a slightly adapted Java Script like described here: folivora.ai - Great Tools for your Mac! (the inline & java script section)
If you know some Java Script, have a look! I'll also try to install it, but probably won't get to it until end of next week.
It apparently supports the OpenAI API with a single change of the URL:
GPT4All Chat comes with a built-in server mode allowing you to programmatically interact with any supported local LLM through a very familiar HTTP API. You can find the API documentation here.
Enabling server mode in the chat client will spin-up on an HTTP server running on localhost port 4891 (the reverse of 1984). You can enable the webserver via GPT4All Chat > Settings > Enable web server.
It also supports curl like this (I assume this is OpenAI compliant, though I never used their API):
curl -X POST http://localhost:4891/v1/completions -H "Content-Type: application/json" -H "Authorization: Bearer NO_API_KEY" -d "{\"model\": \"mistral-7b-instruct-v0.
1.Q4_0.gguf\", \"prompt\": \"How can I use curl to POST to a local API?\", \"temperature\": 0.7, \"max_tokens\": 200, \"top_p\": 0.95, \"n\": 1, \"stream\": false}"
You specify the model you downloaded and the prompt. Returns JSON. This therefore seems very promising that the action you already developed for OpenAI could easily support a local inference option for anyone who installs this free and open source tool.
I'll have a look at the javascript solution in the meantime. Thank you as always for such an amazing tool!!!!!
Great, the Javascript is basically working, brilliant thank you!!!!!!!!!
It seems GPT4All needs those parameters, I get something very truncated answers back
Q: How can I use curl to POST to a local API?
A: To make a POST request using cURL on the command line, you will
Exactly like this curl request:
curl http://localhost:4891/v1/completions -H "Content-Type: application/json" -H "Authorization: Bearer NO_API_KEY" -d "{\"model\": \"mistral-7b-instruct-v0.1.Q4_0.g
guf\", \"prompt\": \"How can I use curl to POST to a local API?\"}"
{"choices":[{"finish_reason":"length","index":0,"logprobs":null,"references":[],"text":"To make a POST request using cURL on the command line, you will"}],"created":1708596439,"id":"foobarbaz","model":"Mistral Instruct","object":"text_completion","usage":{"completion_tokens":16,"prompt_tokens":22,"total_tokens":38}}
As it is local we don't need to worry about token limits etc.
So this is just a tweak of the javascript that generates the body, so totally totally cool!!!!
I think there are some typos in the javascript from that article, there are ` in a couple of places that I think should be " lines start Authorisation and return
There is a second local app that uses the same model formats as GPT4All, and also supports the same API (you need to configure LMStudio to use port 8941):
You can swap from LMStudio to GPT4All and BTT's javascript action works well both tools. LMStudio has a slightly more powerful GUI, and for example exposes the local server logs so you can see the GPT model working as you run the BTT action. It uses the model specified in the GUI and ignores the model JSON that GPT4All uses. As both tools use the same models, you can symlink the models and only download a model once. I've tested with Googles latest model Gemma, Microsoft's Phi and Mistral Instruct — this is the strong advantage of a local LLM tool, freedom, privacy and flexibility with no financial cost.
For BTT, by changing the BEHAVIOR_DESCRIPTION prompt, you can set up different actions. I have a Technical Support action that answers technical questions, and another that acts as an AI Writing Editor to clarify english text. Then bind to hyper+ 1 and hyper+ 2 and both AIs are a keypress away in any app. You could create different "personas" (William Shakespeare, Friedrich Wilhelm Nietzsche etc.) and use BTT to manage each.