billion-context 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -62,6 +62,19 @@ so you don't have to invent the schema from scratch:
62
62
  [acp-config] created empty config at ~/.config/billion-context/billion-context.json — add your providers (see README Quickstart), then restart
63
63
  ```
64
64
 
65
+ **Or configure via the web UI** (easier): open `http://localhost:8787/__acp/` in
66
+ a browser while the proxy is running — edit providers in a form, and get
67
+ copy-ready config snippets for Pi / OpenCode / Codex. The startup banner prints
68
+ this URL too:
69
+
70
+ ```
71
+ acp-proxy listening on http://localhost:8787 — web UI: http://localhost:8787/__acp/
72
+ ```
73
+
74
+ This is the recommended path for first-time setup. (Prefer editing the JSON
75
+ file directly — e.g. for git-managed or scripted deployments? See
76
+ [Manual config file](#manual-config-file) below.)
77
+
65
78
  ### How routing works
66
79
 
67
80
  The proxy routes by a **provider name in the URL path** — the first path
@@ -86,40 +99,20 @@ to send each request. In the config below, `zhipu` corresponds to:
86
99
  }
87
100
  ```
88
101
 
89
- ### Step 2 — Edit the config file
90
-
91
- Open the file from Step 1 (`~/.config/billion-context/billion-context.json`)
92
- and edit the `providers` block to match what you pay for. Each entry is a
93
- **name → URL** mapping; the name is what you'll put in the client's base URL in
94
- Step 3.
95
-
96
- ```json
97
- {
98
- "providers": {
99
- "zhipu": {
100
- "url": "https://open.bigmodel.cn",
101
- "models": {
102
- "glm-5.2": { "context": 1000000, "output": 131072 }
103
- }
104
- },
105
- "anthropic": "https://api.anthropic.com"
106
- }
107
- }
108
- ```
109
-
110
- - Delete providers you don't use.
111
- - Add others (e.g. `"deepseek": "https://api.deepseek.com"`).
112
- - The API key is **not** here — it lives in the client; the proxy passes it
113
- through untouched.
102
+ ### Step 2 — Configure your providers
114
103
 
115
- After saving, **restart `bili`**. The startup banner lists your routes:
104
+ Open the **web UI** at `http://localhost:8787/__acp/` and add your providers
105
+ there (add provider → fill name + URL + per-model context → Save). This writes
106
+ to `~/.config/billion-context/billion-context.json` directly. Then **restart
107
+ `bili`** — the startup banner lists your routes:
116
108
 
117
109
  ```
118
- acp-proxy listening on http://127.0.0.1:8787 — routes: anthropic=https://api.anthropic.com, zhipu=https://open.bigmodel.cn
110
+ acp-proxy listening on http://localhost:8787 — routes: anthropic=https://api.anthropic.com, zhipu=https://open.bigmodel.cn
119
111
  ```
120
112
 
121
- That confirms the proxy picked up your config. (Full schema per-model context
122
- windows, optional fields is in [Configuration](#configuration).)
113
+ That confirms the proxy picked up your config. (Prefer editing the JSON file by
114
+ hand? See [Manual config file](#manual-config-file). Full schema — per-model
115
+ context windows, optional fields — is in [Configuration](#configuration).)
123
116
 
124
117
  ### Step 3 — Point your client at the proxy
125
118
 
@@ -187,6 +180,48 @@ Not yet supported. The proxy currently speaks the Anthropic, OpenAI
187
180
  chat-completions, and OpenAI Responses protocols — if your client uses a
188
181
  different protocol or a non-standard auth header, it won't work yet.
189
182
 
183
+ ### Web UI
184
+
185
+ Open `http://localhost:8787/__acp/` in a browser while the proxy is running. You can:
186
+
187
+ - **Edit providers** in a form (add/remove providers and per-model context windows) and save — this writes to `billion-context.json` directly.
188
+ - **Generate client URLs** — pick a provider, get ready-to-copy config snippets for Pi / OpenCode / Codex (the `baseUrl`/`baseURL`/`base_url` line with the proxy origin + provider name filled in).
189
+ - **View sessions** — live table of active sessions (requests, tokens saved, last seen), auto-refreshing.
190
+
191
+ Changes to providers require a **restart** to take effect (the UI tells you this).
192
+
193
+ ### Manual config file
194
+
195
+ Prefer editing JSON by hand — for git-managed configs, scripted deployments, or
196
+ if you just don't want to use the browser? The web UI writes to the same file,
197
+ so you can edit it directly with identical results.
198
+
199
+ Open `~/.config/billion-context/billion-context.json` and edit the `providers`
200
+ block. Each entry is a **name → URL** mapping; the name is what you put in the
201
+ client's base URL in Step 3.
202
+
203
+ ```json
204
+ {
205
+ "providers": {
206
+ "zhipu": {
207
+ "url": "https://open.bigmodel.cn",
208
+ "models": {
209
+ "glm-5.2": { "context": 1000000, "output": 131072 }
210
+ }
211
+ },
212
+ "anthropic": "https://api.anthropic.com"
213
+ }
214
+ }
215
+ ```
216
+
217
+ - Delete providers you don't use.
218
+ - Add others (e.g. `"deepseek": "https://api.deepseek.com"`).
219
+ - The API key is **not** here — it lives in the client; the proxy passes it
220
+ through untouched.
221
+
222
+ After saving, **restart `bili`**. (Full schema — per-model context windows,
223
+ optional fields — is in [Configuration](#configuration).)
224
+
190
225
  ### Verify
191
226
 
192
227
  With the proxy running and your config saved, check it answers and that your
package/README.zh-CN.md CHANGED
@@ -53,67 +53,16 @@ bili
53
53
 
54
54
  它监听 `http://127.0.0.1:8787`。保持这个终端开着(或后台运行,见[运行代理](#运行代理))。
55
55
 
56
- 首次运行 `bili` 会**自动创建一份空的配置文件**,并告诉你路径:
57
-
58
- ```
59
- [acp-config] created empty config at ~/.config/billion-context/billion-context.json — add your providers (see README Quickstart), then restart
60
- ```
61
-
62
- ### 路由怎么工作
63
-
64
- 代理按 **URL 路径里的 provider 名**路由 —— host 后面的第一段路径。它会
65
- 剥离该名字,把剩余部分转发给那个 provider。名字之后的整段路径原样透传:
66
-
67
- ```
68
- 客户端 baseURL: http://localhost:8787/zhipu/api/coding/paas/v4
69
- └──────────┬──────────┘└────────┬────────┘
70
- 代理 host 剩余路径
71
- + provider 名 (原样转发)
72
- ```
73
-
74
- 这就是为什么第 2 步让你声明带名字的 provider、第 3 步又让你把同样的名字
75
- 放在客户端 base URL 的开头 —— 代理凭这个知道每条请求发到哪。
76
- 稍后在配置文件中,`zhipu` 对应的是:
77
- ```json
78
- "zhipu": {
79
- "url": "https://open.bigmodel.cn",
80
- "models": {
81
- "glm-5.2": { "context": 1000000, "output": 131072 }
82
- }
83
- ```
84
-
56
+ 点击[http://localhost:8787/__acp/](http://localhost:8787/__acp/) 添加你的模型
57
+ <img width="2908" height="1787" alt="image" src="https://github.com/user-attachments/assets/cacf4b64-e5c6-41f2-b270-fd2be02eab0c" />
85
58
 
86
59
  ### 第 2 步 —— 编辑配置文件
87
60
 
88
- 打开第 1 步创建的文件(`~/.config/billion-context/billion-context.json`),
89
- 编辑 `providers` 块,填入你付费使用的 provider。每个条目是一个
90
- **名字 → URL** 映射;这个名字就是你在第 3 步里写进客户端 base URL 的东西。
61
+ 复制以下内容
91
62
 
92
- ```json
93
- {
94
- "providers": {
95
- "zhipu": {
96
- "url": "https://open.bigmodel.cn",
97
- "models": {
98
- "glm-5.2": { "context": 1000000, "output": 131072 }
99
- }
100
- },
101
- "anthropic": "https://api.anthropic.com",
102
- }
103
- }
104
- ```
63
+ <img width="2931" height="1519" alt="image" src="https://github.com/user-attachments/assets/c02278be-bc7a-4f14-8f58-0f2d83784d54" />
105
64
 
106
- - 删掉你不用的 provider
107
- - 添加其他的(例如 `"deepseek": "https://api.deepseek.com"`)。
108
- - API key **不**写在这里 —— key 在客户端那边,代理原样透传。
109
-
110
- 保存后**重启 `bili`**。启动行列出你的路由:
111
-
112
- ```
113
- acp-proxy listening on http://127.0.0.1:8787 — routes: anthropic=https://api.anthropic.com, zhipu=https://open.bigmodel.cn
114
- ```
115
-
116
- 这证明代理读到了你的配置。(完整 schema —— 按模型的 context 窗口、可选字段 —— 见[配置](#配置)。)
65
+ > 不想用网页?也可以直接手编 JSON 文件,见下文[手动配置文件](#手动配置文件)
117
66
 
118
67
  ### 第 3 步 —— 把客户端指向代理
119
68
 
@@ -178,6 +127,51 @@ base_url = "http://localhost:8787/zhipu/api/coding/paas/v4"
178
127
  暂不支持。代理目前说 Anthropic、OpenAI chat-completions、OpenAI Responses
179
128
  三种协议 —— 如果你的客户端用别的协议或非标准 auth header,还用不了。
180
129
 
130
+ ### 手动配置文件
131
+
132
+ 上面用网页配置。如果你不想用网页、想把配置纳入 git 管理、或者用脚本
133
+ 自动化部署,也可以直接手编 JSON 文件,效果完全一样。
134
+
135
+ 打开 `~/.config/billion-context/billion-context.json`,编辑 `providers` 块。
136
+ 每个条目是一个**名字 → URL** 映射;这个名字就是你在第 3 步里写进客户端
137
+ base URL 的东西。
138
+
139
+ ```json
140
+ {
141
+ "providers": {
142
+ "zhipu": {
143
+ "url": "https://open.bigmodel.cn",
144
+ "models": {
145
+ "glm-5.2": { "context": 1000000, "output": 131072 }
146
+ }
147
+ },
148
+ "anthropic": "https://api.anthropic.com"
149
+ }
150
+ }
151
+ ```
152
+
153
+ - 删掉你不用的 provider。
154
+ - 添加其他的(例如 `"deepseek": "https://api.deepseek.com"`)。
155
+ - API key **不**写在这里 —— key 在客户端那边,代理原样透传。
156
+
157
+ 保存后**重启 `bili`**。启动行列出你的路由:
158
+
159
+ ```
160
+ acp-proxy listening on http://127.0.0.1:8787 — routes: anthropic=https://api.anthropic.com, zhipu=https://open.bigmodel.cn
161
+ ```
162
+
163
+ 这证明代理读到了你的配置。(完整 schema —— 按模型的 context 窗口、可选字段 —— 见[配置](#配置)。)
164
+
165
+ ### 网页配置
166
+
167
+ 代理跑着的时候,在浏览器打开 `http://localhost:8787/__acp/`。你可以:
168
+
169
+ - **编辑 providers** —— 用表单增删 provider 和按模型的 context 窗口,点 Save 直接写入 `billion-context.json`。
170
+ - **生成客户端 URL** —— 选一个 provider,得到可直接复制的配置片段(Pi / OpenCode / Codex 的 `baseUrl`/`baseURL`/`base_url` 一行,已填好代理地址 + provider 名)。
171
+ - **查看会话** —— 实时会话表(请求数、省的 token、最后活跃时间),自动刷新。
172
+
173
+ 改完 providers 需要**重启 bili** 才生效(UI 会提醒你)。
174
+
181
175
  ### 验证
182
176
 
183
177
  代理跑着、配置保存了之后,确认它能应答,并且第一个真实请求在日志里显示压缩活动: