gpt4free/g4f/Provider
H Lohaus 0a070bdf10
feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925)
* feat: introduce AnyProvider & LM Arena, overhaul model/provider logic

- **Provider additions & removals**
  - Added `Provider/LMArenaProvider.py` with full async stream implementation and vision model support
  - Registered `LMArenaProvider` in `Provider/__init__.py`; removed old `hf_space/LMArenaProvider.py`
  - Created `providers/any_provider.py`; registers `AnyProvider` dynamically in `Provider`
- **Provider framework enhancements**
  - `providers/base_provider.py`
    - Added `video_models` and `audio_models` attributes
  - `providers/retry_provider.py`
    - Introduced `is_content()` helper; now treats `AudioResponse` as stream content
- **Cloudflare provider refactor**
  - `Provider/Cloudflare.py`
    - Re‑implemented `get_models()` with `read_models()` helper, `fallback_models`, robust nodriver/curl handling and model‑name cleaning
- **Other provider tweaks**
  - `Provider/Copilot.py` – removed `"reasoning"` alias and initial `setOptions` WS message
  - `Provider/PollinationsAI.py` & `PollinationsImage.py`
    - Converted `audio_models` from list to dict, adjusted usage checks and labels
  - `Provider/hf/__init__.py` – applies `model_aliases` remap before dispatch
  - `Provider/hf_space/DeepseekAI_JanusPro7b.py` – now merges media before upload
  - `needs_auth/Gemini.py` – dropped obsolete Gemini model entries
  - `needs_auth/GigaChat.py` – added lowercase `"gigachat"` alias
- **API & client updates**
  - Replaced `ProviderUtils` with new `Provider` map usage throughout API and GUI server
  - Integrated `AnyProvider` as default fallback in `g4f/client` sync & async flows
  - API endpoints now return counts of providers per model and filter by `x_ignored` header
- **GUI improvements**
  - Updated JS labels with emoji icons, provider ignore logic, model count display
- **Model registry**
  - Renamed base model `"GigaChat:latest"` ➜ `"gigachat"` in `models.py`
- **Miscellaneous**
  - Added audio/video flags to GUI provider list
  - Tightened error propagation in `retry_provider.raise_exceptions`

* Fix unittests

* fix: handle None conversation when accessing provider-specific data

- Modified `AnyProvider` class in `g4f/providers/any_provider.py`
- Updated logic to check if `conversation` is not None before accessing `provider.__name__` attribute
- Wrapped `getattr(conversation, provider.__name__, None)` block in an additional `if conversation is not None` condition
- Changed `setattr(conversation, provider.__name__, chunk)` to use `chunk.get_dict()` instead of the object directly
- Ensured consistent use of `JsonConversation` when modifying or assigning `conversation` data

* ```
feat: add provider string conversion & update IterListProvider call

- In g4f/client/__init__.py, within both Completions and AsyncCompletions, added a check to convert the provider from a string using convert_to_provider(provider) when applicable.
- In g4f/providers/any_provider.py, removed the second argument (False) from the IterListProvider constructor call in the async for loop.
```

