refactor: auto-generate model role from model name[provider name] format
This commit is contained in:
+2
-5
@@ -391,10 +391,7 @@ export default function App() {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onModelAdd={() => {
|
onModelAdd={() => {
|
||||||
const providerModels = Object.values(config.models).filter(
|
const alias = `新模型[${currentProvider.name}]`;
|
||||||
(m) => m.provider === currentProvider.name
|
|
||||||
);
|
|
||||||
const alias = `${currentProvider.name}-${providerModels.length + 1}`;
|
|
||||||
updateConfig((cfg) => ({
|
updateConfig((cfg) => ({
|
||||||
...cfg,
|
...cfg,
|
||||||
models: {
|
models: {
|
||||||
@@ -405,7 +402,7 @@ export default function App() {
|
|||||||
model: "",
|
model: "",
|
||||||
max_context_size: getDefaultMaxContextSize(alias),
|
max_context_size: getDefaultMaxContextSize(alias),
|
||||||
display_name: null,
|
display_name: null,
|
||||||
role: null,
|
role: `新模型[${currentProvider.name}]`,
|
||||||
supports_1m: false,
|
supports_1m: false,
|
||||||
capabilities: [],
|
capabilities: [],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -379,6 +379,7 @@ function ModelMapping({
|
|||||||
for (const dm of discovered) {
|
for (const dm of discovered) {
|
||||||
if (!selected.has(dm.id)) continue;
|
if (!selected.has(dm.id)) continue;
|
||||||
const alias = dm.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
const alias = dm.id.replace(/[^a-zA-Z0-9_-]/g, "-");
|
||||||
|
const role = `${dm.id}[${provider.name}]`;
|
||||||
const max_context_size = dm.max_context_size ?? getDefaultMaxContextSize(dm.id);
|
const max_context_size = dm.max_context_size ?? getDefaultMaxContextSize(dm.id);
|
||||||
toAdd.push({
|
toAdd.push({
|
||||||
alias,
|
alias,
|
||||||
@@ -386,7 +387,7 @@ function ModelMapping({
|
|||||||
model: dm.id,
|
model: dm.id,
|
||||||
max_context_size,
|
max_context_size,
|
||||||
display_name: dm.display_name,
|
display_name: dm.display_name,
|
||||||
role: null,
|
role,
|
||||||
supports_1m: max_context_size >= 1_000_000,
|
supports_1m: max_context_size >= 1_000_000,
|
||||||
capabilities: [],
|
capabilities: [],
|
||||||
});
|
});
|
||||||
@@ -482,17 +483,9 @@ function ModelMapping({
|
|||||||
{models.map((m) => (
|
{models.map((m) => (
|
||||||
<tr key={m.alias} className="hover:bg-[#1c1c20]">
|
<tr key={m.alias} className="hover:bg-[#1c1c20]">
|
||||||
<td className="px-4 py-2">
|
<td className="px-4 py-2">
|
||||||
<input
|
<span className="text-sm text-gray-400">
|
||||||
className="w-full bg-transparent border border-[#2a2a2e] rounded px-2 py-1.5 text-sm focus:ring-2 focus:ring-blue-500 focus:outline-none"
|
{m.model ? `${m.model}[${m.provider}]` : m.alias}
|
||||||
value={m.role || ""}
|
</span>
|
||||||
placeholder={m.alias}
|
|
||||||
onChange={(e) =>
|
|
||||||
onModelChange({
|
|
||||||
...m,
|
|
||||||
role: e.target.value || null,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</td>
|
</td>
|
||||||
<td className="px-4 py-2">
|
<td className="px-4 py-2">
|
||||||
<input
|
<input
|
||||||
|
|||||||
Reference in New Issue
Block a user