feat: make custom provider base URL and model fields conditionally editable based on API key state
This commit is contained in:
parent
dcba4ff045
commit
de16a9d7b8
@ -358,14 +358,29 @@ struct APIKeyManagementView: View {
|
|||||||
|
|
||||||
// Configuration Fields
|
// Configuration Fields
|
||||||
VStack(alignment: .leading, spacing: 8) {
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
TextField("Base URL (e.g., https://api.example.com/v1/chat/completions)", text: $aiService.customBaseURL)
|
if !aiService.isAPIKeyValid {
|
||||||
.textFieldStyle(.roundedBorder)
|
TextField("Base URL (e.g., https://api.example.com/v1/chat/completions)", text: $aiService.customBaseURL)
|
||||||
|
.textFieldStyle(.roundedBorder)
|
||||||
TextField("Model Name (e.g., gpt-4o-mini, claude-3-5-sonnet-20240620)", text: $aiService.customModel)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
TextField("Model Name (e.g., gpt-4o-mini, claude-3-5-sonnet-20240620)", text: $aiService.customModel)
|
||||||
|
.textFieldStyle(.roundedBorder)
|
||||||
|
} else {
|
||||||
|
VStack(alignment: .leading, spacing: 8) {
|
||||||
|
Text("Base URL")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Text(aiService.customBaseURL)
|
||||||
|
.font(.system(.body, design: .monospaced))
|
||||||
|
|
||||||
|
Text("Model")
|
||||||
|
.font(.subheadline)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Text(aiService.customModel)
|
||||||
|
.font(.system(.body, design: .monospaced))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if aiService.isAPIKeyValid {
|
if aiService.isAPIKeyValid {
|
||||||
// Show masked API key when valid
|
|
||||||
Text("API Key")
|
Text("API Key")
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
@ -385,7 +400,6 @@ struct APIKeyManagementView: View {
|
|||||||
.buttonStyle(.borderless)
|
.buttonStyle(.borderless)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Show API key input when not valid
|
|
||||||
Text("Enter your API Key")
|
Text("Enter your API Key")
|
||||||
.font(.subheadline)
|
.font(.subheadline)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user