openui README

The project's README from github.com/wandb/openui. As one markdown file: README.md.

OpenUI

OpenUI

Building UI components can be a slog. OpenUI aims to make the process fun, fast, and flexible. It's also a tool we're using at W&B to test and prototype our next generation tooling for building powerful applications on top of LLM's.

Overview

Demo

OpenUI let's you describe UI using your imagination, then see it rendered live. You can ask for changes and convert HTML to React, Svelte, Web Components, etc. It's like v0 but open source and not as polished :stuck_out_tongue_closed_eyes:.

Live Demo

Try the demo

Running Locally

OpenUI supports OpenAI, Groq, and any model LiteLLM supports such as Gemini or Anthropic (Claude). The following environment variables are optional, but need to be set in your environment for alternative models to work:

For example, if you're running a tool like localai you can set OPENAI_COMPATIBLE_ENDPOINT and optionally OPENAI_COMPATIBLE_API_KEY to have the models available listed in the UI's model selector under LiteLLM.

Ollama

You can also use models available to Ollama. Install Ollama and pull a model like Llava. If Ollama is not running on http://127.0.0.1:11434, you can set the OLLAMA_HOST environment variable to the host and port of your Ollama instance. For example when running in docker you'll need to point to http://host.docker.internal:11434 as shown below.

Docker (preferred)

The following command would forward the specified API keys from your shell environment and tell Docker to use the Ollama instance running on your machine.

export ANTHROPIC_API_KEY=xxx
export OPENAI_API_KEY=xxx
docker run --rm --name openui -p 7878:7878 -e OPENAI_API_KEY -e ANTHROPIC_API_KEY -e OLLAMA_HOST=http://host.docker.internal:11434 ghcr.io/wandb/openui

Now you can goto http://localhost:7878 and generate new UI's!

From Source / Python

Assuming you have git and uv installed:

git clone https://github.com/wandb/openui
cd openui/backend
uv sync --frozen --extra litellm
source .venv/bin/activate
# Set API keys for any LLM's you want to use
export OPENAI_API_KEY=xxx
python -m openui

LiteLLM

LiteLLM can be used to connect to basically any LLM service available. We generate a config automatically based on your environment variables. You can create your own proxy config to override this behavior. We look for a custom config in the following locations:

  1. litellm-config.yaml in the current directory
  2. /app/litellm-config.yaml when running in a docker container
  3. An arbitrary path specified by the OPENUI_LITELLM_CONFIG environment variable

For example to use a custom config in docker you can run:

docker run -n openui -p 7878:7878 -v $(pwd)/litellm-config.yaml:/app/litellm-config.yaml ghcr.io/wandb/openui

To use litellm from source you can run:

pip install .[litellm]
export ANTHROPIC_API_KEY=xxx
export OPENAI_COMPATIBLE_ENDPOINT=http://localhost:8080/v1
python -m openui --litellm

Groq

To use the super fast Groq models, set GROQ_API_KEY to your Groq api key which you can find here. To use one of the Groq models, click the settings icon in the nav bar.

Docker Compose

DISCLAIMER: This is likely going to be very slow. If you have a GPU you may need to change the tag of the ollama container to one that supports it. If you're running on a Mac, follow the instructions above and run Ollama natively to take advantage of the M1/M2.

From the root directory you can run:

docker-compose up -d
docker exec -it openui-ollama-1 ollama pull llava

If you have your OPENAI_API_KEY set in the environment already, just remove =xxx from the OPENAI_API_KEY line. You can also replace llava in the command above with your open source model of choice (llava is one of the only Ollama models that support images currently). You should now be able to access OpenUI at http://localhost:7878.

If you make changes to the frontend or backend, you'll need to run docker-compose build to have them reflected in the service.

Development

A dev container is configured in this repository which is the quickest way to get started.

Codespace

New with options...

