增加注入提示词功能
This commit is contained in:
parent
f193c48ce1
commit
ae059ffcb8
10 changed files with 160 additions and 20 deletions
|
|
@ -19,8 +19,8 @@ code{background:var(--input);padding:1px 5px;border-radius:4px;font-size:12px;fo
|
|||
.field{margin-bottom:16px}
|
||||
.field label{display:block;font-size:13px;color:var(--muted);margin-bottom:6px;font-weight:500}
|
||||
.input-wrap{position:relative}
|
||||
.input-wrap input,.input-wrap select{width:100%;background:var(--input);border:1px solid var(--border);border-radius:8px;padding:10px 14px;color:var(--text);font-size:14px;outline:none;transition:border-color .2s}
|
||||
.input-wrap input:focus,.input-wrap select:focus{border-color:var(--primary)}
|
||||
.input-wrap input,.input-wrap select,.input-wrap textarea{width:100%;background:var(--input);border:1px solid var(--border);border-radius:8px;padding:10px 14px;color:var(--text);font-size:14px;outline:none;transition:border-color .2s}
|
||||
.input-wrap input:focus,.input-wrap select:focus,.input-wrap textarea:focus{border-color:var(--primary)}
|
||||
.input-wrap .eye{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:none;color:var(--muted);cursor:pointer;padding:4px;font-size:16px}
|
||||
select{cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238899ab'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center}
|
||||
|
||||
|
|
@ -61,6 +61,7 @@ main{padding:28px 0 60px}
|
|||
.tag-responses{background:rgba(59,130,246,.15);color:#60a5fa}
|
||||
.tag-auto{background:rgba(139,92,246,.15);color:#a78bfa}
|
||||
.tag-override{background:rgba(59,130,246,.1);color:var(--primary)}
|
||||
.tag-instructions{background:rgba(234,179,8,.15);color:var(--yellow)}
|
||||
.mapping-actions{margin-left:auto;display:flex;gap:6px}
|
||||
.empty{text-align:center;padding:40px;color:var(--muted)}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,6 +115,24 @@
|
|||
<button class="eye" onclick="togglePwd('mKey')">👁</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>自定义指令 <span style="color:var(--muted)">(可选)</span></label>
|
||||
<div class="input-wrap"><textarea id="mInstructions" rows="5" placeholder="注入到请求中的自定义系统指令 Responses 格式 → 写入 instructions 字段(developer 级别) Chat Completions 格式 → 注入为首条 system 消息 Anthropic 格式 → 写入 system 字段" style="resize:vertical;min-height:80px"></textarea></div>
|
||||
<div class="hint">
|
||||
每个模型可单独配置。指令会被注入到发往上游的请求中,模型会无条件信任该内容。<br>
|
||||
适用场景:自定义人格、解除限制、注入 CTF 环境假设等。
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>注入位置</label>
|
||||
<div class="input-wrap">
|
||||
<select id="mInsPosition">
|
||||
<option value="prepend">前置(推荐,优先级更高)</option>
|
||||
<option value="append">后置</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="hint">前置:自定义指令放在系统提示词最前面,模型优先看到;后置:放在末尾</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-ghost" onclick="closeModal()">取消</button>
|
||||
<button class="btn btn-primary" id="modalSaveBtn" onclick="saveMapping()">保存</button>
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ async function loadMappings() {
|
|||
? 'responses'
|
||||
: backend;
|
||||
const hasOverride = m.target_url || m.api_key;
|
||||
const hasInstructions = !!m.custom_instructions;
|
||||
return `<div class="mapping-item">
|
||||
<div class="mapping-top">
|
||||
<span class="mapping-name">${esc(name)}</span>
|
||||
|
|
@ -145,6 +146,7 @@ async function loadMappings() {
|
|||
<div class="mapping-meta">
|
||||
<span class="tag ${tagClass}">${tagLabel}</span>
|
||||
${hasOverride ? '<span class="tag tag-override">自定义地址</span>' : ''}
|
||||
${hasInstructions ? '<span class="tag tag-instructions">自定义指令</span>' : ''}
|
||||
</div>
|
||||
<div class="mapping-actions">
|
||||
<button class="btn btn-ghost btn-sm" onclick="openEditModal('${esc(name)}')">编辑</button>
|
||||
|
|
@ -167,6 +169,8 @@ function openAddModal() {
|
|||
document.getElementById('mBackend').value = 'auto';
|
||||
document.getElementById('mUrl').value = '';
|
||||
document.getElementById('mKey').value = '';
|
||||
document.getElementById('mInstructions').value = '';
|
||||
document.getElementById('mInsPosition').value = 'prepend';
|
||||
document.getElementById('modal').classList.add('active');
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +187,8 @@ async function openEditModal(name) {
|
|||
document.getElementById('mBackend').value = m.backend || 'auto';
|
||||
document.getElementById('mUrl').value = m.target_url || '';
|
||||
document.getElementById('mKey').value = m.api_key || '';
|
||||
document.getElementById('mInstructions').value = m.custom_instructions || '';
|
||||
document.getElementById('mInsPosition').value = m.instructions_position || 'prepend';
|
||||
document.getElementById('modal').classList.add('active');
|
||||
} catch (e) {
|
||||
toast('错误: ' + e.message, false);
|
||||
|
|
@ -206,6 +212,8 @@ async function saveMapping() {
|
|||
backend: document.getElementById('mBackend').value,
|
||||
target_url: document.getElementById('mUrl').value.trim(),
|
||||
api_key: document.getElementById('mKey').value.trim(),
|
||||
custom_instructions: document.getElementById('mInstructions').value,
|
||||
instructions_position: document.getElementById('mInsPosition').value,
|
||||
};
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue