Add reverse proxy support to Google MakerSuite to allow some Google MakerSuite URLs to no longer be hardcoded with domain names. (#2307)

* Add reverse proxy support to Google MakerSuite.

* Remove hardcoded URLs for some Google MakerSuite API calls.

* Don't send real key to alt.endpoint

* Fix for image captioning

* Fix key validation

* +fix key check for mistral

* Fix caption key validation

* Fix tokenization endpoint use

---------

Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
This commit is contained in:
daiaji
2024-05-25 02:38:29 +08:00
committed by GitHub
parent e1dfbc0bea
commit 66454bb711
8 changed files with 46 additions and 34 deletions

View File

@ -1743,8 +1743,8 @@ async function sendOpenAIRequest(type, messages, signal) {
delete generate_data.stop;
}
// Proxy is only supported for Claude, OpenAI and Mistral
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI].includes(oai_settings.chat_completion_source)) {
// Proxy is only supported for Claude, OpenAI, Mistral, and Google MakerSuite
if (oai_settings.reverse_proxy && [chat_completion_sources.CLAUDE, chat_completion_sources.OPENAI, chat_completion_sources.MISTRALAI, chat_completion_sources.MAKERSUITE].includes(oai_settings.chat_completion_source)) {
validateReverseProxy();
generate_data['reverse_proxy'] = oai_settings.reverse_proxy;
generate_data['proxy_password'] = oai_settings.proxy_password;
@ -4038,7 +4038,7 @@ async function onConnectButtonClick(e) {
await writeSecret(SECRET_KEYS.MAKERSUITE, api_key_makersuite);
}
if (!secret_state[SECRET_KEYS.MAKERSUITE]) {
if (!secret_state[SECRET_KEYS.MAKERSUITE] && !oai_settings.reverse_proxy) {
console.log('No secret key saved for MakerSuite');
return;
}
@ -4090,7 +4090,7 @@ async function onConnectButtonClick(e) {
await writeSecret(SECRET_KEYS.MISTRALAI, api_key_mistralai);
}
if (!secret_state[SECRET_KEYS.MISTRALAI]) {
if (!secret_state[SECRET_KEYS.MISTRALAI] && !oai_settings.reverse_proxy) {
console.log('No secret key saved for MistralAI');
return;
}