@nextclaw/ui 0.3.8 → 0.3.10
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/CHANGELOG.md +20 -0
- package/dist/assets/index-DM9Q3WUX.css +1 -0
- package/dist/assets/index-DO3sh5Tk.js +230 -0
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/src/api/config.ts +11 -4
- package/src/api/types.ts +50 -5
- package/src/components/config/ChannelForm.tsx +171 -97
- package/src/components/config/ModelConfig.tsx +2 -27
- package/src/components/config/ProviderForm.tsx +74 -72
- package/src/hooks/useConfig.ts +12 -1
- package/src/lib/i18n.ts +0 -1
- package/dist/assets/index-DI6zQUcL.js +0 -230
- package/dist/assets/index-DahcMyga.css +0 -1
|
@@ -100,85 +100,87 @@ export function ProviderForm() {
|
|
|
100
100
|
</div>
|
|
101
101
|
</DialogHeader>
|
|
102
102
|
|
|
103
|
-
<form onSubmit={handleSubmit} className="
|
|
104
|
-
<div className="space-y-
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
<form onSubmit={handleSubmit} className="flex flex-col pt-2">
|
|
104
|
+
<div className="space-y-5 max-h-[60vh] overflow-y-auto pr-1">
|
|
105
|
+
<div className="space-y-2.5">
|
|
106
|
+
<Label htmlFor="apiKey" className="text-sm font-medium text-gray-900 flex items-center gap-2">
|
|
107
|
+
<KeyRound className="h-3.5 w-3.5 text-gray-500" />
|
|
108
|
+
{apiKeyHint?.label ?? t('apiKey')}
|
|
109
|
+
</Label>
|
|
110
|
+
<MaskedInput
|
|
111
|
+
id="apiKey"
|
|
112
|
+
value={apiKey}
|
|
113
|
+
isSet={providerConfig?.apiKeySet}
|
|
114
|
+
onChange={(e) => setApiKey(e.target.value)}
|
|
115
|
+
placeholder={
|
|
116
|
+
providerConfig?.apiKeySet
|
|
117
|
+
? t('apiKeySet')
|
|
118
|
+
: apiKeyHint?.placeholder ?? 'Enter API Key'
|
|
119
|
+
}
|
|
120
|
+
className="rounded-xl"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
124
|
+
<div className="space-y-2.5">
|
|
125
|
+
<Label htmlFor="apiBase" className="text-sm font-medium text-gray-900 flex items-center gap-2">
|
|
126
|
+
<Globe className="h-3.5 w-3.5 text-gray-500" />
|
|
127
|
+
{apiBaseHint?.label ?? t('apiBase')}
|
|
128
|
+
</Label>
|
|
129
|
+
<Input
|
|
130
|
+
id="apiBase"
|
|
131
|
+
type="text"
|
|
132
|
+
value={apiBase}
|
|
133
|
+
onChange={(e) => setApiBase(e.target.value)}
|
|
134
|
+
placeholder={
|
|
135
|
+
providerSpec?.defaultApiBase ||
|
|
136
|
+
apiBaseHint?.placeholder ||
|
|
137
|
+
'https://api.example.com'
|
|
138
|
+
}
|
|
139
|
+
className="rounded-xl"
|
|
140
|
+
/>
|
|
141
|
+
{apiBaseHint?.help && (
|
|
142
|
+
<p className="text-xs text-gray-500">{apiBaseHint.help}</p>
|
|
143
|
+
)}
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
{providerSpec?.supportsWireApi && (
|
|
147
|
+
<div className="space-y-2.5">
|
|
148
|
+
<Label htmlFor="wireApi" className="text-sm font-medium text-gray-900 flex items-center gap-2">
|
|
149
|
+
<Hash className="h-3.5 w-3.5 text-gray-500" />
|
|
150
|
+
{wireApiHint?.label ?? t('wireApi')}
|
|
151
|
+
</Label>
|
|
152
|
+
<select
|
|
153
|
+
id="wireApi"
|
|
154
|
+
value={wireApi}
|
|
155
|
+
onChange={(e) => setWireApi(e.target.value as 'auto' | 'chat' | 'responses')}
|
|
156
|
+
className="flex h-10 w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
157
|
+
>
|
|
158
|
+
{(providerSpec.wireApiOptions || ['auto', 'chat', 'responses']).map((option) => (
|
|
159
|
+
<option key={option} value={option}>
|
|
160
|
+
{option === 'chat'
|
|
161
|
+
? t('wireApiChat')
|
|
162
|
+
: option === 'responses'
|
|
163
|
+
? t('wireApiResponses')
|
|
164
|
+
: t('wireApiAuto')}
|
|
165
|
+
</option>
|
|
166
|
+
))}
|
|
167
|
+
</select>
|
|
168
|
+
</div>
|
|
142
169
|
)}
|
|
143
|
-
</div>
|
|
144
170
|
|
|
145
|
-
{providerSpec?.supportsWireApi && (
|
|
146
171
|
<div className="space-y-2.5">
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
<
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
className="flex h-10 w-full rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm focus:outline-none disabled:cursor-not-allowed disabled:opacity-50"
|
|
156
|
-
>
|
|
157
|
-
{(providerSpec.wireApiOptions || ['auto', 'chat', 'responses']).map((option) => (
|
|
158
|
-
<option key={option} value={option}>
|
|
159
|
-
{option === 'chat'
|
|
160
|
-
? t('wireApiChat')
|
|
161
|
-
: option === 'responses'
|
|
162
|
-
? t('wireApiResponses')
|
|
163
|
-
: t('wireApiAuto')}
|
|
164
|
-
</option>
|
|
165
|
-
))}
|
|
166
|
-
</select>
|
|
172
|
+
<Label className="text-sm font-medium text-gray-900 flex items-center gap-2">
|
|
173
|
+
<Hash className="h-3.5 w-3.5 text-gray-500" />
|
|
174
|
+
{extraHeadersHint?.label ?? t('extraHeaders')}
|
|
175
|
+
</Label>
|
|
176
|
+
<KeyValueEditor
|
|
177
|
+
value={extraHeaders}
|
|
178
|
+
onChange={setExtraHeaders}
|
|
179
|
+
/>
|
|
167
180
|
</div>
|
|
168
|
-
)}
|
|
169
|
-
|
|
170
|
-
<div className="space-y-2.5">
|
|
171
|
-
<Label className="text-sm font-medium text-gray-900 flex items-center gap-2">
|
|
172
|
-
<Hash className="h-3.5 w-3.5 text-gray-500" />
|
|
173
|
-
{extraHeadersHint?.label ?? t('extraHeaders')}
|
|
174
|
-
</Label>
|
|
175
|
-
<KeyValueEditor
|
|
176
|
-
value={extraHeaders}
|
|
177
|
-
onChange={setExtraHeaders}
|
|
178
|
-
/>
|
|
179
181
|
</div>
|
|
180
182
|
|
|
181
|
-
<DialogFooter className="pt-4">
|
|
183
|
+
<DialogFooter className="pt-4 flex-shrink-0">
|
|
182
184
|
<Button
|
|
183
185
|
type="button"
|
|
184
186
|
variant="outline"
|
package/src/hooks/useConfig.ts
CHANGED
|
@@ -5,7 +5,8 @@ import {
|
|
|
5
5
|
fetchConfigSchema,
|
|
6
6
|
updateModel,
|
|
7
7
|
updateProvider,
|
|
8
|
-
updateChannel
|
|
8
|
+
updateChannel,
|
|
9
|
+
executeConfigAction
|
|
9
10
|
} from '@/api/config';
|
|
10
11
|
import { toast } from 'sonner';
|
|
11
12
|
import { t } from '@/lib/i18n';
|
|
@@ -81,3 +82,13 @@ export function useUpdateChannel() {
|
|
|
81
82
|
}
|
|
82
83
|
});
|
|
83
84
|
}
|
|
85
|
+
|
|
86
|
+
export function useExecuteConfigAction() {
|
|
87
|
+
return useMutation({
|
|
88
|
+
mutationFn: ({ actionId, data }: { actionId: string; data: unknown }) =>
|
|
89
|
+
executeConfigAction(actionId, data as Parameters<typeof executeConfigAction>[1]),
|
|
90
|
+
onError: (error: Error) => {
|
|
91
|
+
toast.error(t('error') + ': ' + error.message);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
package/src/lib/i18n.ts
CHANGED
|
@@ -21,7 +21,6 @@ export const LABELS: Record<string, { zh: string; en: string }> = {
|
|
|
21
21
|
modelName: { zh: '模型', en: 'Model' },
|
|
22
22
|
workspace: { zh: '工作空间', en: 'Workspace' },
|
|
23
23
|
maxTokens: { zh: '最大 Token 数', en: 'Max Tokens' },
|
|
24
|
-
temperature: { zh: '温度', en: 'Temperature' },
|
|
25
24
|
maxToolIterations: { zh: '最大工具迭代次数', en: 'Max Tool Iterations' },
|
|
26
25
|
|
|
27
26
|
// Provider
|