Home

Awesome

ollama-chats v1.9.10

Ollama chat client in Vue, everything you need to do your private text rpg in browser, with any amount of different characters, rag, per character context and more.

What this is..

This "project" is a single web page desktop interface for chatting with your local Ollama server. It doesn't use any libraries apart from Vue and can be opened in browser as a regular web page.

It looks like this:

image

You can run it just from disk in your browser, if you set an evironment variable or you can run it in a local web-server, like NGINX, Apache, etc. The reason for that is that Ollama's API is done via a local network server, and locally opened web pages (from disk) by default are not allowed to access network resources (for safety reasons), even if it's your local Ollama server. Thus, to make it work you need either to configure Ollama to allow that or to use a local web-server software :).

Why:

when i installed Ollama, i tried its built-in console chat interface but quickly realized it's nowhere enough to have fun, just enough to test the thing..

..then i looked up several existing interfaces and realized (again) that:

  1. these things are either too big
  2. or i'm too lazy to check all the code to ensure they do not send my local chats somewhere
  3. i want to have it my way - that is for desktop and keyboard, not for mobile phones.
  4. i want it to have a convenient keyboard driven interface and no unnecessary whistles.
  5. i want it to use as few 3rd party libraries as possible for security reasons.
  6. fully local, so nothing is uploaded anywhere.
  7. browser based.

And here we are. Whole thing is less than 30KB right now (actually 274KB already+bg image, lol), that's including the excerpts from Ollama documentation, html code and help page. The only imported thing is Vue which is a great web framework, probably used by millions of people, so it's pretty safe.

In other words, this UI is made with paranoia in mind, to prevent any chances of leaking our chats.

You can check the whole code in 30 minutes if you wish, to ensure you are totally safe with it. It's a single file, so no need to wonder by hundreds of separate sources for that.

If you already have a web-server running this thing is a matter of seconds. If you don't, you can install Nginx in some minutes. Hopefully in future we might run it directly with Ollama, but not yet.

Installation:

There is not much to install, it's a single index.html. The file needs to connect to your local Ollama server and you have 2 choices for that:

1. Here is a longer but safe way with a web-server:

If you already have a web-server, there is not much to say, just put "index.html" from this project into any of your web folders, rename it as you wish if needed and access in browser.

if you don't have a web-server, the easiest and the best one is NGINX. I do not have a goal of writing FAQ on NGINX here, there are tons online. So please consult with these. The short installation instruction, tho, is here:

  1. install nginx (on ubuntu it's as easy as: sudo apt install nginx).
  2. create a configuration file "ollama-chats.conf" in its configuration folder, (/etc/nginx/conf.d for linux) The file example is already presented in this project, you can just copy it if you run ollama locally, nothing needs to be changed.
  3. Take care to set all paths to what you have, including the "root" folder to where you want it to be and copy the index.html file from this project there. If you are using ubuntu, nothing needs to be changed in the sample config.
  4. Make sure to set file permissions and file ownership of the index.html and of the root folder according to nginx rules, you can google it for your OS. On ubuntu:
    • copy the index.html from this project to /var/www/html/index.html (root folder in config)
    • in console change the file permissions: sudo chmod 640 /var/www/html/index.html
    • in console change the file permissions: sudo chown "$USER":www-data /var/www/html/index.html
  5. Start nginx (on ubuntu: sudo service nginx restart)
  6. Access http://127.0.0.1/index.html in your browser
  7. If you see some error, like file not found, etc, it means you've misconfigured nginx or file ownership/permissions.
  8. If you configured your web server correctly, that's it. It's probably just 3 minutes.

Also, please note, now the sample configuration file has an example on how to configure Nginx as reverse proxy for Ollama. That is needed if you run Ollama on another computer. In that case you will need to change the IP addresses in the sample config as it's explained there. Check the "nginx-ollama.conf" file. This is the best way to access Ollama remotely, because you can configure access in Nginx. Alternative method of changing "origin" environment headers for Ollama would open it up for anybody on internet, which is probably not what you want.

Alternative web-server written with GO, if you are a GO fan, check this out :). The mod by Farwish is here: https://github.com/farwish/ollama-chats/tree/main/go