---------

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-04-18 14:10:51 +02:00
..
bing Add filessupport, scrape and refine your data 2025-01-01 04:20:02 +01:00
deprecated Add Path and PathLike support when uploading images (#2514) 2024-12-28 16:50:08 +01:00
hf feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
hf_space feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
local Fix Image Generation in HuggingChat 2025-01-24 03:13:04 +01:00
mini_max Support reasoning tokens by default 2025-01-31 17:36:48 +01:00
needs_auth feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
not_working Fix using ImageResponse 2025-03-31 21:33:17 +02:00
npm Revert "Cleanup unused dependencies" 2024-01-23 04:59:46 +01:00
openai feat: introduce render_messages and enhance HAR/conversation handling 2025-04-17 07:14:34 +02:00
template Add example for video generation 2025-03-27 09:38:31 +01:00
__init__.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
AllenAI.py feat: improve file handling and streamline provider implementations 2025-04-08 19:00:44 +02:00
ARTA.py feat: improve file handling and streamline provider implementations 2025-04-08 19:00:44 +02:00
base_provider.py Improve download of generated images, serve images in the api (#2391) 2024-11-20 19:58:16 +01:00
Blackbox.py feat: introduce render_messages and enhance HAR/conversation handling 2025-04-17 07:14:34 +02:00
Chatai.py New provider added (g4f/Provider/Chatai.py) (#2864) 2025-04-06 11:28:20 +02:00
ChatGLM.py AI Provider and Model Updates: Adding New, Removing Deprecated, and Enhancing Functionality (#2739) 2025-02-24 15:53:20 +01:00
ChatGpt.py Add AsyncAuthedProvider in Copilot 2025-01-28 20:33:50 +01:00
ChatGptEs.py Update models and providers with improved documentation and code structure (#2786) 2025-03-09 19:46:27 +01:00
Cloudflare.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
Copilot.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
DDG.py docs: update providers documentation and enhance support for Blackbox HAR auth 2025-04-04 13:36:28 +03:00
DeepInfraChat.py Standardize model configurations and enhance error handling (#2818) 2025-03-22 10:49:25 +01:00
DuckDuckGo.py feat: add LM Arena provider, async‑ify Copilot & surface follow‑up suggestions 2025-04-17 01:21:58 +02:00
Dynaspark.py Add audio transcribing example and support 2025-03-21 03:17:45 +01:00
Free2GPT.py Update models and providers with improved documentation and code structure (#2786) 2025-03-09 19:46:27 +01:00
FreeGpt.py Update models and providers with improved documentation and code structure (#2786) 2025-03-09 19:46:27 +01:00
FreeRouter.py fix: update provider integrations, recipient logic, and auth handling 2025-04-17 03:26:50 +02:00
GizAI.py Improve TypeGPT, GizAI, Goabror and LambdaChat provider 2025-03-20 21:45:59 +01:00
Glider.py Improve TypeGPT, GizAI, Goabror and LambdaChat provider 2025-03-20 21:45:59 +01:00
Goabror.py Improve TypeGPT, GizAI, Goabror and LambdaChat provider 2025-03-20 21:45:59 +01:00
helper.py Remove all not working provider (#1679) 2024-03-12 02:06:06 +01:00
ImageLabs.py Fix using ImageResponse 2025-03-31 21:33:17 +02:00
Jmuz.py Add Janus_Pro_7B provider 2025-01-30 00:35:51 +01:00
LambdaChat.py Standardize model configurations and enhance error handling (#2818) 2025-03-22 10:49:25 +01:00
Liaobots.py Fix Liaobots provider 2025-03-10 04:34:08 +01:00
LMArenaProvider.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
OIVSCode.py AI Provider and Model Updates: Adding New, Removing Deprecated, and Enhancing Functionality (#2739) 2025-02-24 15:53:20 +01:00
PerplexityLabs.py Delete buckets with the conversation 2025-03-29 11:22:22 +01:00
Pi.py Add leagcy port to docker-compose files 2025-01-26 16:32:32 +01:00
Pizzagpt.py Provider Updates and Fixes (#2570) 2025-01-15 22:35:05 +01:00
PollinationsAI.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
PollinationsImage.py feat: introduce AnyProvider & LM Arena, overhaul model/provider logic (#2925) 2025-04-18 14:10:51 +02:00
TeachAnything.py Update models and providers with improved documentation and code structure (#2786) 2025-03-09 19:46:27 +01:00
TypeGPT.py Update models.py 2025-03-29 20:11:32 +01:00
Websim.py Fix using ImageResponse 2025-03-31 21:33:17 +02:00
You.py Add chat share function 2025-03-25 01:46:57 +01:00
Yqcloud.py Provider Updates and Fixes (#2570) 2025-01-15 22:35:05 +01:00