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

open-webui: init at 0.2.4 #316248

Merged
merged 2 commits into from
Jun 4, 2024
Merged

open-webui: init at 0.2.4 #316248

merged 2 commits into from
Jun 4, 2024

Conversation

shivaraj-bh
Copy link
Member

@shivaraj-bh shivaraj-bh commented May 31, 2024

Description of changes

Resolves #309567

open-webui package

mkdir -p ./{data,static}
DATA_DIR=$(pwd) STATIC_DIR=$(pwd)/static nix run github:shivaraj-bh/nixpkgs/open-webui#open-webui

open-webui service

{
  services.open-webui.enable = true;
}

open-webui service with ollama

{
  services.ollama.enable = true;
  services.open-webui = {
    enable = true;
    environment.OLLAMA_API_BASE_URL = "http://localhost:11434";
  };
}
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!

Thanks for submitting this!

I left some comments, could you also please pass the new files through nixfmt-rfc-style ?

nixos/modules/services/misc/open-webui.nix Outdated Show resolved Hide resolved
pkgs/by-name/op/open-webui/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/op/open-webui/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/op/open-webui/package.nix Outdated Show resolved Hide resolved
nixos/tests/all-tests.nix Outdated Show resolved Hide resolved
@TanvirOnGH
Copy link

TanvirOnGH commented Jun 2, 2024

v0.2.3 is out!

@shivaraj-bh
Copy link
Member Author

v0.2.2 is out: https://github.com/open-webui/open-webui/releases/tag/v0.2.2

@TanvirOnGH There is a problem after 0.1.125, which I am still unsure how to tackle, see: #309567 (comment)

To be specific, they are fetching some dependencies in build-time: https://github.com/open-webui/open-webui/blob/be08dbf00d9ed894602f92955355eb2aa8374ec5/package.json#L7C13-L7C34

@shivaraj-bh shivaraj-bh changed the title open-webui: init at 0.1.124 open-webui: init at 0.2.0 Jun 4, 2024
@shivaraj-bh
Copy link
Member Author

v0.2.2 is out: https://github.com/open-webui/open-webui/releases/tag/v0.2.2

@TanvirOnGH There is a problem after 0.1.125, which I am still unsure how to tackle, see: #309567 (comment)

To be specific, they are fetching some dependencies in build-time: https://github.com/open-webui/open-webui/blob/be08dbf00d9ed894602f92955355eb2aa8374ec5/package.json#L7C13-L7C34

@TanvirOnGH I have disabled pyotide until we figure that out separately in a different PR: 39227d2

Now the package inits at 0.2.0

@shivaraj-bh
Copy link
Member Author

@drupol Does it look good for a merge now? (If yes, I can squash the commits)

I have also switched over to use buildPythonApplication as suggested by @mweinelt

pkgs/by-name/op/open-webui/package.nix Outdated Show resolved Hide resolved
@drupol
Copy link
Contributor

drupol commented Jun 4, 2024

@TanvirOnGH There is a problem after 0.1.125, which I am still unsure how to tackle, see: #309567 (comment)

To be specific, they are fetching some dependencies in build-time: https://github.com/open-webui/open-webui/blob/be08dbf00d9ed894602f92955355eb2aa8374ec5/package.json#L7C13-L7C34

I see that you've updated to 0.2.0, does that mean that the aforementioned issue has been dealt with? If yes, would it be possible to update to the very latest version then?

@shivaraj-bh
Copy link
Member Author

I see that you've updated to 0.2.0, does that mean that the aforementioned issue has been dealt with?

I have disabled the feature that’s causing the issue for the time-being: 39227d2

If yes, would it be possible to update to the very latest version then?

will do

Copy link
Contributor

@drupol drupol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there,

Upgrade to latest version and squash the relevant some commits together now so that it make sense?

@shivaraj-bh shivaraj-bh changed the title open-webui: init at 0.2.0 open-webui: init at 0.2.4 Jun 4, 2024
@drupol
Copy link
Contributor

drupol commented Jun 4, 2024

