summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorkqlio67 <kqlio67@users.noreply.github.com>2024-10-22 14:02:35 +0200
committerkqlio67 <kqlio67@users.noreply.github.com>2024-10-22 14:02:35 +0200
commit8aa3c2cc4e18d9094fadc36573e38e7636d979cc (patch)
treea122cc059eba9310dceaa83c6f3b321e5bc8b50f /g4f/Provider
parentRestored provider (g4f/Provider/nexra/NexraSD15.py) (diff)
downloadgpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar.gz
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar.bz2
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar.lz
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar.xz
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.tar.zst
gpt4free-8aa3c2cc4e18d9094fadc36573e38e7636d979cc.zip
Diffstat (limited to 'g4f/Provider')
-rw-r--r--g4f/Provider/nexra/NexraSD21.py75
-rw-r--r--g4f/Provider/nexra/__init__.py1
2 files changed, 0 insertions, 76 deletions
diff --git a/g4f/Provider/nexra/NexraSD21.py b/g4f/Provider/nexra/NexraSD21.py
deleted file mode 100644
index 46cd6611..00000000
--- a/g4f/Provider/nexra/NexraSD21.py
+++ /dev/null
@@ -1,75 +0,0 @@
-from __future__ import annotations
-
-import json
-from aiohttp import ClientSession
-from ...image import ImageResponse
-
-from ...typing import AsyncResult, Messages
-from ..base_provider import AsyncGeneratorProvider, ProviderModelMixin
-
-
-class NexraSD21(AsyncGeneratorProvider, ProviderModelMixin):
- label = "Nexra Stable Diffusion 2.1"
- url = "https://nexra.aryahcr.cc/documentation/stable-diffusion/en"
- api_endpoint = "https://nexra.aryahcr.cc/api/image/complements"
- working = False
-
- default_model = 'stablediffusion-2.1'
- models = [default_model]
-
- model_aliases = {
- "sd-2.1": "stablediffusion-2.1",
- }
-
- @classmethod
- def get_model(cls, model: str) -> str:
- if model in cls.models:
- return model
- elif model in cls.model_aliases:
- return cls.model_aliases[model]
- else:
- return cls.default_model
-
- @classmethod
- async def create_async_generator(
- cls,
- model: str,
- messages: Messages,
- proxy: str = None,
- response: str = "url", # base64 or url
- **kwargs
- ) -> AsyncResult:
- model = cls.get_model(model)
-
- headers = {
- "Content-Type": "application/json",
- }
- async with ClientSession(headers=headers) as session:
- # Directly use the messages as the prompt
- data = {
- "prompt": messages,
- "model": model,
- "response": response,
- "data": {
- "prompt_negative": "",
- "guidance_scale": 9
- }
- }
- async with session.post(cls.api_endpoint, json=data, proxy=proxy) as response:
- response.raise_for_status()
- text_response = await response.text()
-
- # Clean the response by removing unexpected characters
- cleaned_response = text_response.strip('__')
-
- if not cleaned_response.strip():
- raise ValueError("Received an empty response from the server.")
-
- try:
- json_response = json.loads(cleaned_response)
- image_url = json_response.get("images", [])[0]
- # Create an ImageResponse object
- image_response = ImageResponse(images=image_url, alt="Generated Image")
- yield image_response
- except json.JSONDecodeError:
- raise ValueError("Unable to decode JSON from the received text response.")
diff --git a/g4f/Provider/nexra/__init__.py b/g4f/Provider/nexra/__init__.py
index 32b159d1..6121fdc0 100644
--- a/g4f/Provider/nexra/__init__.py
+++ b/g4f/Provider/nexra/__init__.py
@@ -13,6 +13,5 @@ from .NexraMidjourney import NexraMidjourney
from .NexraProdiaAI import NexraProdiaAI
from .NexraQwen import NexraQwen
from .NexraSD15 import NexraSD15
-from .NexraSD21 import NexraSD21
from .NexraSDLora import NexraSDLora
from .NexraSDTurbo import NexraSDTurbo