feat(ui): add model field to the image-recognition settings card
The card now configures the provider endpoint, API key, and model, mirroring the provider Config. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,18 @@ export function ImageRecognitionCard(props: ImageRecognitionCardProps) {
|
|||||||
onEdit={(text) => { props.edit('baseURL', text) }}
|
onEdit={(text) => { props.edit('baseURL', text) }}
|
||||||
onReset={() => { props.resetField('baseURL') }}
|
onReset={() => { props.resetField('baseURL') }}
|
||||||
/>
|
/>
|
||||||
|
<ValueField
|
||||||
|
id="plugin-config-image-recognition-model"
|
||||||
|
label={t('imageRecognitionModel')}
|
||||||
|
hint={t('imageRecognitionModelHint')}
|
||||||
|
overriddenLabel={t('overridden')}
|
||||||
|
resetLabel={t('reset')}
|
||||||
|
invalidLabel={t('invalidNumber')}
|
||||||
|
disabled={disabled}
|
||||||
|
{...state.model}
|
||||||
|
onEdit={(text) => { props.edit('model', text) }}
|
||||||
|
onReset={() => { props.resetField('model') }}
|
||||||
|
/>
|
||||||
</PluginCard>
|
</PluginCard>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ export interface ImageRecognitionSettings {
|
|||||||
apiKeyEnv?: string
|
apiKeyEnv?: string
|
||||||
/** Provider endpoint; blank inherits the provider default. */
|
/** Provider endpoint; blank inherits the provider default. */
|
||||||
baseURL?: string
|
baseURL?: string
|
||||||
|
/** Vision model name; blank inherits the provider default. */
|
||||||
|
model?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What the credentials domain last reported, and for which reference. */
|
/** What the credentials domain last reported, and for which reference. */
|
||||||
@@ -50,6 +52,8 @@ interface CredentialState {
|
|||||||
export interface ImageRecognitionCardState extends CardShell {
|
export interface ImageRecognitionCardState extends CardShell {
|
||||||
/** Provider endpoint. */
|
/** Provider endpoint. */
|
||||||
baseURL: CardFieldState
|
baseURL: CardFieldState
|
||||||
|
/** Vision model name. */
|
||||||
|
model: CardFieldState
|
||||||
/** The staged credential, which starts blank on every load. */
|
/** The staged credential, which starts blank on every load. */
|
||||||
apiKey: CardFieldState
|
apiKey: CardFieldState
|
||||||
/** Whether the Host reports a credential configured for the referenced key. */
|
/** Whether the Host reports a credential configured for the referenced key. */
|
||||||
@@ -82,7 +86,7 @@ export class ImageRecognitionCardController {
|
|||||||
) {
|
) {
|
||||||
this.form = new CardForm(
|
this.form = new CardForm(
|
||||||
scope,
|
scope,
|
||||||
[textField('baseURL')],
|
[textField('baseURL'), textField('model')],
|
||||||
[{ field: API_KEY_FIELD, write: text => this.writeKey(text) }],
|
[{ field: API_KEY_FIELD, write: text => this.writeKey(text) }],
|
||||||
)
|
)
|
||||||
this.store = this.form.bind(() => this.projection())
|
this.store = this.form.bind(() => this.projection())
|
||||||
@@ -94,6 +98,7 @@ export class ImageRecognitionCardController {
|
|||||||
return {
|
return {
|
||||||
...this.form.shell(),
|
...this.form.shell(),
|
||||||
baseURL: this.form.field('baseURL'),
|
baseURL: this.form.field('baseURL'),
|
||||||
|
model: this.form.field('model'),
|
||||||
apiKey: this.form.field(API_KEY_FIELD),
|
apiKey: this.form.field(API_KEY_FIELD),
|
||||||
apiKeyConfigured: this.credential.configured,
|
apiKeyConfigured: this.credential.configured,
|
||||||
apiKeyWritable: this.credential.writable,
|
apiKeyWritable: this.credential.writable,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export type PluginsSettingsLocaleKey =
|
|||||||
| 'imageRecognitionTitle' | 'imageRecognitionDescription'
|
| 'imageRecognitionTitle' | 'imageRecognitionDescription'
|
||||||
| 'imageRecognitionApiKey' | 'imageRecognitionApiKeyHint' | 'imageRecognitionApiKeySet' | 'imageRecognitionApiKeyUnset'
|
| 'imageRecognitionApiKey' | 'imageRecognitionApiKeyHint' | 'imageRecognitionApiKeySet' | 'imageRecognitionApiKeyUnset'
|
||||||
| 'imageRecognitionBaseUrl' | 'imageRecognitionBaseUrlHint'
|
| 'imageRecognitionBaseUrl' | 'imageRecognitionBaseUrlHint'
|
||||||
|
| 'imageRecognitionModel' | 'imageRecognitionModelHint'
|
||||||
|
|
||||||
/** English copy. */
|
/** English copy. */
|
||||||
export const en: Record<PluginsSettingsLocaleKey, string> = {
|
export const en: Record<PluginsSettingsLocaleKey, string> = {
|
||||||
@@ -62,6 +63,8 @@ export const en: Record<PluginsSettingsLocaleKey, string> = {
|
|||||||
imageRecognitionApiKeyUnset: 'No key is configured; recognition is unavailable until one is.',
|
imageRecognitionApiKeyUnset: 'No key is configured; recognition is unavailable until one is.',
|
||||||
imageRecognitionBaseUrl: 'Endpoint',
|
imageRecognitionBaseUrl: 'Endpoint',
|
||||||
imageRecognitionBaseUrlHint: 'Leave blank to use the provider default.',
|
imageRecognitionBaseUrlHint: 'Leave blank to use the provider default.',
|
||||||
|
imageRecognitionModel: 'Model',
|
||||||
|
imageRecognitionModelHint: 'Vision model name; leave blank to use the provider default.',
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Simplified Chinese copy. */
|
/** Simplified Chinese copy. */
|
||||||
@@ -111,4 +114,6 @@ export const zh: Record<PluginsSettingsLocaleKey, string> = {
|
|||||||
imageRecognitionApiKeyUnset: '未配置密钥;配置之前图像识别不可用。',
|
imageRecognitionApiKeyUnset: '未配置密钥;配置之前图像识别不可用。',
|
||||||
imageRecognitionBaseUrl: '接口地址',
|
imageRecognitionBaseUrl: '接口地址',
|
||||||
imageRecognitionBaseUrlHint: '留空则使用提供方默认地址。',
|
imageRecognitionBaseUrlHint: '留空则使用提供方默认地址。',
|
||||||
|
imageRecognitionModel: '模型',
|
||||||
|
imageRecognitionModelHint: '视觉模型名称;留空则使用提供方默认。',
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user