Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 8 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ OCEANBASE_PORT=2881
OCEANBASE_USER=root
OCEANBASE_PASSWORD=
OCEANBASE_DATABASE=bub
BUB_TAPE_TABLE=bub_tape_entries
# Optional explicit override. If unset, entrypoint derives:
# mysql+oceanbase://OCEANBASE_USER:OCEANBASE_PASSWORD@OCEANBASE_HOST:OCEANBASE_PORT/OCEANBASE_DATABASE
# BUB_TAPESTORE_SQLALCHEMY_URL=

# Bub runtime
BUB_MODEL=openai:qwen-plus
BUB_MAX_TOKENS=2048
# Optional explicit tape namespace for session keys
# BUB_TAPE_NAME=endless-context
BUB_GRADIO_HOST=0.0.0.0
BUB_GRADIO_PORT=7860

# LLM credentials (Bub resolves from BUB_API_KEY / LLM_API_KEY / OPENROUTER_API_KEY)
LLM_API_KEY=your_api_key_here
LLM_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
# LLM credentials
BUB_API_KEY=your_api_key_here
BUB_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
13 changes: 8 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM quay.io/oceanbase/seekdb:latest
ENV DEBIAN_FRONTEND=noninteractive

RUN if command -v yum >/dev/null 2>&1; then \
yum install -y --allowerasing curl ca-certificates python3 python3-pip python3.12 python3.12-pip && \
yum install -y --allowerasing curl git ca-certificates python3 python3-pip python3.12 python3.12-pip && \
yum clean all; \
else \
echo "No supported package manager found." && exit 1; \
Expand All @@ -20,7 +20,9 @@ ENV UV_INDEX_STRATEGY=unsafe-first-match

RUN python3.12 -m pip install --no-cache-dir -U uv -i "${PIP_INDEX_URL}"

ENV PATH="/root/.local/bin:${PATH}"
ENV PATH="/app/.venv/bin:/root/.local/bin:${PATH}"
ENV BUB_HOME=/app/.bub
ENV BUB_WORKSPACE_PATH=/app

WORKDIR /app

Expand All @@ -33,10 +35,11 @@ COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
COPY docker/setup-bub-workspace.py /usr/local/bin/setup-bub-workspace.py

RUN chmod +x /usr/local/bin/entrypoint.sh
RUN uv sync --frozen --python python3.12 --no-dev --default-index "${PIP_INDEX_URL}"
RUN uv venv --python python3.12 /app/.venv
RUN UV_PROJECT_ENVIRONMENT=/app/.venv uv sync --frozen --python python3.12 --no-dev --default-index "${PIP_INDEX_URL}"

ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
ENV BUB_GRADIO_HOST=0.0.0.0
ENV BUB_GRADIO_PORT=7860
ENV OCEANBASE_HOST=127.0.0.1
ENV OCEANBASE_PORT=2881

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export: ## Export requirements.txt from uv.lock

.PHONY: run
run: ## Run the Gradio app
@uv run python app.py
@.venv/bin/python app.py

.PHONY: test
test: ## Run tests
@uv run pytest
@.venv/bin/pytest

.PHONY: check
check: ## Run code quality checks
Expand Down
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ license: Apache License 2.0

A lightweight Gradio chat agent with tape-first context management powered by Bub, SeekDB, and OceanBase. Built to be ModelScope-friendly while staying easy to run locally.

## What it is
It provides:

- Bub runtime for deterministic loop/tool routing and tape-first orchestration
- SeekDB-backed persistent tape store via pyobvector dialect
- Three-pane Gradio UI (Tape / Conversation / Anchors) with context-window indicator
- Works out of the box on ModelScope Docker Studio via the included `Dockerfile`
- Supports OpenAI, Qwen (via OpenAI-compatible API base), and other any-llm compatible providers
- a `gradio` Bub channel for browser chat
- OceanBase/seekdb dialect registration compatible with `bub-tapestore-sqlalchemy`
- a ModelScope-friendly `app.py` that boots Bub's `ChannelManager` with `gradio` enabled
- the original three-pane Gradio UI/UX for tape, conversation, and anchors

The old private `AppRuntime`, custom tape store, and monkey patches inside the app layer have been removed.

## Run on ModelScope Docker Studio

1) Keep the provided `Dockerfile` and `docker/entrypoint.sh` (they start SeekDB and the app).
1) Keep the provided `Dockerfile` and `docker/entrypoint.sh`.
2) Exposed ports: `7860` (Gradio) and `2881` (SeekDB). Entry file is `app.py`.
3) Set environment secrets in Studio, e.g. `BUB_MODEL`, `LLM_API_KEY`, `LLM_API_BASE`, `OCEANBASE_HOST`, `OCEANBASE_PORT`, `OCEANBASE_USER`, `OCEANBASE_PASSWORD`, `OCEANBASE_DATABASE`, and optional `BUB_TAPE_TABLE`.
4) Build and run; open the forwarded `7860` port to use the chat UI.
3) Set environment secrets in Studio, e.g. `BUB_MODEL`, `BUB_API_KEY`, `BUB_API_BASE`, `BUB_TAPESTORE_SQLALCHEMY_URL`, and the `OCEANBASE_*` values required by your seekdb deployment.
4) Build and run. `app.py` starts Bub's channel manager with `gradio` enabled, so opening the forwarded `7860` port reaches the Bub channel directly.

## Run locally (preferred: Docker)

Expand All @@ -45,7 +46,7 @@ A lightweight Gradio chat agent with tape-first context management powered by Bu
cp .env.example .env # fill in keys
make compose-up # builds and starts everything
```
The UI is at `http://localhost:7860`. Stop with `make compose-down`.
The UI is at `http://localhost:7860`. In Compose mode, SeekDB is only exposed on the internal Docker network so local port conflicts on `2881` do not block startup. Stop with `make compose-down`.

### Single container
```bash
Expand All @@ -60,6 +61,16 @@ cp .env.example .env
make run
```

### Bub CLI shape

`app.py` starts the same shape you would get from:

```bash
uv run bub gateway --enable-channel gradio
```

That keeps the runtime aligned with Bub's extension model instead of a project-local forked runtime.

## Docs

- `docs/index.md` contains architecture, local/Docker workflows, and configuration details.
Expand Down
Loading
Loading