feat: apply smart default max_context_size when adding models
This commit is contained in:
+8
-2
@@ -5,6 +5,7 @@ import { useConfig } from "./hooks/useConfig";
|
|||||||
import { ProviderList } from "./components/ProviderList";
|
import { ProviderList } from "./components/ProviderList";
|
||||||
import { ProviderEdit } from "./components/ProviderEdit";
|
import { ProviderEdit } from "./components/ProviderEdit";
|
||||||
import { useTranslation } from "./i18n";
|
import { useTranslation } from "./i18n";
|
||||||
|
import { getDefaultMaxContextSize } from "./lib/model-defaults";
|
||||||
import type { Agent, Model, Provider } from "./types";
|
import type { Agent, Model, Provider } from "./types";
|
||||||
|
|
||||||
const AGENT_STORAGE_KEY = "pi-switch-agent";
|
const AGENT_STORAGE_KEY = "pi-switch-agent";
|
||||||
@@ -246,7 +247,12 @@ export default function App() {
|
|||||||
alias = `${m.alias}-${n}`;
|
alias = `${m.alias}-${n}`;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
updatedModels[alias] = { ...m, alias, provider: provider.name };
|
updatedModels[alias] = {
|
||||||
|
...m,
|
||||||
|
alias,
|
||||||
|
provider: provider.name,
|
||||||
|
max_context_size: m.max_context_size ?? getDefaultMaxContextSize(m.model),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let default_model = cfg.default_model;
|
let default_model = cfg.default_model;
|
||||||
@@ -398,7 +404,7 @@ export default function App() {
|
|||||||
alias,
|
alias,
|
||||||
provider: currentProvider.name,
|
provider: currentProvider.name,
|
||||||
model: "",
|
model: "",
|
||||||
max_context_size: 128000,
|
max_context_size: getDefaultMaxContextSize(alias),
|
||||||
display_name: null,
|
display_name: null,
|
||||||
role: null,
|
role: null,
|
||||||
supports_1m: false,
|
supports_1m: false,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useId, useState } from "react";
|
import { useEffect, useId, useState } from "react";
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { useTranslation } from "../i18n";
|
import { useTranslation } from "../i18n";
|
||||||
|
import { getDefaultMaxContextSize } from "../lib/model-defaults";
|
||||||
import { AgentSettingsPanel } from "./AgentSettingsPanel";
|
import { AgentSettingsPanel } from "./AgentSettingsPanel";
|
||||||
import type { Agent, DiscoveredModel, Model, Provider, ProviderType } from "../types";
|
import type { Agent, DiscoveredModel, Model, Provider, ProviderType } from "../types";
|
||||||
|
|
||||||
@@ -378,14 +379,15 @@ 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 max_context_size = dm.max_context_size ?? getDefaultMaxContextSize(dm.id);
|
||||||
toAdd.push({
|
toAdd.push({
|
||||||
alias,
|
alias,
|
||||||
provider: provider.name,
|
provider: provider.name,
|
||||||
model: dm.id,
|
model: dm.id,
|
||||||
max_context_size: dm.max_context_size ?? 128000,
|
max_context_size,
|
||||||
display_name: dm.display_name,
|
display_name: dm.display_name,
|
||||||
role: null,
|
role: null,
|
||||||
supports_1m: (dm.max_context_size ?? 0) >= 1_000_000,
|
supports_1m: max_context_size >= 1_000_000,
|
||||||
capabilities: [],
|
capabilities: [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user