dsh-hduhelp-ai 0.1.0 → 0.1.2
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 +127 -103
- package/docs/icon.png +0 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,78 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="docs/icon.png" width="96" alt="dsh-hduhelp-ai">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">dsh-hduhelp-ai</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
把杭电助手的 AI 网关接进 DeepSeek Harness。面板里用学号密码登录,选几个模型,剩下的交给 agent。
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/dsh-hduhelp-ai">
|
|
13
|
+
<img src="https://img.shields.io/badge/npm-dsh--hduhelp--ai-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="npm">
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="https://github.com/AlaIchhe/dsh-hduhelp-ai/releases/latest"><img src="https://img.shields.io/github/v/release/AlaIchhe/dsh-hduhelp-ai?label=release&style=flat-square" alt="Release"></a>
|
|
19
|
+
<a href="https://www.npmjs.com/package/dsh-hduhelp-ai"><img src="https://img.shields.io/npm/v/dsh-hduhelp-ai?style=flat-square" alt="npm"></a>
|
|
20
|
+
<a href="https://github.com/AlaIchhe/dsh-hduhelp-ai/actions"><img src="https://img.shields.io/github/actions/workflow/status/AlaIchhe/dsh-hduhelp-ai/publish.yml?branch=master&label=CI&style=flat-square" alt="CI"></a>
|
|
21
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/AlaIchhe/dsh-hduhelp-ai?style=flat-square" alt="License"></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p align="center">
|
|
25
|
+
<sub>一条命令装进 DSH:<code>dsh plugin --profile web add dsh-hduhelp-ai</code></sub>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="docs/screenshot.png" width="720" alt="设置面板">
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
## 能做什么
|
|
35
|
+
|
|
36
|
+
<table>
|
|
37
|
+
<tr>
|
|
38
|
+
<td width="50%" valign="top">
|
|
39
|
+
<strong>面板登录</strong><br>
|
|
40
|
+
设置里填学号和统一身份认证密码,走杭电 CAS 换 token,纯 HTTP 不需要浏览器,通常不到 1 秒。
|
|
41
|
+
</td>
|
|
42
|
+
<td width="50%" valign="top">
|
|
43
|
+
<strong>只注册你选的模型</strong><br>
|
|
44
|
+
上游目录有 77 个模型,插件只把勾选的那几个注册进 DSH 模型列表,选择器保持干净。
|
|
45
|
+
</td>
|
|
46
|
+
</tr>
|
|
47
|
+
<tr>
|
|
48
|
+
<td width="50%" valign="top">
|
|
49
|
+
<strong>原生多轮工具调用</strong><br>
|
|
50
|
+
走 Responses 协议的 <code>function_call</code> / <code>function_call_output</code>,思考—调用—观察的 ReAct 循环不降级。
|
|
51
|
+
</td>
|
|
52
|
+
<td width="50%" valign="top">
|
|
53
|
+
<strong>额度就在手边</strong><br>
|
|
54
|
+
输入框工具行、权限按钮右侧显示 5 小时 / 7 天两个窗口的用量;额度用尽时显示恢复倒计时。
|
|
55
|
+
</td>
|
|
56
|
+
</tr>
|
|
57
|
+
<tr>
|
|
58
|
+
<td width="50%" valign="top">
|
|
59
|
+
<strong>OpenAI 兼容反代</strong><br>
|
|
60
|
+
额外提供 <code>http://<host>:8787/v1</code>,chat/completions 自动翻译成 Responses,供 Cherry Studio / LobeChat / SDK 使用。
|
|
61
|
+
</td>
|
|
62
|
+
<td width="50%" valign="top">
|
|
63
|
+
<strong>登录态自维护</strong><br>
|
|
64
|
+
token 过期用 refresh_token 自动续;刷新失败会在面板里留下可读的错误。
|
|
65
|
+
</td>
|
|
66
|
+
</tr>
|
|
67
|
+
</table>
|
|
68
|
+
|
|
69
|
+
<p align="center">
|
|
70
|
+
<img src="docs/screenshot-quota.png" width="420" alt="额度胶囊">
|
|
71
|
+
</p>
|
|
72
|
+
|
|
73
|
+
## 开始使用
|
|
74
|
+
|
|
75
|
+
1. 装插件:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
dsh plugin --profile web add dsh-hduhelp-ai
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
2. 在 `~/.dsh/profiles/<profile>/cordis.patch.yml` 末尾加一条 loader 入口:
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
- insert:
|
|
85
|
+
- id: hduhelp-ai
|
|
86
|
+
name: 'dsh-hduhelp-ai'
|
|
87
|
+
config:
|
|
88
|
+
port: 8787
|
|
89
|
+
apiKey: sk-hduhelp
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
3. 打开 DSH 设置 →「杭电助手 AI」,用学号 + 数字杭电密码登录。
|
|
93
|
+
|
|
94
|
+
4. 在「模型注册」里勾选要用的模型并保存;回到聊天,在输入框上方的模型选择器里选「杭电助手」。
|
|
95
|
+
|
|
96
|
+
> [!NOTE]
|
|
97
|
+
> 插件的文本用途走 **Responses** 协议(`/openai/v1/responses`),走 chat/completions 会被上游拒绝;
|
|
98
|
+
> 反代那边已经做了翻译,所以普通 OpenAI 客户端不用关心这件事。
|
|
99
|
+
|
|
100
|
+
> [!IMPORTANT]
|
|
101
|
+
> 账号密码只用于换取 token,不落盘:`~/.dsh/hduhelp-ai/token.json` 里只有 access/refresh token(0600)。
|
|
102
|
+
> 面板接口要求 `X-DSH-HDUHelp: 1` 头并校验 Host,跨站页面无法静默调用。
|
|
103
|
+
> 反代默认监听 `0.0.0.0:8787`,只建议在内网使用;公网部署请改成 `127.0.0.1` 或加前置鉴权。
|
|
104
|
+
> 本项目只做协议转换与本地反代,请在你的账号额度内使用,并遵守学校与杭电助手的使用规则。
|
|
105
|
+
|
|
106
|
+
## 反代
|
|
71
107
|
|
|
72
108
|
| 路由 | 说明 |
|
|
73
109
|
|---|---|
|
|
74
110
|
| `GET /v1/models` | 上游模型目录 |
|
|
75
|
-
| `POST /v1/chat/completions` | 翻译成 Responses
|
|
111
|
+
| `POST /v1/chat/completions` | 翻译成 Responses,流式 / 非流式都支持 |
|
|
76
112
|
| `POST /v1/responses` | 原样透传 |
|
|
77
113
|
| `POST /v1/embeddings`、`/v1/images/*`、`/v1/rerank` | 透传 |
|
|
78
114
|
|
|
@@ -87,57 +123,45 @@ API Key 默认 `sk-hduhelp`,也可以直接把 `access_token` 当 key 传。
|
|
|
87
123
|
|
|
88
124
|
## 配置
|
|
89
125
|
|
|
90
|
-
`cordis.patch.yml` 的 `config`:
|
|
91
|
-
|
|
92
126
|
| 键 | 默认 | 说明 |
|
|
93
127
|
|---|---|---|
|
|
94
128
|
| `port` | `8787` | 反代端口,`0` 表示不自动启动 |
|
|
95
|
-
| `host` | `0.0.0.0` |
|
|
129
|
+
| `host` | `0.0.0.0` | 反代监听地址 |
|
|
96
130
|
| `purpose` | `app.mate.chat` | 固定用途,插件只暴露 chat 这一条入口 |
|
|
97
131
|
| `apiKey` | `sk-hduhelp` | 客户端用的 key |
|
|
98
132
|
| `defaultModel` | 空 | 请求没带 model 时补的值 |
|
|
99
133
|
| `dataDir` | `~/.dsh/hduhelp-ai` | token / 勾选集 / 模型缓存目录 |
|
|
100
134
|
|
|
101
|
-
##
|
|
135
|
+
## 工作原理
|
|
102
136
|
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
→ GET
|
|
106
|
-
→ CAS
|
|
107
|
-
→ POST /login 表单(AES-128-ECB + PKCS#7
|
|
137
|
+
```text
|
|
138
|
+
学号 + 密码
|
|
139
|
+
→ GET /identity/login/url?grant-key=cas&client_id=poplar
|
|
140
|
+
→ 解析 CAS 登录页的 login-croypto(AES key) 与 flowkey
|
|
141
|
+
→ POST /login 表单(AES-128-ECB + PKCS#7 加密,captcha_payload=AES("{}"))
|
|
108
142
|
→ 302 → /identity/login/sso?state&ticket → /auth/callback?code=
|
|
109
143
|
→ POST /identity/login/exchange {code} → access_token / refresh_token
|
|
110
144
|
```
|
|
111
145
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
```
|
|
115
|
-
{api}/purposes/app.mate.chat/openai/v1/responses
|
|
116
|
-
Authorization: Bearer <access_token>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
额度是响应头带回来的:
|
|
120
|
-
|
|
121
|
-
```
|
|
122
|
-
x-hduhelp-quota-5h-utilization / x-hduhelp-quota-5h-reset
|
|
123
|
-
x-hduhelp-quota-7d-utilization / x-hduhelp-quota-7d-reset
|
|
124
|
-
retry-after (仅 429)
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## 安全
|
|
128
|
-
|
|
129
|
-
- 面板接口要求 `X-DSH-HDUHelp: 1` 头 + Host 白名单,且不发 CORS 头,跨站页面无法静默调用;
|
|
130
|
-
- 密码只在登录子进程的环境变量里出现一次,不落盘;token/勾选文件 0600;
|
|
131
|
-
- 反代默认监听 `0.0.0.0`,只在内网使用;公网部署请改 `127.0.0.1` 或加前置鉴权。
|
|
146
|
+
额度来自响应头:`x-hduhelp-quota-5h-utilization` / `-5h-reset`、`x-hduhelp-quota-7d-*`,429 时附 `retry-after`。
|
|
132
147
|
|
|
133
148
|
## 卸载
|
|
134
149
|
|
|
135
150
|
```bash
|
|
136
151
|
dsh plugin --profile web remove dsh-hduhelp-ai
|
|
137
152
|
rm -rf ~/.dsh/hduhelp-ai
|
|
138
|
-
# 再删掉 cordis.patch.yml 里的 hduhelp-ai 条目
|
|
139
153
|
```
|
|
140
154
|
|
|
141
|
-
|
|
155
|
+
再删掉 `cordis.patch.yml` 里的 `hduhelp-ai` 条目。
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
<p align="center">
|
|
160
|
+
<a href="https://github.com/AlaIchhe/dsh-hduhelp-ai/issues">反馈</a> ·
|
|
161
|
+
<a href="LICENSE">License</a> ·
|
|
162
|
+
<a href="https://www.npmjs.com/package/dsh-hduhelp-ai">npm</a>
|
|
163
|
+
</p>
|
|
142
164
|
|
|
143
|
-
|
|
165
|
+
<p align="center">
|
|
166
|
+
<sub>把学校的 AI 额度,接到自己的 agent 上。<br>省下来的时间,拿去写点更有意思的东西。</sub>
|
|
167
|
+
</p>
|
package/docs/icon.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hduhelp-ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "杭电助手(HDUHelp)AI 网关接入 DeepSeek Harness:面板里用学号密码走 CAS 登录,模型注册进 DSH 模型列表,另提供 OpenAI 兼容反代。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -58,5 +58,6 @@
|
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"icon": "docs/icon.png"
|
|
62
63
|
}
|