mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-06 02:30:41 -08:00
- Changed default model in commit.py from "gpt-4o" to "claude-3.7-sonnet" - Fixed ARTA provider by adding proper auth token handling and form data submission - Updated Blackbox provider to use OpenRouter models instead of premium models - Improved DDG provider with simplified authentication and better error handling - Updated DeepInfraChat provider with new models and aliases - Removed non-working providers: Goabror, Jmuz, OIVSCode, AllenAI, ChatGptEs, FreeRouter, Glider - Moved non-working providers to the not_working directory - Added BlackboxPro provider in needs_auth directory with premium model support - Updated Liaobots provider with new models and improved authentication - Renamed Microsoft_Phi_4 to Microsoft_Phi_4_Multimodal for clarity - Updated LambdaChat provider with direct API implementation instead of HuggingChat - Updated models.py with new model definitions and provider mappings - Removed BlackForestLabs_Flux1Schnell from HuggingSpace providers - Updated model aliases across multiple providers for better compatibility - Fixed Dynaspark provider endpoint URL to prevent spam detection
65 lines
2.4 KiB
Python
65 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from aiohttp import ClientSession, FormData
|
|
|
|
from ..typing import AsyncResult, Messages, MediaListType
|
|
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
|
|
from ..requests.raise_for_status import raise_for_status
|
|
from ..image import to_bytes, is_accepted_format
|
|
from .helper import format_prompt
|
|
|
|
class Dynaspark(AsyncGeneratorProvider, ProviderModelMixin):
|
|
url = "https://dynaspark.onrender.com"
|
|
login_url = None
|
|
api_endpoint = "https://dynaspark.onrender.com/dsai_fuck_u_spammer"
|
|
|
|
working = True
|
|
needs_auth = False
|
|
use_nodriver = True
|
|
supports_stream = True
|
|
supports_system_message = False
|
|
supports_message_history = False
|
|
|
|
default_model = 'gemini-1.5-flash'
|
|
default_vision_model = default_model
|
|
vision_models = [default_vision_model, 'gemini-1.5-flash-8b', 'gemini-2.0-flash', 'gemini-2.0-flash-lite']
|
|
models = vision_models
|
|
|
|
model_aliases = {
|
|
"gemini-1.5-flash": "gemini-1.5-flash-8b",
|
|
"gemini-2.0-flash": "gemini-2.0-flash-lite",
|
|
}
|
|
|
|
@classmethod
|
|
async def create_async_generator(
|
|
cls,
|
|
model: str,
|
|
messages: Messages,
|
|
proxy: str = None,
|
|
media: MediaListType = None,
|
|
**kwargs
|
|
) -> AsyncResult:
|
|
headers = {
|
|
'accept': '*/*',
|
|
'accept-language': 'en-US,en;q=0.9',
|
|
'origin': 'https://dynaspark.onrender.com',
|
|
'referer': 'https://dynaspark.onrender.com/',
|
|
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36',
|
|
'x-requested-with': 'XMLHttpRequest'
|
|
}
|
|
async with ClientSession(headers=headers) as session:
|
|
form = FormData()
|
|
form.add_field('user_input', format_prompt(messages))
|
|
form.add_field('ai_model', model)
|
|
|
|
if media is not None and len(media) > 0:
|
|
image, image_name = media[0]
|
|
image_bytes = to_bytes(image)
|
|
form.add_field('file', image_bytes, filename=image_name, content_type=is_accepted_format(image_bytes))
|
|
|
|
async with session.post(f"{cls.api_endpoint}", data=form, proxy=proxy) as response:
|
|
await raise_for_status(response)
|
|
response_text = await response.text()
|
|
response_json = json.loads(response_text)
|
|
yield response_json["response"]
|