mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Implement Vertex AI authentication modes and configuration in UI
- Updated index.html to include options for Vertex AI authentication modes (Express and Full). - Enhanced openai.js to manage Vertex AI settings, including project ID, region, and service account JSON. - Added validation and handling for service account JSON in the backend. - Modified API request handling in google.js to support both authentication modes for Vertex AI. - Updated secrets.js to include a key for storing Vertex AI service account JSON. - Improved error handling and user feedback for authentication issues.
This commit is contained in:
@@ -56,6 +56,13 @@ export async function getMultimodalCaption(base64Img, prompt) {
|
||||
model: extension_settings.caption.multimodal_model || 'gpt-4-turbo',
|
||||
};
|
||||
|
||||
// Add Vertex AI specific parameters if using Vertex AI
|
||||
if (extension_settings.caption.multimodal_api === 'vertexai') {
|
||||
requestBody.vertexai_auth_mode = oai_settings.vertexai_auth_mode;
|
||||
requestBody.vertexai_project_id = oai_settings.vertexai_project_id;
|
||||
requestBody.vertexai_region = oai_settings.vertexai_region;
|
||||
}
|
||||
|
||||
if (isOllama) {
|
||||
if (extension_settings.caption.multimodal_model === 'ollama_current') {
|
||||
requestBody.model = textgenerationwebui_settings.ollama_model;
|
||||
@@ -164,8 +171,27 @@ function throwIfInvalidModel(useReverseProxy) {
|
||||
throw new Error('Google AI Studio API key is not set.');
|
||||
}
|
||||
|
||||
if (multimodalApi === 'vertexai' && !secret_state[SECRET_KEYS.VERTEXAI] && !useReverseProxy) {
|
||||
throw new Error('Google Vertex AI API key is not set.');
|
||||
if (multimodalApi === 'vertexai' && !useReverseProxy) {
|
||||
// Check based on authentication mode
|
||||
const authMode = oai_settings.vertexai_auth_mode || 'express';
|
||||
|
||||
if (authMode === 'express') {
|
||||
// Express mode requires API key
|
||||
if (!secret_state[SECRET_KEYS.VERTEXAI]) {
|
||||
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
|
||||
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 (!oai_settings.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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (multimodalApi === 'mistral' && !secret_state[SECRET_KEYS.MISTRALAI] && !useReverseProxy) {
|
||||
|
Reference in New Issue
Block a user