it's a way to run the page in GO written web-server, if you like GO and know what you are doing (i.e. can read and trust the GO code), instead of nginx you can take a look at this project. Thanks to Farwish for this :).

2. If you do not wish to install a webserver, here is an INSECURE way to install, NOT RECOMMENDED.

On Ubuntu

You will need to edit ollama.service. i use Nano editor, replace it with what you use:

On Windows:

Features:

Now, let me list the features this thing has:

  1. You can "prompt" the AI and see the replies in a chat form, as we all love. "Enter" button sends the reply, shift+enter allows making a line-break.
  2. You can ask AI for any amount of side-replies (alternative ones), by clicking on the arrow next to the message or simply by clicking "right" arrow on the keyboard. Left arrow works as well). If you have some text typed in your prompt and you are editing it, arrows will not slide replies, obviously, for your convenience, as you may move cursor through the typed text. Same if you are editing something else, like settings.
  3. You can do a similar thing with your own replies. Say, you are in a middle of conversation and you see that AI doesn't like your reply, so you just click "right" arrow next to your own message and it creates a new message. Then you just type in your new prompt, send it and that's it. You get a new "branch" of the conversation. And at that your previous branch is still there and you can return to it at any time.
  4. Under the "left" and "right" arrows for every "turn" of your chat there are numbers. These show how many alternative replies you do have there.
  5. You can travel "up" and "down" the conversation with your arrows easily. It's super convenient when you "chat a story".
  6. You can stop AI reply if it takes too long or if it's obviously wrong. Just hit "Escape" button on your keyboard.
  7. You can see the number of every alternative reply, making it easy to remember which one you liked and return to it if no new ones are good.
  8. You can manually edit any of the messages - both your and AI ones. To do that, just click on the text of a message you wish to edit and that's it, simply edit it in place. But pay attention, there is no way back once you click away from editing. Until then, you can use ctrl+z of your browser to revert things. Once you've edited, there is no more old version anywhere, AI will see only the edited version, you too. So, if there is a minor mistake made by AI in an otherwise perfect answer, it's very easy to fix it and continue having fun. You even can edit the nicks for each message.
  9. You can specify nicknames - yours and of AI. These nicknames are used in prompts for AI, so they are important.
  10. You can rate the messages by clicking -- or ++. This rating can actually be used to instruct the model within chat to try to copy their style. If you have more than ~7 messages it actually makes real big difference, which is very cool. And of course if you are into finetuning, you can save your chat with ratings. Later, on your own, you may extract the dataset from the saved file (with your ratings) and use it in your finetuning project.
  11. When you open the page, it pulls the list of locally available models and adds these to the list. The list is under the prompt text area. You can easily choose the model you wish to get reply from. Yes, you can do it anytime within the chat. So, if your current model provides bad replies at some point, why not to change it to some other model and to go on?
  12. If you do not have any installed models, it will suggest you to pull a model from ollama's library. Note: the page itself does not load anything, it just uses Ollama's functionality, and kindly asks Ollama to download a new model from its safe library. Ollama has that feature.
  13. It can work in two modes, sending messages as a single prompt and as an array of user messages. Models treat these differently, so you can try what fits you the best.
  14. Side messages can use your rating to instruct the model to produce something better. For that just use ctrl+right or right click on an arrow :).
  15. It has white and dark themes. Though the white one is scary :).
  16. You can create characters with totally different "memory" (context). For example, 2 of your characters can do something together and the 3rd character won't know anything about that, poor thing :). This allows a much more interesting roleplays.
  17. You can have separate settings per AI character, which means you can use different temperature etc and even different models for different characters!
  18. You can switch manually controlled character to be AI controlled and vice versa :). So you can make AI to play for the char you used to be, and you instead would continue to play for AI's char. Of course you can do it with any of the charactes in the story. To do that click an up/down arrow icon in the users list at the top-left.
  19. You can automatically try ranges of various model parameters with configurable steps and see how model reacts to these. Find the best parameters to have fun with your model :). To do that click F9 and reada small instruction on using it ;).
  20. You can use RAG to store any amount of memories for characters, both per character and for all of them. You can enable/disable this as you wish, as well as define the amount of relevant memories for characters to "remember" before answering to you :). It also will show you which "memories" were used in the past reply of a character. To use it, just click shift+f4 for knowledge that all characters share or shift+f5 for personal memories of a given character. Then just enter "memories" as paragraphs of text. Size doesn't matter here, you can use any amount of data.
  21. It's possible to upload images for multimodal models, like llava or moondream! They will tell you what's on the image.
  22. Now it has a brilliant character generator! You can generate any personage with any parameters, from evil and creepy one to a saint! And it's going to be much more fun to chat than it is with a simple short or bad written system prompt that you can find in most cards online. Also, it generated memories for the character on any topics, if you use rag (included) you can have even more complicated personalities created!
  23. And many more features :).
  24. Let's talk about lower menu:

