summaryrefslogtreecommitdiffstats
path: root/g4f
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-22 18:08:04 +0200
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-04-22 18:08:04 +0200
commit6e064adb094bacd10bd8bbc8c18a405e1cf651cd (patch)
tree19b3a3e9bdd7ce2afed8070dac7b5f0f2a7f7308 /g4f
parentFix "domain" KeyError with Firefox .har (diff)
downloadgpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar.gz
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar.bz2
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar.lz
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar.xz
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.tar.zst
gpt4free-6e064adb094bacd10bd8bbc8c18a405e1cf651cd.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/GeminiPro.py9
-rw-r--r--g4f/gui/client/index.html10
-rw-r--r--g4f/gui/server/api.py28
3 files changed, 30 insertions, 17 deletions
diff --git a/g4f/Provider/GeminiPro.py b/g4f/Provider/GeminiPro.py
index 214b7383..56c211ef 100644
--- a/g4f/Provider/GeminiPro.py
+++ b/g4f/Provider/GeminiPro.py
@@ -11,12 +11,14 @@ from ..errors import MissingAuthError
from .helper import get_connector
class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
+ label = "Gemini API"
url = "https://ai.google.dev"
working = True
supports_message_history = True
needs_auth = True
- default_model = "gemini-pro"
- models = ["gemini-pro", "gemini-pro-vision"]
+ default_model = "gemini-1.5-pro-latest"
+ default_vision_model = default_model
+ models = [default_model, "gemini-pro", "gemini-pro-vision"]
@classmethod
async def create_async_generator(
@@ -32,11 +34,10 @@ class GeminiPro(AsyncGeneratorProvider, ProviderModelMixin):
connector: BaseConnector = None,
**kwargs
) -> AsyncResult:
- model = "gemini-pro-vision" if not model and image is not None else model
model = cls.get_model(model)
if not api_key:
- raise MissingAuthError('Missing "api_key"')
+ raise MissingAuthError('Add a "api_key"')
headers = params = None
if use_auth_header:
diff --git a/g4f/gui/client/index.html b/g4f/gui/client/index.html
index d84bbbe9..cfca51a9 100644
--- a/g4f/gui/client/index.html
+++ b/g4f/gui/client/index.html
@@ -130,11 +130,7 @@
<textarea id="DeepInfra-api_key" name="DeepInfra[api_key]" class="DeepInfraImage-api_key" placeholder="api_key"></textarea>
</div>
<div class="field box">
- <label for="Gemini-api_key" class="label" title="">Gemini:</label>
- <textarea id="Gemini-api_key" name="Gemini[api_key]" placeholder="&quot;__Secure-1PSID&quot; cookie"></textarea>
- </div>
- <div class="field box">
- <label for="GeminiPro-api_key" class="label" title="">GeminiPro API:</label>
+ <label for="GeminiPro-api_key" class="label" title="">Gemini API:</label>
<textarea id="GeminiPro-api_key" name="GeminiPro[api_key]" placeholder="api_key"></textarea>
</div>
<div class="field box">
@@ -157,6 +153,10 @@
<label for="OpenRouter-api_key" class="label" title="">OpenRouter:</label>
<textarea id="OpenRouter-api_key" name="OpenRouter[api_key]" placeholder="api_key"></textarea>
</div>
+ <div class="field box">
+ <label for="Replicate-api_key" class="label" title="">Replicate:</label>
+ <textarea id="Replicate-api_key" name="Replicate[api_key]" class="ReplicateImage-api_key" placeholder="api_key"></textarea>
+ </div>
</div>
<div class="bottom_buttons">
<button onclick="delete_conversations()">
diff --git a/g4f/gui/server/api.py b/g4f/gui/server/api.py
index 3d9f6a1c..020b2090 100644
--- a/g4f/gui/server/api.py
+++ b/g4f/gui/server/api.py
@@ -45,6 +45,7 @@ class Api():
@staticmethod
def get_image_models() -> list[dict]:
image_models = []
+ index = []
for provider in __providers__:
if hasattr(provider, "image_models"):
if hasattr(provider, "get_models"):
@@ -52,14 +53,25 @@ class Api():
parent = provider
if hasattr(provider, "parent"):
parent = __map__[provider.parent]
- for model in provider.image_models:
- image_models.append({
- "provider": parent.__name__,
- "url": parent.url,
- "label": parent.label if hasattr(parent, "label") else None,
- "image_model": model,
- "vision_model": parent.default_vision_model if hasattr(parent, "default_vision_model") else None
- })
+ if parent.__name__ not in index:
+ for model in provider.image_models:
+ image_models.append({
+ "provider": parent.__name__,
+ "url": parent.url,
+ "label": parent.label if hasattr(parent, "label") else None,
+ "image_model": model,
+ "vision_model": parent.default_vision_model if hasattr(parent, "default_vision_model") else None
+ })
+ index.append(parent.__name__)
+ elif hasattr(provider, "default_vision_model") and provider.__name__ not in index:
+ image_models.append({
+ "provider": provider.__name__,
+ "url": provider.url,
+ "label": provider.label if hasattr(provider, "label") else None,
+ "image_model": None,
+ "vision_model": provider.default_vision_model
+ })
+ index.append(provider.__name__)
return image_models
@staticmethod