open-intelligent-ui README

项目的 README,来自 github.com/thesysdev/open-intelligent-ui。合并为一个 markdown 文件:README.md。

Open Intelligent UI

An open-source implementation of the "Intelligent UI" experience introduced in ChatGPT, built on OpenUI.

Try the live demo

In ChatGPT's Intelligent UI, a request such as "plan a day in San Francisco" returns an interactive answer (a map, photographs and an editable itinerary) rather than text. This repository reproduces that experience with open-source components, so that the same kind of interface can be built, modified and shipped inside any application.

OpenUI is an open standard for Generative UI.

This project is independent and is not affiliated with or endorsed by OpenAI. "Intelligent UI" refers to the ChatGPT feature that this demo recreates.

Demo video

ChatGPT's Intelligent UI (left) and this project (right) answering the same request. Select the image to play the video.

ChatGPT and OpenUI side by side, each showing a one-day San Francisco route with photos and a map

What's in the demo

The model streams OpenUI Lang 1.0, and the app renders it with a library of primitives the model arranges itself: no layout is fixed in the components. The primitives and @functions come from the @openuidev/intelligent-ui-library component library, and src/lib/library.ts extends it (library.extend) with what only this app can do: SearchImage, Map with MapMarker, and @CopyToClipboard. The components have light and dark tokens, but only /gallery (and the benchmark's /preview) switch to dark; the chat is light only:

The dev-only page /gallery renders hand-written programs: a working answer for each of the 16 Intelligent UI examples (from the 7-speed bike to the arcade game), two dashboards over demo data, the prompt's worked examples, and programs that exercise every component.

Setup

Requires Node 24.

cp .env.example .env
npm install
npm run generate:apiKey   # writes THESYS_API_KEY to .env
npm run dev

Open http://localhost:3000 and try: I'm in San Francisco for a day, plan a sightseeing route for me

Variable Required Purpose
THESYS_API_KEY Yes, unless using a direct API OpenUI Cloud (Gateway) key, used only on the server.
THESYS_MODEL No A {provider}/{model} id. Defaults to openai/gpt-6.1-sol.
THESYS_BASE_URL No The Gateway's Responses endpoint. Defaults to https://api.thesys.dev/v1/embed.
LLM_BASE_URL No Use any OpenAI-compatible Chat Completions API directly instead of Cloud, e.g. https://openrouter.ai/api/v1; see Use any OpenAI-compatible API.
LLM_API_KEY With LLM_BASE_URL That API's key.
LLM_MODEL With LLM_BASE_URL The model id it serves, e.g. openai/gpt-6.1-sol on OpenRouter.
LLM_REASONING_EFFORT No Reasoning effort for both paths. Defaults to low (about five times faster to the first line of UI on gpt-6.1-sol, same quality); default sends none.
MODEL_PROVIDER No Set to ollama to run a local model instead of Gateway; see Run with a local model.
OLLAMA_MODEL No The Ollama model to use. Defaults to qwen3.8:27b.
OLLAMA_BASE_URL No Ollama's OpenAI-compatible endpoint. Defaults to http://localhost:11434/v1.

Use any OpenAI-compatible API

Set LLM_BASE_URL, LLM_API_KEY and LLM_MODEL to skip OpenUI Cloud and call a model directly, for example through OpenRouter:

LLM_BASE_URL=https://openrouter.ai/api/v1
LLM_API_KEY=sk-or-...
LLM_MODEL=openai/gpt-6.1-sol

/api/chat then builds the full OpenUI 1.0 system prompt on the server, from the same library spec and prompt options (generateSystemPrompt), streams Chat Completions and relays the text as Responses events, so the browser is unchanged. The Ollama variables below are shortcuts for the same path. Output is rendered as written: Cloud's correction step is not there.

Run with a local model (Ollama)

The demo can also run on a local model through Ollama, with no API key required.

It works with any OpenAI-compatible local server (Ollama, LM Studio) via OLLAMA_BASE_URL.

  1. Install Ollama and pull a model. The default is qwen3.8:27b (about 18 GB, best with 32 GB of memory or more); gpt-oss:20b and qwen3:8b are smaller alternatives.

    ollama pull qwen3.8:27b
    
  2. Give the model a larger context window. The OpenUI prompt for this app is about 8,000 tokens, and Ollama's default window is 4,096, which silently cuts the prompt and produces broken output. Either start Ollama with a larger default:

    OLLAMA_CONTEXT_LENGTH=32768 ollama serve
    

    or create a model variant with a larger window and use its name as OLLAMA_MODEL:

    printf 'FROM qwen3.8:27b\nPARAMETER num_ctx 32768\n' > Modelfile
    ollama create qwen3.8-32k -f Modelfile
    
  3. In .env, set MODEL_PROVIDER=ollama (and OLLAMA_MODEL to use another model), then npm run dev.

What changes with a local model:

How it works

Project structure

File Purpose
src/app/layout.tsx Root layout: page metadata, the Inter font and globals.css.
src/app/page.tsx The chat page. Renders AgentInterface with the component library, theme, welcome screen and starter prompts, and connects it to /api/chat.
src/app/globals.css Global CSS reset.
src/app/api/chat/route.ts Chat endpoint. Validates the request, forwards the conversation to OpenUI Cloud (or, with LLM_BASE_URL or the Ollama variables, to any OpenAI-compatible API with the prompt built here), and streams the response back.
src/app/api/street-route/route.ts Street geometry between stops from OSRM, cached on the server.
src/app/api/wiki/route.ts Wikipedia lookup: the lead photos (and coordinates) of an article, cached on the server.
src/app/api/image-search/route.ts Photo search for SearchImage: matching Wikipedia lead images, then Wikimedia Commons, cached on the server.
src/app/gallery/ The dev-only /gallery page and its OpenUI Lang programs; tool-programs.ts holds the 16 examples and the dashboards.
src/app/preview/ A dev-only page that renders one program handed in by a script, for the benchmark's screenshots.
src/lib/library.ts The app's component library: @openuidev/intelligent-ui-library extended with SearchImage, Map, MapMarker and @CopyToClipboard.
src/lib/actions.ts The @CopyToClipboard action and its handler.
src/lib/demo-data.ts Demo data tools (get_orders, get_tickets, get_traffic) for Query-backed dashboards: their specs for the prompt and a function-map tool provider.
src/lib/prompt-options.ts The prompt options: the component library's rules and examples, with the photo and map rules rewritten for SearchImage and Map, and a dashboard variant with the demo data tools.
src/lib/components/ The app's own components: SearchImage, the map in map/, and their styles and tokens.
src/generated/spec.json Library spec sent to Gateway in the system prompt. Regenerate with npm run generate after changing a component schema.
src/generated/system-prompt.txt The full system prompt for the library; dashboard-system-prompt.txt adds the demo data tools. Regenerate with npm run prompt.
scripts/bench/ The benchmark: 16 example prompts and 8 dashboard prompts, run against a model and checked; see Benchmark.
docs/openui-chatgpt-comparison.mp4 Side-by-side video of ChatGPT and this project; docs/openui-chatgpt-comparison.jpg is its README preview.
.env.example The environment variables to copy into .env.

For designers

npm install && npm run dev, then open http://localhost:3000/gallery. It needs no API key: every example and component renders from hand-written programs, with Light and Dark at the top right. Check phone width too.

How anything looks can change freely. What the model writes must keep working, so keep these as they are, or regenerate the prompt (npm run generate && npm run prompt) and tell whoever owns it:

Checks

npm run generate && npm run prompt   # after changing a component schema, a function or the prompt options
npm test                             # the functions, and every gallery program and prompt example parsed by the 1.0 parser
npm run typecheck
npm run build

Then open /gallery (npm run dev), switch between light and dark, and try it at phone width.

Benchmark

scripts/bench/run.mjs sends the 16 example prompts (with system-prompt.txt) and 8 dashboard prompts (with dashboard-system-prompt.txt) to a model on any OpenAI-compatible endpoint, saves each answer, checks it with the 1.0 parser, flags @names and components the library does not have, and screenshots each answer in light and dark at 390 and 1280 px through /preview. The key is read from an environment variable at run time.

npm run dev   # in another terminal, for the screenshots
PLAYWRIGHT_CORE=/path/to/playwright-core CHROME=/path/to/chrome-headless-shell \
  OPENROUTER_API_KEY=... npm run bench -- --model <id> --base-url https://openrouter.ai/api/v1 --key-env OPENROUTER_API_KEY
npm run bench -- --fake                 # the hand-written programs stand in for the model
npm run bench -- --answers <dir>        # re-check and re-shoot saved <id>.oui answers

Results go to bench-out/<model>-<time>/: answers/, shots/, report.json and report.md. Other options: --only id,id, --kind tool|dashboard, --widths, --no-shots, --concurrency, --temperature, --max-tokens, --app.

License

MIT

Clash Royale deck coach (/clash)

A second chat at /clash that answers Clash Royale questions with live card UI: decks held in a $deck variable, tap-to-swap benches, an elixir meter and deck health checks that recompute on every swap without another model call.

Fan-made demo, not affiliated with or endorsed by Supercell.

Chess coach (/chess)

A chat at /chess that answers chess questions with a playable board: the game is a list of moves in a $moves variable, and the board, score sheet and position checks recompute on every move without another model call.

open-intelligent-ui (thesysdev/open-intelligent-ui)

正在搜索数据库…

这是什么?这是对 ChatGPT「智能界面」(Intelligent UI)功能的开源复刻。应用不再只返回纯文本,而是实时流式输出一个可交互的回答,由地图、照片、图表、绘图和可用的工具组成,并通过 OpenUI 标准由 LLM 实时生成。
这是我要引入的库,还是独立应用?这是一个可以直接运行的 Next.js/React 网页应用(包含一个聊天页面和仅限开发环境的 /gallery 页面),不是可以导入其他项目的库。UI 基础组件和提示词逻辑都位于本应用自己的源码目录中。
我该怎么让它跑起来?将 .env.example 复制为 .env 并设置所需变量后,运行 npm install && npm run dev。
用它需要 API 密钥吗?需要,除非你选择其他方式。默认情况下,需要 THESYSAPIKEY 来使用 OpenUI Cloud;你也可以把 LLMBASEURL/LLMAPIKEY/LLMMODEL 指向任意兼容 OpenAI 的 API(例如 OpenRouter),或设置 MODELPROVIDER=ollama 来运行完全本地的模型,无需任何密钥。
本地的 Ollama 方案开箱即用吗?基本可以,但 Ollama 默认的上下文窗口为 4,096 个 token,而本应用的 OpenUI 提示词约为 8,000 个 token。因此,除非你调大窗口,提示词会被悄悄截断,生成的界面也会出错。另外,本地模型会跳过 Gateway 的输出修正步骤,所以结果更依赖模型本身的质量。
我的聊天记录存在哪里?聊天线程和消息(包括你在回答中输入或勾选的任何内容)仅保存在浏览器的 localStorage 中。因此刷新页面后依然保留,但数据只存在于客户端。
OpenUI Lang 是什么?这是模型输出的流式格式。应用使用一套可自动排列的基础组件库来渲染它,而不是固定的页面布局。该组件库包括布局、文本、输入、媒体、图表、地图、绘图以及 59 个辅助函数。
/gallery 页面里有什么?这是仅限开发环境的页面,包含手写的 OpenUI 程序,涵盖全部 16 个原始 Intelligent UI 示例(从自行车路线到街机游戏)、两个数据仪表盘,以及用于测试每个组件的测试用例。
回答中的照片是怎么获取的?SearchImage 组件会调用内部的 /api/wiki 和 /api/image-search 路由,查找匹配的维基百科条目,并从维基百科和 Wikimedia Commons 获取主图。
地图路线是从哪里来的?街道几何数据通过 /api/street-route 从公共 OSRM 演示服务器的驾车配置文件获取,并会进行缓存。它只提供道路概览,不提供步行或公共交通路线。如果 OSRM 不可用,则会回退为一条带标注的直线。
有哪些类似的项目?OpenIntelligentUI, CopilotKit, NextChat, tambo, dsh-genui, mdxcn, nivo, ai
作者
thesysdev
大小
34.9 MB
星标
1K
更新
提交Nov 17
时长
1个月
提交 · 90 天