feat: Agnes上下文512K→1M + Ollama支持配置num_ctx

Agnes AI:
- adapter注释和API文档更新: 上下文512K→1M (官方已升级)

Ollama num_ctx 支持:
- MetonaGenerationParams 新增 contextLength 字段
- OllamaAdapter.toNativeRequest 发送 options.num_ctx
- AgentLoopEngine 从 config 读取并传递到请求参数
- database.service 新增 ollama.numCtx 默认配置(null=由模型决定)
- SettingsModal LLM设置: Ollama 选中时显示上下文长度输入框
- main.ts 启动时从 configService 读取 ollama.numCtx

数据流:
Settings → configService → main.ts → AgentLoopEngine.config
→ MetonaRequest.params → OllamaAdapter → options.num_ctx
This commit is contained in:
thzxx
2026-06-27 21:57:05 +08:00
parent 8b3dc4298d
commit e4c0259afc
9 changed files with 32 additions and 4 deletions
+15
View File
@@ -101,6 +101,7 @@ function LLMSettings() {
const [model, setModel] = useConfig('llm.model', '');
const [apiKey, setApiKey] = useConfig('llm.apiKey', '');
const [baseURL, setBaseURL] = useConfig('llm.baseURL', '');
const [numCtx, setNumCtx] = useConfig('ollama.numCtx', null as number | null);
const [showKey, setShowKey] = useState(false);
return (
@@ -118,6 +119,20 @@ function LLMSettings() {
<TextField size="small" label="API Key" type={showKey ? 'text' : 'password'} value={apiKey} onChange={(e) => setApiKey(e.target.value)} placeholder="sk-...(本地模型可留空)"
slotProps={{ input: { endAdornment: <IconButton size="small" onClick={() => setShowKey(!showKey)}>{showKey ? <EyeOff size={14} /> : <Eye size={14} />}</IconButton> } }}
/>
{provider === 'ollama' && (
<TextField
size="small"
label="上下文长度 (num_ctx)"
type="number"
value={numCtx ?? ''}
onChange={(e) => {
const v = e.target.value;
setNumCtx(v === '' ? null : Number(v));
}}
placeholder="默认由模型决定(如 2048、4096、128000"
slotProps={{ htmlInput: { min: 512, step: 512 } }}
/>
)}
</Stack>
);
}