Choose more options when creating a Codespace, then select New with options.... Select the US West region if you want a really fast boot time. You'll also want to configure your OPENAI_API_KEY secret or just set it to xxx if you want to try Ollama (you'll want at least 16GB of Ram).

Once inside the code space you can run the server in one terminal: python -m openui --dev. Then in a new terminal:

cd /workspaces/openui/frontend
npm run dev

This should open another service on port 5173, that's the service you'll want to visit. All changes to both the frontend and backend will automatically be reloaded and reflected in your browser.

Ollama

The codespace installs ollama automaticaly and downloads the llava model. You can verify Ollama is running with ollama list if that fails, open a new terminal and run ollama serve. In Codespaces we pull llava on boot so you should see it in the list. You can select Ollama models from the settings gear icon in the upper left corner of the application. Any models you pull i.e. ollama pull llama will show up in the settings modal.

Select Ollama models

Gitpod

You can easily use Open UI via Gitpod, preconfigured with Open AI.

Open in Gitpod

On launch Open UI is automatically installed and launched.

Before you can use Gitpod:

NOTE: Other (local) models might also be used with a bigger Gitpod instance type. Required models are not preconfigured in Gitpod but can easily be added as documented above.

Resources

See the readmes in the frontend and backend directories.

openui (wandb/openui)

Searching Database…

22.6K ·GitHub
这是干什么的?OpenUI 是 W&B 开源的一个工具,能把文字描述变成实时渲染的界面:描述一个组件,看着它渲染出来,让它改,最后还能把结果转换成 React、Svelte、Web Components 等多种格式。
它是像 v0 那样的在线网站,还是要我自己部署的?两者都有。有一个在线演示可以直接快速体验;自己部署的话推荐用 Docker——装好后会得到一个网页应用,在浏览器里打开本地端口就能用。
怎么在我自己的电脑上跑起来?首选 Docker:运行 OpenUI 容器,把你的模型服务商 API 密钥从 shell 环境变量转发进去。如果从源码运行,需要先装好 git 和 uv;官方文档里也提供了开发容器和 Codespace 的配置方式。
必须用 OpenAI 的密钥吗,还是可以接其他模型?任何服务商都行:OpenAI、Groq,以及 LiteLLM 支持的所有模型(Gemini、Anthropic、Cohere、Mistral、OpenAI 兼容接口),还有本地的 Ollama 模型。你只需要为选定的服务商设置对应的环境变量。
入手之前有什么要注意的坑吗?作者自己承认它不如 v0 那样精致,而且全本地的 Docker Compose 方案被标为可能非常慢——在 Mac 上建议直接原生运行 Ollama,以发挥 M1/M2 芯片的性能。
能不能完全本地运行,让我的提示词不出本机?可以——把它指向 Ollama,使用 Llava 这类本地模型即可。当 OpenUI 跑在 Docker 里而连不上你本地的 Ollama 时,把 OLLAMA_HOST 变量设成你的 Ollama 主机地址和端口。
它和 v0 有什么区别?核心思路一样,都是描述然后渲染,但 OpenUI 是开源的(Apache-2.0 协议),可以对接任何 LiteLLM 支持的服务商或本地 Ollama 模型,而不绑定单一厂商。作者还开玩笑说它就是不如 v0 那样精致。
它能把我的设计转换成什么?除了在聊天里反复迭代,你还可以让 OpenUI 把生成的 HTML 转换成 React、Svelte、Web Components 等其他目标格式。
W&B 为什么要做这个?这是 W&B 内部使用的工具,用来测试和原型验证他们下一代的产品——基于大语言模型构建强大应用的工具链。
能不能什么都不装就先试试?可以——有在线演示可以直接用,还有一个 Gitpod 环境,会自动安装并启动 Open UI;如果想用 OpenAI 的模型,在你的 Gitpod 账户里设置 OPENAI_API_KEY 即可。
Creator
wandb
Size
25 MB
Stars
22.6K
Updated
CommitJun 30
Age
2y
Commits · 90 Days