Skip to content
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

docs(example/llm): init #254

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/examples.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Examples

- [ ] [[share-services]]#
- [[share-services]]#
- [[llm]]#
62 changes: 62 additions & 0 deletions doc/llm.md
shivaraj-bh marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
page:
image: llm.png
shivaraj-bh marked this conversation as resolved.
Show resolved Hide resolved
template:
toc:
enable: false
---

# Local AI chatbot

The [`llm` example][source] allows you to run advanced AI chatbots and services on your own computer with just one command. Once you've downloaded the model, you can use it without needing a constant internet connection.

![[llm.png]]

> [!tip] On dev vs app mode
>
> **services-flake** provides two main uses:
>
> 1. Running services in development projects with source code access.
> 1. Creating end-user *apps* that run multiple services.
>
> Our example is based on the second use. These *apps* can be launched with `nix run` or installed using `nix profile install`.

{#run}
## Running the app

To run the local AI chatbot and launch the Web UI,

```sh
# You can also use `nix profile install` on this URL, and run `services-flake-llm`
nix run "github:juspay/services-flake?dir=example/llm"
```

Before launching the Web UI, this will download the [`phi3`] model, which is about 2.4GB. To reduce or avoid this delay, you can:

1. Choose a different model, or
2. Use no model at all

See further below for more options.

### Demo

<center>
<blockquote class="twitter-tweet" data-media-max-width="560"><p lang="en" dir="ltr">Want to run your own AI chatbot (like ChatGPT) locally? You can do that with Nix.<br><br>Powered by services-flake (<a href="https://twitter.com/hashtag/NixOS?src=hash&amp;ref_src=twsrc%5Etfw">#NixOS</a>), using <a href="https://twitter.com/OpenWebUI?ref_src=twsrc%5Etfw">@OpenWebUI</a> and <a href="https://twitter.com/ollama?ref_src=twsrc%5Etfw">@ollama</a>. <br><br>See example: <a href="https://t.co/dyItC93Pya">https://t.co/dyItC93Pya</a> <a href="https://t.co/DeDow8bEPw">pic.twitter.com/DeDow8bEPw</a></p>&mdash; NixOS Asia (@nixos_asia) <a href="https://twitter.com/nixos_asia/status/1803065244568244578?ref_src=twsrc%5Etfw">June 18, 2024</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</center>

{#default-config}
## Default configuration & models

The [example][source] runs two processes [[ollama]] and [[open-webui]]

Key points:

1. **Data storage:**
- Ollama data is stored in `$HOME/.services-flake/llm/ollama`
- To change this location, edit the `dataDir` option in `flake.nix`
2. **Model management**:
- By default, the [`phi3`] model is automatically downloaded
- To change or add models: a. Edit the `models` option in `flake.nix` b. Use the open-webui interface to download additional models.

[`phi3`]: https://ollama.com/library/phi3
[source]: https://github.com/juspay/services-flake/tree/main/example/llm
Binary file added doc/llm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 0 additions & 18 deletions example/llm/README.md

This file was deleted.

1 change: 1 addition & 0 deletions example/llm/README.md
2 changes: 1 addition & 1 deletion example/llm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# models manually in the UI.
#
# Search for the models here: https://ollama.com/library
models = [ "deepseek-coder-v2" ];
models = [ "phi3" ];
};

# Get ChatGPT like UI, but open-source, with Open WebUI
Expand Down