Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/provider-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const baseProviderSettingsSchema = z.object({
diffEnabled: z.boolean().optional(),
fuzzyMatchThreshold: z.number().optional(),
modelTemperature: z.number().nullish(),
modelSeed: z.number().optional(),
rateLimitSeconds: z.number().optional(),

// Model reasoning.
Expand Down
1 change: 1 addition & 0 deletions src/api/providers/base-openai-compatible-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export abstract class BaseOpenAiCompatibleProvider<ModelName extends string>
model,
max_tokens,
temperature,
seed: this.options.modelSeed,
messages: [{ role: "system", content: systemPrompt }, ...convertToOpenAiMessages(messages)],
stream: true,
stream_options: { include_usage: true },
Expand Down
1 change: 1 addition & 0 deletions src/api/providers/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class OpenAiHandler extends BaseProvider implements SingleCompletionHandl
const requestOptions: OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming = {
model: modelId,
temperature: this.options.modelTemperature ?? (deepseekReasoner ? DEEP_SEEK_DEFAULT_TEMPERATURE : 0),
seed: this.options.modelSeed,
messages: convertedMessages,
stream: true as const,
...(isGrokXAI ? {} : { stream_options: { include_usage: true } }),
Expand Down
2 changes: 2 additions & 0 deletions src/api/providers/openrouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
model: modelId,
...(maxTokens && maxTokens > 0 && { max_tokens: maxTokens }),
temperature,
seed: this.options.modelSeed,
top_p: topP,
messages: openAiMessages,
stream: true,
Expand Down Expand Up @@ -219,6 +220,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
model: modelId,
max_tokens: maxTokens,
temperature,
seed: this.options.modelSeed,
messages: [{ role: "user", content: prompt }],
stream: false,
// Only include provider if openRouterSpecificProvider is not "[default]".
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/components/settings/ApiOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { DiffSettingsControl } from "./DiffSettingsControl"
import { TemperatureControl } from "./TemperatureControl"
import { RateLimitSecondsControl } from "./RateLimitSecondsControl"
import { BedrockCustomArn } from "./providers/BedrockCustomArn"
import { SeedControl } from "./SeedControl"
import { buildDocLink } from "@src/utils/docLinks"

export interface ApiOptionsProps {
Expand Down Expand Up @@ -488,6 +489,10 @@ const ApiOptions = ({
value={apiConfiguration.rateLimitSeconds || 0}
onChange={(value) => setApiConfigurationField("rateLimitSeconds", value)}
/>
<SeedControl
value={apiConfiguration.modelSeed}
onChange={handleInputChange("modelSeed", noTransform)}
/>
</>
)}
</div>
Expand Down
82 changes: 82 additions & 0 deletions webview-ui/src/components/settings/SeedControl.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
import { useEffect, useState } from "react"
import { useAppTranslation } from "@/i18n/TranslationContext"
import { useDebounce } from "react-use"

interface SeedControlProps {
value: number | undefined | null
onChange: (value: number | undefined) => void
}

export const SeedControl = ({ value, onChange }: SeedControlProps) => {
const { t } = useAppTranslation()
const [isCustomSeed, setIsCustomSeed] = useState(value !== undefined && value !== null)
const [inputValue, setInputValue] = useState<string>(value?.toString() ?? "")

useDebounce(
() => {
if (inputValue === "") {
onChange(undefined)
} else {
const numValue = parseInt(inputValue, 10)
if (!isNaN(numValue)) {
onChange(numValue)
}
}
},
50,
[onChange, inputValue],
)

// Sync internal state with prop changes when switching profiles.
useEffect(() => {
const hasCustomSeed = value !== undefined && value !== null
setIsCustomSeed(hasCustomSeed)
setInputValue(value?.toString() ?? "")
}, [value])

const handleCheckboxChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const isChecked = e.target.checked
setIsCustomSeed(isChecked)

if (!isChecked) {
setInputValue("")
} else {
setInputValue(value?.toString() ?? "42")
}
}

const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setInputValue(e.target.value)
}

return (
<>
<div>
<VSCodeCheckbox
checked={isCustomSeed}
onChange={(e) => {
handleCheckboxChange(e as React.ChangeEvent<HTMLInputElement>)
}}>
<label className="block font-medium mb-1">{t("settings:seed.useCustom")}</label>
</VSCodeCheckbox>
<div className="text-sm text-vscode-descriptionForeground mt-1">{t("settings:seed.description")}</div>
</div>

{isCustomSeed && (
<div className="flex flex-col gap-3 pl-3 border-l-2 border-vscode-button-background">
<div>
<input
type="number"
value={inputValue}
onChange={(e) => {
handleInputChange(e as React.ChangeEvent<HTMLInputElement>)
}}
className="w-full"
/>
</div>
</div>
)}
</>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ jest.mock("@vscode/webview-ui-toolkit/react", () => ({
VSCodeRadio: ({ value, checked }: any) => <input type="radio" value={value} checked={checked} />,
VSCodeRadioGroup: ({ children }: any) => <div>{children}</div>,
VSCodeButton: ({ children }: any) => <div>{children}</div>,
VSCodeCheckbox: ({ children, checked, onChange }: any) => (
<label>
<input type="checkbox" checked={checked} onChange={onChange} />
{children}
</label>
),
}))

// Mock other components
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/ca/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Controla l'aleatorietat en les respostes del model.",
"rangeDescription": "Valors més alts fan que la sortida sigui més aleatòria, valors més baixos la fan més determinista."
},
"seed": {
"useCustom": "Utilitzar llavor personalitzada",
"description": "Controla la naturalesa determinista de les respostes del model. Deixeu en blanc per a aleatori.",
"label": "Introduïu un valor de llavor"
},
"modelInfo": {
"supportsImages": "Suporta imatges",
"noImages": "No suporta imatges",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/de/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Steuert die Zufälligkeit in den Antworten des Modells.",
"rangeDescription": "Höhere Werte machen die Ausgabe zufälliger, niedrigere Werte machen sie deterministischer."
},
"seed": {
"useCustom": "Benutzerdefinierten Seed verwenden",
"description": "Steuert die deterministische Natur der Antworten des Modells. Für zufällig leer lassen.",
"label": "Einen Seed-Wert eingeben"
},
"modelInfo": {
"supportsImages": "Unterstützt Bilder",
"noImages": "Unterstützt keine Bilder",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Controls randomness in the model's responses.",
"rangeDescription": "Higher values make output more random, lower values make it more deterministic."
},
"seed": {
"useCustom": "Use custom seed",
"description": "Controls the deterministic nature of the model's responses. Leave blank for random.",
"label": "Enter a seed value"
},
"modelInfo": {
"supportsImages": "Supports images",
"noImages": "Does not support images",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/es/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Controla la aleatoriedad en las respuestas del modelo.",
"rangeDescription": "Valores más altos hacen que la salida sea más aleatoria, valores más bajos la hacen más determinista."
},
"seed": {
"useCustom": "Usar semilla personalizada",
"description": "Controla la naturaleza determinista de las respuestas del modelo. Dejar en blanco para aleatorio.",
"label": "Introducir un valor de semilla"
},
"modelInfo": {
"supportsImages": "Soporta imágenes",
"noImages": "No soporta imágenes",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/fr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Contrôle l'aléatoire dans les réponses du modèle.",
"rangeDescription": "Des valeurs plus élevées rendent la sortie plus aléatoire, des valeurs plus basses la rendent plus déterministe."
},
"seed": {
"useCustom": "Utiliser une graine personnalisée",
"description": "Contrôle la nature déterministe des réponses du modèle. Laisser vide pour aléatoire.",
"label": "Entrez une valeur de graine"
},
"modelInfo": {
"supportsImages": "Prend en charge les images",
"noImages": "Ne prend pas en charge les images",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/hi/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "मॉडल की प्रतिक्रियाओं में यादृच्छिकता को नियंत्रित करता है।",
"rangeDescription": "उच्च मान आउटपुट को अधिक यादृच्छिक बनाते हैं, निम्न मान इसे अधिक निर्धारित बनाते हैं।"
},
"seed": {
"useCustom": "कस्टम सीड का प्रयोग करें",
"description": "मॉडल की प्रतिक्रियाओं की déterministe प्रकृति को नियंत्रित करता है। यादृच्छिक के लिए खाली छोड़ दें।",
"label": "एक सीड मान दर्ज करें"
},
"modelInfo": {
"supportsImages": "छवियों का समर्थन करता है",
"noImages": "छवियों का समर्थन नहीं करता है",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/it/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Controlla la casualità nelle risposte del modello.",
"rangeDescription": "Valori più alti rendono l'output più casuale, valori più bassi lo rendono più deterministico."
},
"seed": {
"useCustom": "Usa seed personalizzato",
"description": "Controlla la natura deterministica delle risposte del modello. Lasciare vuoto per casuale.",
"label": "Inserisci un valore di seed"
},
"modelInfo": {
"supportsImages": "Supporta immagini",
"noImages": "Non supporta immagini",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/ja/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "モデルの応答のランダム性を制御します。",
"rangeDescription": "高い値は出力をよりランダムに、低い値はより決定論的にします。"
},
"seed": {
"useCustom": "カスタムシードを使用",
"description": "モデルの応答の決定性を制御します。ランダムの場合は空白のままにします。",
"label": "シード値を入力してください"
},
"modelInfo": {
"supportsImages": "画像をサポート",
"noImages": "画像をサポートしていません",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/ko/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "모델 응답의 무작위성을 제어합니다.",
"rangeDescription": "높은 값은 출력을 더 무작위하게, 낮은 값은 더 결정적으로 만듭니다."
},
"seed": {
"useCustom": "사용자 지정 시드 사용",
"description": "모델 응답의 결정적 특성을 제어합니다. 무작위의 경우 비워 둡니다.",
"label": "시드 값 입력"
},
"modelInfo": {
"supportsImages": "이미지 지원",
"noImages": "이미지 지원 안 함",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/nl/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Bepaalt de willekeurigheid in de antwoorden van het model.",
"rangeDescription": "Hogere waarden maken de output willekeuriger, lagere waarden maken deze deterministischer."
},
"seed": {
"useCustom": "Aangepaste seed gebruiken",
"description": "Bepaalt de deterministische aard van de antwoorden van het model. Laat leeg voor willekeurig.",
"label": "Voer een seed-waarde in"
},
"modelInfo": {
"supportsImages": "Ondersteunt afbeeldingen",
"noImages": "Ondersteunt geen afbeeldingen",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/pl/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Kontroluje losowość w odpowiedziach modelu.",
"rangeDescription": "Wyższe wartości sprawiają, że wyjście jest bardziej losowe, niższe wartości czynią je bardziej deterministycznym."
},
"seed": {
"useCustom": "Użyj niestandardowego ziarna",
"description": "Kontroluje deterministyczną naturę odpowiedzi modelu. Pozostaw puste dla losowości.",
"label": "Wprowadź wartość ziarna"
},
"modelInfo": {
"supportsImages": "Obsługuje obrazy",
"noImages": "Nie obsługuje obrazów",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/pt-BR/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Controla a aleatoriedade nas respostas do modelo.",
"rangeDescription": "Valores mais altos tornam a saída mais aleatória, valores mais baixos a tornam mais determinística."
},
"seed": {
"useCustom": "Usar semente personalizada",
"description": "Controla a natureza determinística das respostas do modelo. Deixe em branco para aleatório.",
"label": "Insira um valor de semente"
},
"modelInfo": {
"supportsImages": "Suporta imagens",
"noImages": "Não suporta imagens",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Управляет случайностью ответов модели.",
"rangeDescription": "Более высокие значения делают ответы более случайными, низкие — более детерминированными."
},
"seed": {
"useCustom": "Использовать пользовательское начальное значение",
"description": "Контролирует детерминированность ответов модели. Оставьте пустым для случайного значения.",
"label": "Введите начальное значение"
},
"modelInfo": {
"supportsImages": "Поддерживает изображения",
"noImages": "Не поддерживает изображения",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/tr/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Model yanıtlarındaki rastgeleliği kontrol eder.",
"rangeDescription": "Daha yüksek değerler çıktıyı daha rastgele yapar, daha düşük değerler daha deterministik hale getirir."
},
"seed": {
"useCustom": "Özel tohum kullan",
"description": "Modelin yanıtlarının deterministik doğasını kontrol eder. Rastgele için boş bırakın.",
"label": "Bir tohum değeri girin"
},
"modelInfo": {
"supportsImages": "Görüntüleri destekler",
"noImages": "Görüntüleri desteklemez",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/vi/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "Kiểm soát tính ngẫu nhiên trong phản hồi của mô hình.",
"rangeDescription": "Giá trị cao hơn làm cho đầu ra ngẫu nhiên hơn, giá trị thấp hơn làm cho nó xác định hơn."
},
"seed": {
"useCustom": "Sử dụng hạt giống tùy chỉnh",
"description": "Kiểm soát tính xác định của các phản hồi của mô hình. Để trống cho ngẫu nhiên.",
"label": "Nhập giá trị hạt giống"
},
"modelInfo": {
"supportsImages": "Hỗ trợ hình ảnh",
"noImages": "Không hỗ trợ hình ảnh",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/zh-CN/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "控制模型响应的随机性",
"rangeDescription": "值越高回答越多样,值越低越保守"
},
"seed": {
"useCustom": "使用自定义种子",
"description": "控制模型响应的确定性。留空则随机。",
"label": "输入种子值"
},
"modelInfo": {
"supportsImages": "支持图像",
"noImages": "不支持图像",
Expand Down
5 changes: 5 additions & 0 deletions webview-ui/src/i18n/locales/zh-TW/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,11 @@
"description": "控制模型回應的隨機性",
"rangeDescription": "較高值使輸出更隨機,較低值更確定"
},
"seed": {
"useCustom": "使用自訂種子",
"description": "控制模型回應的確定性。留空則隨機。",
"label": "輸入種子值"
},
"modelInfo": {
"supportsImages": "支援影像",
"noImages": "不支援影像",
Expand Down
Loading