d36b940981
test / pytest (push) Successful in 1m13s
Add app_settings migration, settings UI, and OpenAI-compatible httpx LLM client with mocked tests. Preserve API keys on blank form submissions, require a fresh key when base_url changes, and keep AI search settings untouched for step 3. Update docs/design LLM integration and step 3 AI search notes, including prompt contract and extra-hints planning.
56 lines
1.9 KiB
HTML
56 lines
1.9 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<div class="breadcrumb">
|
|
<a href="/boxes">箱子</a>
|
|
<span>/</span>
|
|
<strong>设置</strong>
|
|
</div>
|
|
<div class="page-header">
|
|
<div>
|
|
<h1>设置</h1>
|
|
<p class="muted">配置 LLM 连接参数。未配置时,整站行为不受影响。</p>
|
|
</div>
|
|
</div>
|
|
|
|
{% if test_result %}
|
|
<section class="card" style="margin-bottom: 16px; border-color: {% if test_result.success %}#2f6b1f{% else %}#b42318{% endif %};">
|
|
<p style="margin:0; color: {% if test_result.success %}#2f6b1f{% else %}#b42318{% endif %};">
|
|
<strong>{{ "✓ " if test_result.success else "✗ " }}{{ test_result.message }}</strong>
|
|
</p>
|
|
</section>
|
|
{% endif %}
|
|
|
|
<form method="post" action="/settings" class="stack form-panel">
|
|
<label class="form-field checkbox-row">
|
|
<input type="checkbox" name="enabled" {% if config.enabled %}checked{% endif %}>
|
|
启用 LLM
|
|
</label>
|
|
<p class="checkbox-help">开启后,AI 相关功能将使用下方配置连接 LLM 服务。</p>
|
|
|
|
<label class="form-field">
|
|
Base URL
|
|
<input type="text" name="base_url" value="{{ config.base_url }}" placeholder="https://api.openai.com/v1">
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
模型名称
|
|
<input type="text" name="model" value="{{ config.model }}" placeholder="例如 gpt-4o-mini">
|
|
</label>
|
|
|
|
<label class="form-field">
|
|
API Key
|
|
{% if api_key_configured %}
|
|
<input type="password" name="api_key" value="" placeholder="已配置,留空=不修改">
|
|
{% else %}
|
|
<input type="password" name="api_key" value="" placeholder="输入 API Key">
|
|
{% endif %}
|
|
</label>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="button button-primary">保存设置</button>
|
|
<button type="submit" class="button button-secondary" formaction="/settings/test" formmethod="post">测试连接</button>
|
|
</div>
|
|
</form>
|
|
{% endblock %}
|