mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(gemini): support mid-session model change (#379)
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { MODEL_OPTIONS } from '@/components/NewSession/types'
|
||||
import { getClaudeComposerModelOptions, getNextClaudeComposerModel } from './claudeModelOptions'
|
||||
import type { ClaudeComposerModelOption } from './claudeModelOptions'
|
||||
|
||||
export type ModelOption = ClaudeComposerModelOption
|
||||
|
||||
function getGeminiModelOptions(currentModel?: string | null): ModelOption[] {
|
||||
const options = MODEL_OPTIONS.gemini.map((m) => ({
|
||||
value: m.value === 'auto' ? null : m.value,
|
||||
label: m.label
|
||||
}))
|
||||
const normalized = currentModel?.trim() || null
|
||||
if (normalized && !options.some((o) => o.value === normalized)) {
|
||||
options.splice(1, 0, { value: normalized, label: normalized })
|
||||
}
|
||||
return options
|
||||
}
|
||||
|
||||
function getNextGeminiModel(currentModel?: string | null): string | null {
|
||||
const options = getGeminiModelOptions(currentModel)
|
||||
const currentIndex = options.findIndex((o) => o.value === (currentModel ?? null))
|
||||
if (currentIndex === -1) {
|
||||
return options[0]?.value ?? null
|
||||
}
|
||||
return options[(currentIndex + 1) % options.length]?.value ?? null
|
||||
}
|
||||
|
||||
export function getModelOptionsForFlavor(flavor: string | undefined | null, currentModel?: string | null): ModelOption[] {
|
||||
if (flavor === 'gemini') {
|
||||
return getGeminiModelOptions(currentModel)
|
||||
}
|
||||
return getClaudeComposerModelOptions(currentModel)
|
||||
}
|
||||
|
||||
export function getNextModelForFlavor(flavor: string | undefined | null, currentModel?: string | null): string | null {
|
||||
if (flavor === 'gemini') {
|
||||
return getNextGeminiModel(currentModel)
|
||||
}
|
||||
return getNextClaudeComposerModel(currentModel)
|
||||
}
|
||||
Reference in New Issue
Block a user