-
Notifications
You must be signed in to change notification settings - Fork 81
feat: add open-webui module #580
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
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
e338f36
feat: add open-webui module for coder-labs
mtojek 3cb817c
fixes
mtojek e46cbbd
fixes 2
mtojek ebce587
fix: use venv instead of pip install --user
mtojek cfc8383
fix: remove running process check
mtojek 749be20
fix: restore LOG_PATH and PORT variable assignments from templatefile
mtojek a1de7c2
fixes
mtojek 855c545
fixes
mtojek 631a137
Revert "fixes"
mtojek b4902e4
fix: rename variables to HTTP_SERVER_PORT and HTTP_SERVER_LOG_PATH
mtojek b6009b2
test
mtojek 0411dfc
test
mtojek 3015fdf
test
mtojek 2a22690
test
mtojek f28e116
cleanup
mtojek da9fb56
Add terraform tests for open-webui module
mtojek 0996f63
Add open_webui_version parameter (default: 0.6.40)
mtojek f548d3d
Show version in startup message
mtojek 7f9854e
fix: typo
mtojek 02cd802
Add data_dir parameter for database/vectordb storage location
mtojek fd0bd95
Use ~/.open-webui as default data_dir
mtojek 12e0760
Remove unused DATA_DIR export
mtojek 7ae3bb8
Add DATA_DIR echo before starting server
mtojek b2ccead
Change default data_dir from ~/.open-webui to .open-webui
mtojek 34fa08d
Add openai_api_key parameter for OpenAI integration
mtojek 983a83d
Export DATA_DIR as environment variable for Open WebUI
mtojek 07a3492
screenshot
mtojek 4db13c0
Format README.md
mtojek 73af9e7
Fix README structure: add tf code block in h1 section
mtojek 57289ae
Apply code review feedback
mtojek 259f980
Merge branch 'main' into open-webui-module
DevelopmentCats 0741b59
fix?
mtojek 2d5dbe4
fix: use pip semver
mtojek 0ffd694
fix?
mtojek 60c6148
fix ?
mtojek 4e83a73
fix ?
mtojek fa6b236
fix tests
mtojek 61f6ec0
fmt
mtojek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --- | ||
| display_name: Open WebUI | ||
| description: A self-hosted AI chat interface supporting various LLM providers | ||
| icon: ../../../../.icons/openwebui.svg | ||
| verified: false | ||
| tags: [ai, llm, chat, web, python] | ||
| --- | ||
|
|
||
| # Open WebUI | ||
|
|
||
| Open WebUI is a user-friendly web interface for interacting with Large Language Models. It provides a ChatGPT-like interface that can connect to various LLM providers including OpenAI, Ollama, and more. | ||
|
|
||
| ```tf | ||
| module "open-webui" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/coder-labs/open-webui/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.main.id | ||
| } | ||
| ``` | ||
|
|
||
|  | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - **Python 3.11 or higher** must be installed in your image (with `venv` module) | ||
| - Port 7800 (default) or your custom port must be available | ||
|
|
||
| For Ubuntu/Debian, you can install Python 3.11 from [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa): | ||
|
|
||
| ```shell | ||
| sudo add-apt-repository -y ppa:deadsnakes/ppa | ||
| sudo apt-get update | ||
| sudo apt-get install -y python3.11 python3.11-venv | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### With OpenAI API Key | ||
|
|
||
| ```tf | ||
| module "open-webui" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/coder-labs/open-webui/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.main.id | ||
|
|
||
| openai_api_key = var.openai_api_key | ||
| } | ||
| ``` | ||
|
|
||
| ### Custom Port and Data Directory | ||
|
|
||
| ```tf | ||
| module "open-webui" { | ||
| count = data.coder_workspace.me.start_count | ||
| source = "registry.coder.com/coder-labs/open-webui/coder" | ||
| version = "1.0.0" | ||
| agent_id = coder_agent.main.id | ||
|
|
||
| http_server_port = 8080 | ||
| data_dir = "/home/coder/open-webui-data" | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| terraform { | ||
| required_version = ">= 1.0" | ||
|
|
||
| required_providers { | ||
| coder = { | ||
| source = "coder/coder" | ||
| version = ">= 2.5" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| variable "agent_id" { | ||
| type = string | ||
| description = "The ID of a Coder agent." | ||
| } | ||
|
|
||
| variable "http_server_log_path" { | ||
| type = string | ||
| description = "The path to log Open WebUI to." | ||
| default = "/tmp/open-webui.log" | ||
| } | ||
|
|
||
| variable "http_server_port" { | ||
| type = number | ||
| description = "The port to run Open WebUI on." | ||
| default = 7800 | ||
| } | ||
|
|
||
| variable "open_webui_version" { | ||
| type = string | ||
| description = "The version of Open WebUI to install" | ||
| default = "latest" | ||
| } | ||
|
|
||
| variable "data_dir" { | ||
| type = string | ||
| description = "The directory where Open WebUI stores its data (database, uploads, vector_db, cache)." | ||
| default = ".open-webui" | ||
| } | ||
|
|
||
| variable "openai_api_key" { | ||
| type = string | ||
| description = "OpenAI API key for accessing OpenAI models. If not provided, OpenAI integration will need to be configured manually in the UI." | ||
| default = "" | ||
| sensitive = true | ||
| } | ||
|
|
||
| variable "share" { | ||
| type = string | ||
| description = "The sharing level for the Open WebUI app. Set to 'owner' for private access, 'authenticated' for access by any authenticated user, or 'public' for public access." | ||
| default = "owner" | ||
| validation { | ||
| condition = var.share == "owner" || var.share == "authenticated" || var.share == "public" | ||
| error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'." | ||
| } | ||
| } | ||
|
|
||
| variable "order" { | ||
| type = number | ||
| description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)." | ||
| default = null | ||
| } | ||
|
|
||
| variable "group" { | ||
| type = string | ||
| description = "The name of a group that this app belongs to." | ||
| default = null | ||
| } | ||
|
|
||
| resource "coder_script" "open-webui" { | ||
| agent_id = var.agent_id | ||
| display_name = "open-webui" | ||
| icon = "/icon/openwebui.svg" | ||
| script = templatefile("${path.module}/run.sh", { | ||
| HTTP_SERVER_LOG_PATH : var.http_server_log_path, | ||
| HTTP_SERVER_PORT : var.http_server_port, | ||
| VERSION : var.open_webui_version, | ||
| DATA_DIR : var.data_dir, | ||
| OPENAI_API_KEY : var.openai_api_key, | ||
| }) | ||
| run_on_start = true | ||
| } | ||
|
|
||
| resource "coder_app" "open-webui" { | ||
| agent_id = var.agent_id | ||
| slug = "open-webui" | ||
| display_name = "Open WebUI" | ||
| url = "http://localhost:${var.http_server_port}" | ||
| icon = "/icon/openwebui.svg" | ||
| subdomain = true | ||
| share = var.share | ||
| order = var.order | ||
| group = var.group | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,188 @@ | ||
| mock_provider "coder" {} | ||
|
|
||
| run "test_defaults" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-123" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.http_server_port == 7800 | ||
| error_message = "Default port should be 7800" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.http_server_log_path == "/tmp/open-webui.log" | ||
| error_message = "Default log path should be /tmp/open-webui.log" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.share == "owner" | ||
| error_message = "Default share should be 'owner'" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.open_webui_version == "latest" | ||
| error_message = "Default version should be 'latest'" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.subdomain == true | ||
| error_message = "App should use subdomain" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.display_name == "Open WebUI" | ||
| error_message = "App display name should be 'Open WebUI'" | ||
| } | ||
| } | ||
|
|
||
| run "test_custom_port" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-456" | ||
| http_server_port = 9000 | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.http_server_port == 9000 | ||
| error_message = "Custom port should be 9000" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.url == "http://localhost:9000" | ||
| error_message = "App URL should use custom port" | ||
| } | ||
| } | ||
|
|
||
| run "test_custom_log_path" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-789" | ||
| http_server_log_path = "/var/log/open-webui.log" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.http_server_log_path == "/var/log/open-webui.log" | ||
| error_message = "Custom log path should be set" | ||
| } | ||
| } | ||
|
|
||
| run "test_share_authenticated" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-auth" | ||
| share = "authenticated" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.share == "authenticated" | ||
| error_message = "Share should be 'authenticated'" | ||
| } | ||
| } | ||
|
|
||
| run "test_share_public" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-public" | ||
| share = "public" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.share == "public" | ||
| error_message = "Share should be 'public'" | ||
| } | ||
| } | ||
|
|
||
| run "test_order_and_group" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-order" | ||
| order = 10 | ||
| group = "AI Tools" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.order == 10 | ||
| error_message = "Order should be 10" | ||
| } | ||
|
|
||
| assert { | ||
| condition = coder_app.open-webui.group == "AI Tools" | ||
| error_message = "Group should be 'AI Tools'" | ||
| } | ||
| } | ||
|
|
||
| run "test_custom_version" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-version" | ||
| open_webui_version = "0.5.0" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.open_webui_version == "0.5.0" | ||
| error_message = "Custom version should be '0.5.0'" | ||
| } | ||
| } | ||
|
|
||
| run "test_custom_data_dir" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-data" | ||
| data_dir = "/home/coder/open-webui-data" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.data_dir == "/home/coder/open-webui-data" | ||
| error_message = "Custom data_dir should be set" | ||
| } | ||
| } | ||
|
|
||
| run "test_default_data_dir" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-data-default" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.data_dir == ".open-webui" | ||
| error_message = "Default data_dir should be '.open-webui'" | ||
| } | ||
| } | ||
|
|
||
| run "test_openai_api_key" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-openai" | ||
| openai_api_key = "sk-test-key-123" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.openai_api_key == "sk-test-key-123" | ||
| error_message = "OpenAI API key should be set" | ||
| } | ||
| } | ||
|
|
||
| run "test_default_openai_api_key" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| agent_id = "test-agent-openai-default" | ||
| } | ||
|
|
||
| assert { | ||
| condition = var.openai_api_key == "" | ||
| error_message = "Default OpenAI API key should be empty" | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.