added optional request params and context limit from GOOSE_PREDEFINED_MODELS (#6489)

This commit is contained in:
Zane
2026-01-16 10:12:14 -08:00
committed by GitHub
parent 351e99b82d
commit 080a0e04ba
12 changed files with 140 additions and 13 deletions
+10
View File
@@ -542,6 +542,12 @@ export type ModelConfig = {
fast_model?: string | null;
max_tokens?: number | null;
model_name: string;
/**
* Provider-specific request parameters (e.g., anthropic_beta headers)
*/
request_params?: {
[key: string]: unknown;
} | null;
temperature?: number | null;
toolshim: boolean;
toolshim_model?: string | null;
@@ -1168,8 +1174,12 @@ export type UpdateFromSessionRequest = {
};
export type UpdateProviderRequest = {
context_limit?: number | null;
model?: string | null;
provider: string;
request_params?: {
[key: string]: unknown;
} | null;
session_id: string;
};
+10
View File
@@ -31,6 +31,7 @@ import { getSession, Message } from '../api';
import CreateRecipeFromSessionModal from './recipes/CreateRecipeFromSessionModal';
import CreateEditRecipeModal from './recipes/CreateEditRecipeModal';
import { getInitialWorkingDir } from '../utils/workingDir';
import { getPredefinedModelsFromEnv } from './settings/models/predefinedModelsUtils';
import {
trackFileAttached,
trackVoiceDictation,
@@ -448,6 +449,15 @@ export default function ChatInput({
return;
}
// First, check predefined models from environment (highest priority)
const predefinedModels = getPredefinedModelsFromEnv();
const predefinedModel = predefinedModels.find((m) => m.name === model);
if (predefinedModel?.context_limit) {
setTokenLimit(predefinedModel.context_limit);
setIsTokenLimitLoaded(true);
return;
}
const providers = await getProviders(true);
// Find the provider details for the current provider
@@ -53,6 +53,8 @@ export const ModelAndProviderProvider: React.FC<ModelAndProviderProviderProps> =
session_id: sessionId,
provider: providerName,
model: modelName,
context_limit: model.context_limit,
request_params: model.request_params,
},
});
}
+13 -6
View File
@@ -24,6 +24,17 @@ const alertStyles: Record<AlertType, string> = {
[AlertType.Info]: 'dark:bg-white dark:text-black bg-black text-white',
};
const formatTokenCount = (count: number): string => {
if (count >= 1000000) {
const millions = count / 1000000;
return millions % 1 === 0 ? `${millions.toFixed(0)}M` : `${millions.toFixed(1)}M`;
} else if (count >= 1000) {
const thousands = count / 1000;
return thousands % 1 === 0 ? `${thousands.toFixed(0)}k` : `${thousands.toFixed(1)}k`;
}
return count.toString();
};
export const AlertBox = ({ alert, className }: AlertBoxProps) => {
const { read } = useConfig();
const [isEditingThreshold, setIsEditingThreshold] = useState(false);
@@ -242,18 +253,14 @@ export const AlertBox = ({ alert, className }: AlertBoxProps) => {
<div className="flex justify-between items-baseline text-[11px]">
<div className="flex gap-1 items-baseline">
<span className={'dark:text-black/60 text-white/60'}>
{alert.progress!.current >= 1000
? (alert.progress!.current / 1000).toFixed(1) + 'k'
: alert.progress!.current}
{formatTokenCount(alert.progress!.current)}
</span>
<span className={'dark:text-black/40 text-white/40'}>
{Math.round((alert.progress!.current / alert.progress!.total) * 100)}%
</span>
</div>
<span className={'dark:text-black/60 text-white/60'}>
{alert.progress!.total >= 1000
? (alert.progress!.total / 1000).toFixed(0) + 'k'
: alert.progress!.total}
{formatTokenCount(alert.progress!.total)}
</span>
</div>
{alert.showCompactButton && alert.onCompact && (
@@ -7,6 +7,8 @@ export default interface Model {
lastUsed?: string;
alias?: string; // optional model display name
subtext?: string; // goes below model name if not the provider
context_limit?: number; // optional context limit override
request_params?: Record<string, unknown>; // provider-specific request parameters
}
export function createModelStruct(