Can you please squash the relevant commits together?

I think in the end there should be 2 commits, 1 for introducing the pkg open-webui and one for introducing the NixOS module.

@shivaraj-bh
Copy link
Member Author

Can you please squash the relevant commits together?

I think in the end there should be 2 commits, 1 for introducing the pkg open-webui and one for introducing the NixOS module.

Done!

@drupol
Copy link
Contributor

drupol commented Jun 4, 2024

Nice!

I'm wondering if adding something similar to

passthru.tests = {
in open-webui pkg would be a good idea. WDYT ?

@drupol drupol merged commit 6b6d4ae into NixOS:master Jun 4, 2024
23 of 25 checks passed
@drupol
Copy link
Contributor

drupol commented Jun 4, 2024

Thank you @shivaraj-bh !

@shivaraj-bh shivaraj-bh deleted the open-webui branch June 4, 2024 14:00
@drupol
Copy link
Contributor

drupol commented Jun 4, 2024

I quickly tested it locally and I noticed 2 things:

  1. Running OLLAMA_API_BASE_URL="http://127.0.0.1:11434" WEBUI_AUTH="False" STATIC_DIR=/home/pol/.open-webui/static DATA_DIR=/home/pol/.open-webui/data open-webui dev is failing:
❯ OLLAMA_API_BASE_URL="http://127.0.0.1:11434" WEBUI_AUTH="False" STATIC_DIR=/home/pol/.open-webui/static DATA_DIR=/home/pol/.open-webui/data open-webui dev
INFO:     Will watch for changes in these directories: ['/home/pol']
INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
INFO:     Started reloader process [495629] using StatReload
2024-06-04 16:30:19.057669038 [W:onnxruntime:Default, onnxruntime_pybind_state.cc:1983 CreateInferencePybindStateModule] Init provider bridge failed.
Process SpawnProcess-1:
Traceback (most recent call last):
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
  self.run()
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/multiprocessing/process.py", line 108, in run
  self._target(*self._args, **self._kwargs)
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/_subprocess.py", line 78, in subprocess_started
  target(sockets=sockets)
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/server.py", line 65, in run
  return asyncio.run(self.serve(sockets=sockets))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/asyncio/runners.py", line 190, in run
  return runner.run(main)
         ^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/asyncio/runners.py", line 118, in run
  return self._loop.run_until_complete(task)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
  return future.result()
         ^^^^^^^^^^^^^^^
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/server.py", line 69, in serve
  await self._serve(sockets)
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/server.py", line 76, in _serve
  config.load()
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/config.py", line 433, in load
  self.loaded_app = import_from_string(self.app)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/importer.py", line 22, in import_from_string
  raise exc from None
File "/nix/store/a3wgjxq99f6b86vdjcf5s2x4p4a37nd6-python3.11-uvicorn-0.29.0/lib/python3.11/site-packages/uvicorn/importer.py", line 19, in import_from_string
  module = importlib.import_module(module_str)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/nix/store/7hnr99nxrd2aw6lghybqdmkckq60j6l9-python3-3.11.9/lib/python3.11/importlib/__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 940, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/nix/store/hww5p16985hi360yg777ngf57w8jf0yf-open-webui-0.2.4/lib/python3.11/site-packages/main.py", line 23, in <module>
  from apps.ollama.main import app as ollama_app, get_all_models as get_ollama_models
File "/nix/store/hww5p16985hi360yg777ngf57w8jf0yf-open-webui-0.2.4/lib/python3.11/site-packages/apps/ollama/main.py", line 34, in <module>
  from apps.webui.models.models import Models
File "/nix/store/hww5p16985hi360yg777ngf57w8jf0yf-open-webui-0.2.4/lib/python3.11/site-packages/apps/webui/models/models.py", line 11, in <module>
  from apps.webui.internal.db import DB, JSONField
File "/nix/store/hww5p16985hi360yg777ngf57w8jf0yf-open-webui-0.2.4/lib/python3.11/site-packages/apps/webui/internal/db.py", line 6, in <module>
  from config import SRC_LOG_LEVELS, DATA_DIR, DATABASE_URL, BACKEND_DIR
File "/nix/store/hww5p16985hi360yg777ngf57w8jf0yf-open-webui-0.2.4/lib/python3.11/site-packages/config.py", line 6, in <module>
  import chromadb
File "/nix/store/kg9z9iii6rjggd4vd9yf989dj77bqr9w-python3.11-chromadb-0.5.0/lib/python3.11/site-packages/chromadb/__init__.py", line 5, in <module>
  from chromadb.auth.token_authn import TokenTransportHeader
File "/nix/store/kg9z9iii6rjggd4vd9yf989dj77bqr9w-python3.11-chromadb-0.5.0/lib/python3.11/site-packages/chromadb/auth/token_authn/__init__.py", line 20, in <module>
  from chromadb.telemetry.opentelemetry import (
File "/nix/store/kg9z9iii6rjggd4vd9yf989dj77bqr9w-python3.11-chromadb-0.5.0/lib/python3.11/site-packages/chromadb/telemetry/opentelemetry/__init__.py", line 12, in <module>
  from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
File "/nix/store/0bn6iv8mv822bx1rz9944wgsb6br27sy-python3.11-opentelemetry-exporter-otlp-proto-grpc-1.24.0/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/grpc/trace_exporter/__init__.py", line 27, in <module>
  from opentelemetry.exporter.otlp.proto.grpc.exporter import (
File "/nix/store/0bn6iv8mv822bx1rz9944wgsb6br27sy-python3.11-opentelemetry-exporter-otlp-proto-grpc-1.24.0/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/grpc/exporter.py", line 43, in <module>
  from google.rpc.error_details_pb2 import RetryInfo
ModuleNotFoundError: No module named 'google.rpc'
  1. Uploading PDFs is failing at some point this has been fixed using ollama instead of local rag transformer
INFO:     127.0.0.1:47186 - "GET /api/v1/chats/ HTTP/1.1" 200 OK
Batches:   0%|                                   | 0/102 [00:00<?, ?it/s]
fish: Job 1, 'OLLAMA_API_BASE_URL="http://127…' terminated by signal SIGFPE (Floating point exception)
  1. We forgot to add an entry in the release note
  2. I have the feeling that we should add more environment variables, like: HF_HOME, SENTENCE_TRANSFORMERS_HOME

@shivaraj-bh
Copy link
Member Author

I have the feeling that we should add more environment variables, like: HF_HOME, SENTENCE_TRANSFORMERS_HOME

I was about to point this out as well. I just noticed the log while running the VM test.

@Celibistrial
Copy link
Member

Celibistrial commented Jun 6, 2024

Doesn't seem to be working

   ollama = {
      enable = true;
      acceleration = "cuda";
    };
    open-webui = {
      enable = true;
      environment.OLLAMA_API_BASE_URL = "http://localhost:11434";
    };
× open-webui.service - User-friendly WebUI for LLMs
     Loaded: loaded (/etc/systemd/system/open-webui.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Thu 2024-06-06 23:10:19 IST; 2s ago
   Duration: 6.662s
    Process: 75006 ExecStart=/nix/store/zlk9fvnb6gfa5gbl5v9ibws9jcv30sly-open-webui-0.2.4/bin/open-webui serve --host 127.0.0.1 --port 8080 (code=exited, status=1/FAILURE)
   Main PID: 75006 (code=exited, status=1/FAILURE)
         IP: 8.3K in, 2.3K out
        CPU: 4.464s

Jun 06 23:10:18 hp-pav open-webui[75006]:     os.makedirs(os.path.dirname(blob_path), exist_ok=True)
Jun 06 23:10:18 hp-pav open-webui[75006]:   File "<frozen os>", line 215, in makedirs
Jun 06 23:10:18 hp-pav open-webui[75006]:   File "<frozen os>", line 215, in makedirs
Jun 06 23:10:18 hp-pav open-webui[75006]:   File "<frozen os>", line 215, in makedirs
Jun 06 23:10:18 hp-pav open-webui[75006]:   [Previous line repeated 1 more time]
Jun 06 23:10:18 hp-pav open-webui[75006]:   File "<frozen os>", line 225, in makedirs
Jun 06 23:10:18 hp-pav open-webui[75006]: OSError: [Errno 30] Read-only file system: '/.cache'
Jun 06 23:10:19 hp-pav systemd[1]: open-webui.service: Main process exited, code=exited, status=1/FAILURE
Jun 06 23:10:19 hp-pav systemd[1]: open-webui.service: Failed with result 'exit-code'.
Jun 06 23:10:19 hp-pav systemd[1]: open-webui.service: Consumed 4.464s CPU time, received 8.3K IP traffic, sent 2.3K IP traffic.

/var/lib/open-webui/cache is not a read only directory(i can manually create files in that dir)

@jayrahdevore
Copy link

jayrahdevore commented Jun 7, 2024

First off -- thank you all for the work on this! I was pleasantly surprised to see it in nixpkgs and it saves me from having to add another docker container.

I ended up running into the same issue as @Celibistrial . Per @drupol 's comment above, I got it up and running by adding a few more environment variables. I don't think these locations can be arbitrarily created and used due to service permissions, so I kept them to the runtime directory (this may not the ideal place, I was just focused on getting up and running)

HF_HOME = ".";
SENTENCE_TRANSFORMERS_HOME = ".";

@drupol
Copy link
Contributor

drupol commented Jun 7, 2024

I also had the issue and planning to fix the issue, here it is: #318099

@shivaraj-bh
Copy link
Member Author

I also had the issue and planning to fix the issue, here it is: #318099

@drupol Thanks for this! I was offline for the last few days.

Anyways, I was planning to check out why open-webui dev is failing. I will raise a PR once I do.

shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Jun 11, 2024
@shivaraj-bh
Copy link
Member Author

@natsukium Thanks for the review! I will address them in a different PR and cross-reference it here.

shivaraj-bh added a commit to shivaraj-bh/nixpkgs that referenced this pull request Jun 13, 2024
For more info, see:
- Disable hatch custom hook:
NixOS#316248 (comment)
- why `makeWrapperArgs`?:
NixOS#316248 (comment)
- `pythonRelaxDepsHook` is a nativeBuildInput:
NixOS#316248 (comment)
@Kreyren
Copy link
Contributor

Kreyren commented Jun 13, 2024

Please backport this to stable, i wanna use it

Thanks <3

shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Jun 13, 2024
ported from:
https://github.com/shivaraj-bh/ollama-flake/blob/main/services/open-webui.nix

This was also recently upstreamed to
[nixpkgs](https://github.com/NixOS/nixpkgs/tree/master):
NixOS/nixpkgs#316248

---------

Co-authored-by: Pol Dellaiera <pol.dellaiera@protonmail.com>
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Jun 13, 2024
ported from:
https://github.com/shivaraj-bh/ollama-flake/blob/main/services/open-webui.nix

This was also recently upstreamed to
[nixpkgs](https://github.com/NixOS/nixpkgs/tree/master):
NixOS/nixpkgs#316248

---------

Co-authored-by: Pol Dellaiera <pol.dellaiera@protonmail.com>
Co-authored-by: Sridhar Ratnakumar <3998+srid@users.noreply.github.com>
@shivaraj-bh shivaraj-bh added the backport release-24.05 Backport PR automatically label Aug 5, 2024
Copy link
Contributor

github-actions bot commented Aug 5, 2024

Successfully created backport PR for release-24.05:

drupol pushed a commit that referenced this pull request Aug 8, 2024
For more info, see:
- Disable hatch custom hook:
#316248 (comment)
- why `makeWrapperArgs`?:
#316248 (comment)
- `pythonRelaxDepsHook` is a nativeBuildInput:
#316248 (comment)

(cherry picked from commit 75d7ee7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NixOS module request: open-webui (formerly ollama-webui)
10 participants