refactor(settings): 移除无效的配置项
- 移除 maxTokens/temperature 滑块(后端从不使用) - 移除 allowedPaths/deniedPaths 显示(权限通过 handler 处理) - Settings 面板只保留 workdir 和 Summary Model 配置
This commit is contained in:
@@ -13,23 +13,13 @@ import {
|
||||
|
||||
export const configRouter = new Hono();
|
||||
|
||||
// 服务器配置 (后续会从配置文件加载)
|
||||
// 服务器配置
|
||||
interface ServerConfig {
|
||||
model: string;
|
||||
maxTokens: number;
|
||||
temperature: number;
|
||||
workdir: string;
|
||||
allowedPaths: string[];
|
||||
deniedPaths: string[];
|
||||
}
|
||||
|
||||
let serverConfig: ServerConfig = {
|
||||
model: 'claude-sonnet-4-20250514',
|
||||
maxTokens: 8192,
|
||||
temperature: 0.7,
|
||||
workdir: process.cwd(),
|
||||
allowedPaths: [],
|
||||
deniedPaths: [],
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,12 +83,7 @@ export interface FileTreeResponse {
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
model: string;
|
||||
maxTokens: number;
|
||||
temperature: number;
|
||||
workdir: string;
|
||||
allowedPaths: string[];
|
||||
deniedPaths: string[];
|
||||
}
|
||||
|
||||
// ============ Command 相关 ============
|
||||
|
||||
@@ -13,7 +13,6 @@ import { modalOverlay, modalContent, smoothTransition } from '../utils/animation
|
||||
import { Button } from '../primitives/Button';
|
||||
import { Input } from '../primitives/Input';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../primitives/Select';
|
||||
import { Slider } from '../primitives/Slider';
|
||||
import { Skeleton } from './Skeleton';
|
||||
import {
|
||||
getConfig,
|
||||
@@ -30,14 +29,6 @@ interface ConfigPanelProps {
|
||||
responsive?: boolean;
|
||||
}
|
||||
|
||||
// 可用的模型列表
|
||||
const AVAILABLE_MODELS = [
|
||||
{ id: 'claude-sonnet-4-20250514', name: 'Claude Sonnet 4' },
|
||||
{ id: 'claude-3-5-sonnet-20241022', name: 'Claude 3.5 Sonnet' },
|
||||
{ id: 'claude-3-opus-20240229', name: 'Claude 3 Opus' },
|
||||
{ id: 'claude-3-haiku-20240307', name: 'Claude 3 Haiku' },
|
||||
];
|
||||
|
||||
// 摘要模型提供商列表
|
||||
const SUMMARY_PROVIDERS = [
|
||||
{ id: 'openai', name: 'OpenAI' },
|
||||
@@ -46,13 +37,6 @@ const SUMMARY_PROVIDERS = [
|
||||
{ id: 'openai-compatible', name: 'OpenAI Compatible' },
|
||||
];
|
||||
|
||||
// Temperature 语义标签
|
||||
function getTemperatureLabel(value: number): string {
|
||||
if (value <= 0.3) return 'Precise';
|
||||
if (value <= 0.7) return 'Balanced';
|
||||
return 'Creative';
|
||||
}
|
||||
|
||||
export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
const [config, setConfig] = useState<ServerConfig | null>(null);
|
||||
const [summaryConfig, setSummaryConfig] = useState<SummaryConfigInfo | null>(null);
|
||||
@@ -62,9 +46,6 @@ export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
|
||||
// 表单状态
|
||||
const [formData, setFormData] = useState({
|
||||
model: '',
|
||||
maxTokens: 8192,
|
||||
temperature: 0.7,
|
||||
workdir: '',
|
||||
});
|
||||
|
||||
@@ -88,9 +69,6 @@ export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
|
||||
setConfig(configResponse.data);
|
||||
setFormData({
|
||||
model: configResponse.data.model,
|
||||
maxTokens: configResponse.data.maxTokens,
|
||||
temperature: configResponse.data.temperature,
|
||||
workdir: configResponse.data.workdir,
|
||||
});
|
||||
|
||||
@@ -158,9 +136,6 @@ export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
const handleReset = () => {
|
||||
if (config) {
|
||||
setFormData({
|
||||
model: config.model,
|
||||
maxTokens: config.maxTokens,
|
||||
temperature: config.temperature,
|
||||
workdir: config.workdir,
|
||||
});
|
||||
toast.info('Settings reset');
|
||||
@@ -242,81 +217,6 @@ export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
transition={{ delay: 0.1 }}
|
||||
className={cn('space-y-6', responsive ? 'p-4 md:p-6' : 'p-6')}
|
||||
>
|
||||
{/* Model */}
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-medium text-gray-300">Model</label>
|
||||
<Select
|
||||
value={formData.model}
|
||||
onValueChange={(value) => setFormData({ ...formData, model: value })}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select a model" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{AVAILABLE_MODELS.map((model) => (
|
||||
<SelectItem key={model.id} value={model.id}>
|
||||
{model.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p className="text-xs text-gray-500">
|
||||
Select the AI model to use for conversations
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Max Tokens */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-sm font-medium text-gray-300">Max Tokens</label>
|
||||
<span className="text-sm text-primary-400 font-medium">
|
||||
{formData.maxTokens.toLocaleString()}
|
||||
</span>
|
||||
</div>
|
||||
<Slider
|
||||
min={1024}
|
||||
max={32768}
|
||||
step={1024}
|
||||
value={[formData.maxTokens]}
|
||||
onValueChange={(value) => setFormData({ ...formData, maxTokens: value[0] })}
|
||||
/>
|
||||
<div className="flex justify-between text-xs text-gray-500">
|
||||
<span>1K</span>
|
||||
<span>8K</span>
|
||||
<span>16K</span>
|
||||
<span>32K</span>
|
||||
</div>
|
||||
<p className="text-xs text-gray-500">
|
||||
Maximum number of tokens in the response
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Temperature */}
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-sm font-medium text-gray-300">Temperature</label>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-gray-400">{getTemperatureLabel(formData.temperature)}</span>
|
||||
<span className="text-sm text-primary-400 font-medium">
|
||||
{formData.temperature.toFixed(2)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<Slider
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.05}
|
||||
value={[formData.temperature]}
|
||||
onValueChange={(value) => setFormData({ ...formData, temperature: value[0] })}
|
||||
/>
|
||||
<div className="flex justify-between text-xs text-gray-500">
|
||||
<span>Precise</span>
|
||||
<span>Balanced</span>
|
||||
<span>Creative</span>
|
||||
</div>
|
||||
<p className="text-xs text-gray-500">Controls randomness in responses</p>
|
||||
</div>
|
||||
|
||||
{/* Working Directory */}
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-medium text-gray-300">Working Directory</label>
|
||||
@@ -418,36 +318,6 @@ export function ConfigPanel({ onClose, responsive = false }: ConfigPanelProps) {
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
{/* Server Info */}
|
||||
{config && (
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 10 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ delay: 0.2 }}
|
||||
className="pt-4 border-t border-gray-700"
|
||||
>
|
||||
<h3 className="text-sm font-medium text-gray-400 mb-3">Server Information</h3>
|
||||
<div
|
||||
className={cn(
|
||||
'text-sm',
|
||||
responsive ? 'grid grid-cols-1 md:grid-cols-2 gap-3' : 'grid grid-cols-2 gap-4'
|
||||
)}
|
||||
>
|
||||
<div className={responsive ? 'flex justify-between md:block' : ''}>
|
||||
<span className="text-gray-500">Allowed Paths:</span>
|
||||
<span className={cn('text-gray-300', responsive ? 'md:ml-2' : 'ml-2')}>
|
||||
{config.allowedPaths.length || 'All'}
|
||||
</span>
|
||||
</div>
|
||||
<div className={responsive ? 'flex justify-between md:block' : ''}>
|
||||
<span className="text-gray-500">Denied Paths:</span>
|
||||
<span className={cn('text-gray-300', responsive ? 'md:ml-2' : 'ml-2')}>
|
||||
{config.deniedPaths.length || 'None'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user