12.1. Settings:

Allows you to configure the script itself and Ollama. If the parameter value is left empty, Ollama uses values from its modelfile, or default ones if modelfile doesn't have these. Parameters are applied upon each request, and according to Ollama's docs, they should change the rules on the fly.

12.2. Pull:

You can pull new models easily, just enter model's name from ollama.com/library and that's it. For example: "stablelm2:1.6b-zephyr", or just "stablelm2". Once the download is over, you will return to the main interface. Don't forget to choose the newly pulled model in the models list, it's not done automatically.

12.3. Reload models:

You might install models manually in the console, in that case you can update the list by clicking this button.

12.4. System prompt:

Well, this is an obvious one. It's a system prompt for your model, where you can inform it that its life purpose is being a rose pony. Each AI character has its own separate system prompt.

12.5. Instr:

That's a trick you may use to help AI figure out what you want. It does a very simple thing - it injects one more message on behalf of AI with the text you enter here. So, you should write it from the point of view of the AI's character. For example: "(IMPORTANT!! in my next message, i should remember that i'm in a forest right now!)". That might save some nerve cells during the chat. That message is not added to the chat log and does not disappear on the next turn but injected every time. It's convenient to use it to summarize things for AI as a reminder, so it doesn't loose track.. that much. Of course you can update it during the chat, to reflect what's going on in your RPG. This is as well different for each character.

12.6. Prune:

Sometimes chats grow big.. and there are hundreds of garbage replies you don't care of. If you wish to keep only the current version of your chat, that is, ONLY the replies you can see on your screen when scrolling, then you can click "prune" and everything else will be deleted. Your chat will seem as if all replies were like this from the very first attempt. It's better to save, before doing this.

12.7. Save:

Yes, you can save the chat, if you wish. the page saves everything and sends it to you as a file to download. It's not stored anywhere else. If you know what you are doing, you can always extract the replies and do local finetuning based on your good chats. The page does not provide interface for finetuning, that's something out of the scope of this thing.

12.8. Load:

Yes, again, you can load your old chat with all of the settings from a saved file and continue any time. Of course, if you have saved it earlier :).

12.9. Optimize:

Allows you to automatically try any possible combination of configuration and ollama settings for any models and see the results.

12.10. CH.mem:

Character's memory. Allows you to enter any amount of data for character to rememember, so you are not limited with the context window anymore and you can define a very detailed characters with a lot of information they can remember when appropriate.

12.11. P.knlg:

Public knowledge. Allows you to enter any amount of data for all character to know, so you are not limited with the context window anymore and you can define a lot of world descriptions for characters to remember, when appropriate.

