mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Derive Vertex AI Project ID from Service Account JSON
This commit refactors the Vertex AI integration to automatically derive the Project ID from the provided Service Account JSON. This simplifies the configuration process for users in "Full" (service account) authentication mode by removing the need to specify the Project ID separately.
This commit is contained in:
@@ -180,13 +180,10 @@ function throwIfInvalidModel(useReverseProxy) {
|
||||
throw new Error('Google Vertex AI API key is not set for Express mode.');
|
||||
}
|
||||
} else if (authMode === 'full') {
|
||||
// Full mode requires Service Account JSON and project settings
|
||||
// Full mode requires Service Account JSON and region settings
|
||||
if (!secret_state[SECRET_KEYS.VERTEXAI_SERVICE_ACCOUNT]) {
|
||||
throw new Error('Service Account JSON is required for Vertex AI Full mode. Please validate and save your Service Account JSON.');
|
||||
}
|
||||
if (!secret_state[SECRET_KEYS.VERTEXAI_PROJECT_ID]) {
|
||||
throw new Error('Project ID is required for Vertex AI Full mode.');
|
||||
}
|
||||
if (!oai_settings.vertexai_region) {
|
||||
throw new Error('Region is required for Vertex AI Full mode.');
|
||||
}
|
||||
|
@@ -3496,8 +3496,6 @@ function loadOpenAISettings(data, settings) {
|
||||
$('#claude_use_sysprompt').prop('checked', oai_settings.claude_use_sysprompt);
|
||||
$('#use_makersuite_sysprompt').prop('checked', oai_settings.use_makersuite_sysprompt);
|
||||
$('#vertexai_auth_mode').val(oai_settings.vertexai_auth_mode);
|
||||
// Don't display Project ID in input - it's stored in backend secrets
|
||||
$('#vertexai_project_id').val('');
|
||||
$('#vertexai_region').val(oai_settings.vertexai_region);
|
||||
// Don't display Service Account JSON in textarea - it's stored in backend secrets
|
||||
$('#vertexai_service_account_json').val('');
|
||||
@@ -5015,19 +5013,7 @@ async function onConnectButtonClick(e) {
|
||||
}
|
||||
} else {
|
||||
// Full version - use service account
|
||||
// Check if we have a saved project ID, otherwise use the input value
|
||||
const savedProjectId = secret_state[SECRET_KEYS.VERTEXAI_PROJECT_ID];
|
||||
const inputProjectId = String($('#vertexai_project_id').val()).trim();
|
||||
|
||||
if (!savedProjectId && !inputProjectId) {
|
||||
toastr.error(t`Project ID is required for Vertex AI full version`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Save project ID to secrets if we have an input value
|
||||
if (inputProjectId.length) {
|
||||
await writeSecret(SECRET_KEYS.VERTEXAI_PROJECT_ID, inputProjectId);
|
||||
}
|
||||
// Project ID will be extracted from the Service Account JSON
|
||||
|
||||
// Check if service account JSON is saved in backend
|
||||
if (!secret_state[SECRET_KEYS.VERTEXAI_SERVICE_ACCOUNT]) {
|
||||
|
@@ -44,7 +44,6 @@ export const SECRET_KEYS = {
|
||||
SERPER: 'api_key_serper',
|
||||
FALAI: 'api_key_falai',
|
||||
XAI: 'api_key_xai',
|
||||
VERTEXAI_PROJECT_ID: 'vertexai_project_id',
|
||||
VERTEXAI_SERVICE_ACCOUNT: 'vertexai_service_account_json',
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user