12.12. Gen.Char.:

Character generator. Allows you to easily generate a complicated personality of a new personage in a few steps :).

Enjoy!

Changes (v1.9.10 2024.07.22)

Minor bugfix release.

Changes (v1.9.9 2024.07.16)

A major release

This release took a lot of time and efforts were spread in time, so there might be bugs, even tho i spend a lot of time to test. Take it as beta.

Changes (v.1.9.8b 2024.05.22)

A small bugfix release

Changes (v.1.9.8 2024.05.22)

Major release!

Changes (v.1.9.7 2024.05.09)

Major release

Changes (v.1.9.4 2024.04.27)

Changes (v.1.9.3 2024.04.26)

Changes (v.1.9.2 2024.04.26)

Changes (v.1.9 2024.04.19)

New version v1.9 a huge major release. The changes are vast, so if you catch a bug (or a dozen), let me know :).

Changes (v.1.6 2024.03.09):

New version v1.6, it's a minor release.

Changes (v.1.5 2024.03.08):

New version v1.5. (versions 1.2-1.4 were not published), several major changes and a lot of smaller ones.

###New features:

Most to least important:

Features required by the changes above and just minor improvements:

Changes (v.1.1 2024.03.30):

New version v1.1. (let's say previous one was v0). A lot of minor things was changed and a huge major change is introduced. New features:

Most important:

Now it allows you to have so called "rooms", which means you can define as many characters as you wish to to chat with these, by choosing who speaks next. You can have conversations with any amount of people now!

Please note (valid for this version only)

when you've >2 characters defined (including you), it switches to a different mode and the consistency of replies changes. i, personally, find that this multi-user mode provides much better results than regular chat mode, so i recomment to add a 3rd user even if you don't use it in the conversation. But you can try and decide what you like more :).

New features:

License

Please note, it's not an open source project. It's a copyrighted proprietary software. The short version of the rules to use this project:

  1. You use it as is, with no warrantees, no guarantees, at your own risk, etc.
  2. It's totally free for personal non-commercial use. In fact it's being made for people to have a free tool to chat to models in a private and convenient way. That's why the sources are open. So if you just wish to chat with models, enjoy!
  3. It's not allowed to repack it or its parts and to use in your product or as your product. I might agree to this after a discussion but by default it's prohibited.
  4. It's totally not allowed to be used by any business or corporation. It's not allowed to be used for any commercial purpose or in commercial products without my agreement.
  5. It's not allowed to remove the original link to github, usage conditions or any other similar materials from the code.

Bonus

I did some experiments to find the meaningful parameter ranges for llama3:8b and wizardlm2:7b Llama3: temperature<=9, top_k<=17, top_p<=1. Wizardlm2: temperature<=28, top_k<=24, top_p<=1.

Higher values do not change almost anything. A very rare chance to get a different reply.

For people who wish to parse the saved file:

P.S. If you wish to parse the saved file for replies, here is structure:

.turns - an array that has all the messages data. each turn is next "line" of chat.

.turns[id].role - the turn belongs to a: "user" || "assistant"

.turns[id].branches - an array of branches, each branch is tied to a single message in a previous turn

.turns[id].branch - id of the active branch holding messages for the active message in previous turn. it can be==-1, which means branch is inactive, user went by another branch

.turns[id].branches[id].msgs - an array, holding all the replies for a given message in a previous turn.

.turns[id].branches[id].msg - id of the finally selected message in this branch

.turns[id].tree - index to match previous messages to current branches, it's used to link previous turn's branch/msg to a current turn's branch. format is:

[previous turn's branch id][msg id within previous turn's branch]=current turn's branch

.turns[id].branches[id].msgs[id].nick - name

.turns[id].branches[id].msgs[id].content - message body

.turns[id].branches[id].msgs[id].rating - 0 is bad, 1 is good, empty is no rating.