Commit Graph

307 Commits

Author SHA1 Message Date
hlohaus
d824d77d65 feat: Refactor PollinationsAI and ARTA provider structure
- Updated `PollinationsAI.py` to strip trailing periods and newlines from the prompt before encoding.
- Modified the encoding of the prompt to remove trailing percent signs after URL encoding.
- Simplified the audio response handling in `PollinationsAI.py` by removing unnecessary checks and yielding chunks directly.
- Renamed `ARTA.py` to `deprecated/ARTA.py` and updated import paths accordingly in `__init__.py`.
- Changed the `working` status of the `ARTA` class to `False` to indicate it is deprecated.
- Enhanced the `Video` class in `Video.py` to include aspect ratio handling and improved URL response caching.
- Updated the `RequestConfig` class to use a dictionary for storing URLs associated with prompts.
- Removed references to the `ARTA` provider in various files, including `models.py` and `any_provider.py`.
- Adjusted the `best_provider` assignments in `models.py` to exclude `ARTA` and include `HuggingFaceMedia` where applicable.
- Updated the response handling in `Video.py` to yield cached responses when available.
2025-06-19 00:42:41 +02:00
kqlio67
15d8318ab7 feat: Add dev tools, reorganize providers, and expand model support (#3019)
* feat: add repository path support and new md2html converter tool

- Add `--repo` argument to commit.py for specifying git repository path with validation
- Add `validate_git_repository()` function to check repository existence and git status
- Add `get_repository_info()` function to extract branch and remote information
- Update `get_git_diff()` and `make_commit()` functions to accept repository path parameter
- Add Path import and repository validation in main workflow
- Enhance error messages with repository-specific guidance and context
- Update argument parser description and help text for new repository functionality
- Expand module docstring with comprehensive usage examples and feature descriptions
- Add new md2html.py tool for converting Markdown files to HTML using GitHub API
- Add template.html file with GitHub-styled CSS and responsive design
- Implement batch processing, retry logic, and rate limit handling in md2html converter
- Add comprehensive command-line interface with directory processing and custom output options

* refactor: Update provider configurations and model handling

- Removed Dynaspark provider entirely by deleting `g4f/Provider/Dynaspark.py`
- Deprecated DDG provider by moving to `not_working` directory and updating imports
- Restructured HuggingFace and MiniMax providers into `needs_auth` subpackage:
  - Moved all HuggingFace provider files to `needs_auth/hf/`
    - Moved MiniMax providers to `needs_auth/mini_max/`
    - Updated ARTA provider:
      - Expanded `model_aliases` with new tattoo styles and added aliases
        - Added `get_model()` method for model resolution with list support
        - Simplified Blackbox provider:
          - Removed openrouter models and agentMode configurations
            - Reduced model lists to core GPT variants
              - Set session/subscriptionCache to None in payload
              - Added model resolution to Gemini providers:
                - Implemented `get_model()` in Gemini.py and GeminiPro.py
                  - Added alias handling with list support
                  - Updated model definitions in `g4f/models.py`:
                    - Removed references to Dynaspark and DDG providers
                      - Added new SDXL image models with ARTA provider
                        - Adjusted best_provider assignments across multiple models
                        - Removed Dynaspark/DDG references from provider imports and AnyProvider
                        - Added DDG to not_working providers in `__init__.py`

* feat: Add new models to DeepInfraChat, LambdaChat, and models

- Add 'deepseek-ai/DeepSeek-R1-0528' model to DeepInfraChat provider's models list
- Include alias 'deepseek-r1-0528' for DeepSeek-R1-0528 in DeepInfraChat's model_aliases
- Add 'apriel-5b-instruct' model to LambdaChat provider's models list
- Define new 'deepseek-r1-0528' model in models.py with DeepSeek base provider and DeepInfraChat as best provider

* refactor: simplify model registry and add validation

- Remove unused imports: sys, inspect, Set, Type
- Remove ModelRegistry._discovered flag and automatic discovery mechanism
- Add ModelRegistry.clear() method for resetting registry state
- Implement ModelRegistry.list_models_by_provider() for provider-based filtering
- Add ModelRegistry.validate_all_models() for configuration checks
- Remove Model._registered field and simplify registration logic
- Fix gemma_3_12b model name from empty string to 'gemma-3-12b'
- Add image model section header in model definitions
- Replace ModelUtils.convert dict with dynamic property
- Remove ModelUtils.refresh() method
- Register 'gemini' alias directly in ModelRegistry after model creation
- Remove module-level model discovery and ModelUtils.convert initialization

* refactor: Replace ModelUtils.convert property with class variable

- Add class variable `convert` to `ModelUtils` initialized as empty dictionary
- Replace `@property convert` method with `refresh()` class method that updates `convert`
- Remove dynamic property returning `ModelRegistry.all_models()`
- Add module-level assignment to initialize `ModelUtils.convert` with `ModelRegistry.all_models()`
- Include comment for clarity on filling the convert dictionary

* refactor: Reorganize providers and update model configuration

- Removed unused providers from `g4f/Provider/__init__.py`: ChatGpt, Pi, Pizzagpt, PuterJS, You
- Moved LMArenaBeta provider to `needs_auth` directory with updated relative imports
- Moved Pi provider to `needs_auth` directory with updated relative imports
- Moved PuterJS provider to `needs_auth` directory with updated relative imports
- Moved You provider to `needs_auth` directory with updated relative imports
- Added LMArenaBeta, Pi, PuterJS, You to `needs_auth/__init__.py`
- Moved ChatGpt provider to `not_working` directory with updated relative imports
- Moved Pizzagpt provider to `not_working` directory with updated relative imports
- Added ChatGpt, Pizzagpt to `not_working/__init__.py`
- Updated `g4f/models.py` to remove Reka import and change reka_core model provider
- Changed reka_core model's best_provider from IterListProvider to LegacyLMArena in `g4f/models.py`

* feat: add Together provider and update model handling

- Add new provider `Together` in `g4f/Provider/Together.py` with model aliases and configuration
- Implement `get_activation_key` and `get_models` methods in `Together` provider
- Add `get_model` method to resolve aliases in `Together` and `DeepInfraChat`
- Update `DeepInfraChat` model mappings to support multiple versions
  - Change "deepseek-v3" to list with two model options
    - Change "deepseek-r1" to list with two model options
      - Remove duplicate "deepseek-v3" entry
        - Remove "mistral-small" alias
        - Remove "midjourney" from `PollinationsAI.extra_image_models`
        - Register `Together` provider in `g4f/Provider/__init__.py`
        - Update `g4f/models.py` with new providers and models
          - Add `Together` to default and default_vision provider lists
            - Add `Together` as provider for multiple existing models
              - Add new vision model `qwen_2_vl_72b`
                - Add new text models: `qwen_2_5_7b`, `deepseek_r1_distill_qwen_1_5b`, `deepseek_r1_distill_qwen_14b`
                  - Add new image models: `flux_redux`, `flux_depth`, `flux_canny`, `flux_kontext_max`, `flux_dev_lora`, `flux_kontext_pro`
                    - Remove `pi` model definition
                      - Update provider assignments for multiple models to include `Together`

* refactor: Remove LegacyLMArena provider and update model best_providers

- Remove LegacyLMArena import from Provider list in models.py
- Delete LegacyLMArena from default model's best_provider IterListProvider
- Remove multiple obsolete model definitions (gpt_3_5_turbo, gpt_4_turbo, phi_3_small, etc.) that exclusively used LegacyLMArena
- Update best_provider for all remaining models to remove LegacyLMArena from IterListProvider arguments
- Replace LegacyLMArena with alternative providers in model definitions (e.g., OpenaiChat, Together, DeepInfraChat)
- Simplify model definitions by removing redundant IterListProvider wrappers for single providers
- Expand provider imports in any_provider.py to include Blackboxapi, OIVSCodeSer2, etc.
- Extend provider list in AnyProvider with additional working providers for fallback support

* refactor: Remove Blackboxapi provider

- Deleted Blackboxapi provider implementation file
- Removed Blackboxapi import from provider __init__ file
- Updated default model configuration to exclude Blackboxapi provider
- Removed Blackboxapi from llama-3.1-70b model's best_provider
- Updated any_provider to exclude Blackboxapi from provider list

* fix: add missing parameters to Together.get_model method signature

- Add api_key and api_base parameters to get_model method in Together class
- Import random module at the top of the file
- Add inline import comment for random module inside get_model method

* fix: remove broken providers and update model configurations

- Remove non-working providers: ChatGLM, DocsBot, GizAI, OIVSCodeSer5
- Fix Blackbox provider by removing userSelectedModel logic
- Update DeepInfraChat default model to 'deepseek-ai/DeepSeek-V3-0324'
- Add random model selection for DeepInfraChat aliases
- Update LambdaChat default model to 'deepseek-v3-0324' and expand model list
- Fix LegacyLMArena model loading with better error handling and caching
- Add retry logic and timeouts to LegacyLMArena streaming responses
- Improve LegacyLMArena response parsing to handle various data formats
- Update model references across g4f/models.py to remove deleted providers
- Fix AnyProvider model categorization logic for better grouping
- Add LegacyLMArena and ARTA to special provider handling in AnyProvider
- Update provider imports in __init__.py to exclude removed providers
- Add needs_auth flag to You.com and HailuoAI providers
- Fix GeminiPro get_model method signature to accept kwargs

* fix (g4f/Provider/LambdaChat.py)

* refactor: format models list in LMArenaBeta provider

- Convert single-line models array to multi-line format
- Add 11 new models (hunyuan, flux-kontext-pro, cobalt variants, etc.)
- Remove 6 models (bagel, goldmane, redsword, etc.)
- Update stephen model ID

---------

Co-authored-by: kqlio67 <kqlio67.noreply.github.com>
2025-06-11 15:29:27 +02:00
hlohaus
a862b683b9 Fix unittests 2025-05-31 11:48:20 +02:00
hlohaus
7b4de3a86c Revert models.py 2025-05-31 11:34:38 +02:00
kqlio67
d6a7504c8f refactor: rename LMArena provider to LegacyLMArena and update references
- Renamed file g4f/Provider/LMArena.py to g4f/Provider/LegacyLMArena.py
- Renamed class LMArena to LegacyLMArena with label changed to "Legacy LM Arena" and URL to "https://legacy.lmarena.ai" in g4f/Provider/LegacyLMArena.py
- Updated import in g4f/Provider/__init__.py to import LegacyLMArena instead of LMArena
- Changed HarProvider label and URL in g4f/Provider/har/__init__.py to "Legacy LM Arena (Har)" and "https://legacy.lmarena.ai"
- Modified multiple URLs and Host headers from "lmarena.ai" to "legacy.lmarena.ai" in HAR file g4f/Provider/har/lmarena.ai.har
- Replaced all references to LMArena with LegacyLMArena as best_provider in g4f/models.py across numerous model definitions and provider lists
2025-05-28 12:59:57 +03:00
kqlio67
241b0fb8b2 feat: add Blackboxapi provider and update model configurations
- Add new Blackboxapi provider class extending OpenaiTemplate
- Configure Blackboxapi with BlackBox API endpoint and default Llama 3.1 70B model
- Import Blackboxapi in Provider __init__.py
- Add Blackboxapi to default model provider list
- Update llama_3_1_70b model to use IterListProvider with Blackboxapi and LMArena
- Reorder default model providers to prioritize OIVSCodeSer variants
- Add LMArena to default model provider list
2025-05-28 00:14:45 +03:00
kqlio67
4f2bf3048b refactor: remove deprecated providers, rename LMArenaProvider, update LMArena and models
- Deleted multiple deprecated providers including Acytoo, AiAsk, AiService, Aibn, Aivvm, Berlin, ChatAnywhere, ChatgptDuo, CodeLinkAva, Cromicle, DfeHub, EasyChat, FakeGpt, FastGpt, Forefront, GPTalk, GeekGpt, GetGpt, H2o, Hashnode, Myshell, NoowAi, Opchatgpts, OpenAssistant, V50, Vitalentum, VoiGpt, Wewordle, Wuguokai, Ylokh, Yqcloud, and corresponding deprecated/__init__.py
- Renamed LMArenaProvider.py to LMArena.py and incorporated its functionality with enhancements, including updated model lists, aliases, comprehensive model discovery, payload building, and asynchronous generator for completions
- Removed LMArenaProvider import and added LMArena import in Provider/__init__.py
- Modified Blackbox provider:
  - Removed generate_session_data method and updated generate_session to use fixed email
    - Updated session payload usage in send request to use generate_session without email argument
      - Added asyncMode flag set to False in session payload
      - In DeepInfraChat, removed model aliases for "llama-4-maverick-17b" and "llama-4-scout-17b"
      - In PollinationsAI, updated model aliases: replaced "command-r-plus-08-2024" with "command-r-plus"; added "gpt-image" and "grok-3-mini" aliases
      - In LambdaChat, added "llama-3.3-70b" mapping to "llama3.3-70b-instruct"
      - In hf_space:
        - Deleted Qwen_QVQ_72B and Voodoohop_Flux1Schnell providers
          - Updated model_aliases in Qwen_Qwen_2_5_Max to fix model alias key from "qwen-2-5-max" to "qwen-2.5-max"
            - Changed model_aliases in StabilityAI_SD35Large from "stable-diffusion-3.5-large" to "sd-3.5-large"
              - Removed imports of deleted providers in hf_space/__init__.py and updated defaults accordingly
              - In BingCreateImages moved import to relative from .bing.create_images
              - Moved bing directory into needs_auth directory and updated imports accordingly
              - Changed PuterJS provider:
                - Changed working flag from True to False
                  - Changed return_conversation default from False to True in create_async_generator
                    - Changed yield error messages to raising exceptions for authentication and rate limits
                    - Modified models.py:
                      - Added ModelRegistry class for dynamic registration and lookup of Model instances
                        - Modified Model dataclass to auto-register instances on initialization via ModelRegistry
                          - Adjusted imports and removed PuterJS from lists of providers and best_provider assignments
                            - Replaced many references of PuterJS as best_provider with LMArena or IterListProvider including core models like gpt-3.5-turbo, gpt-4, gpt-4o, llama series, mistral, hermes, Microsoft phi, gemini, anthopic claude, cohere, qwen, deepseek, and others
                              - Fixed aliases and model names (e.g., "qwen-2-5-max" to "qwen-2.5-max")
                                - Removed outdated or deprecated model definitions referencing PuterJS
                                - Updated HarProvider label to "LM Arena (Har)" from "LM Arena"
                                - Removed deprecated providers imports from Provider/__init__.py and not_working directory imports updated accordingly
                                - Various exact functions impacted: create_async_generator in providers Blackbox, LMArena, PollinationsAI, LambdaChat, PuterJS; model aliases and model definitions in models.py; Provider package __init__.py files; BingCreateImages import; and deletions of numerous deprecated providers and not_working providers.
2025-05-25 21:38:12 +03:00
kqlio67
f4cd4890d3 feat: enhance provider support and add PuterJS provider (#2999)
* feat: enhance provider support and add PuterJS provider

- Add new PuterJS provider with extensive model support and authentication handling
- Add three new OIVSCode providers (OIVSCodeSer2, OIVSCodeSer5, OIVSCodeSer0501)
- Fix Blackbox provider with improved model handling and session generation
- Update model aliases across multiple providers for consistency
- Mark DDG provider as not working
- Move TypeGPT to not_working directory
- Fix model name formatting in DeepInfraChat and other providers (qwen3 → qwen-3)
- Add get_model method to LambdaChat and other providers for better model alias handling
- Add ModelNotFoundError import to providers that need it
- Update model definitions in models.py with new providers and aliases
- Fix client/stubs.py to allow arbitrary types in ChatCompletionMessage

* Fix conflicts g4f/Provider/needs_auth/Grok.py

* fix: update Blackbox provider default settings

- Changed  parameter to use only the passed value without fallback to 1024
- Set  to  instead of  in request payload

* feat: add WeWordle provider with gpt-4 support

- Created new WeWordle.py provider file implementing AsyncGeneratorProvider
- Added WeWordle class with API endpoint at wewordle.org/gptapi/v1/web/turbo
- Set provider properties: working=True, needs_auth=False, supports_stream=True
- Configured default_model as 'gpt-4' with retry mechanism for API requests
- Implemented URL sanitization logic to handle malformed URLs
- Added response parsing for different JSON response formats
- Added WeWordle to Provider/__init__.py imports
- Added WeWordle to default model providers list in models.py
- Added WeWordle to gpt_4 best_provider list in models.py

* feat: add DocsBot provider with GPT-4o support

- Added new DocsBot.py provider file implementing AsyncGeneratorProvider and ProviderModelMixin
- Created Conversation class extending JsonConversation to track conversation state
- Implemented create_async_generator method with support for:
  - Streaming and non-streaming responses
  - System messages
  - Message history
  - Image handling via data URIs
  - Conversation tracking
- Added DocsBot to Provider/__init__.py imports
- Added DocsBot to default and default_vision model providers in models.py
- Added DocsBot as a provider for gpt_4o model in models.py
- Set default_model and vision support to 'gpt-4o'
- Implemented API endpoint communication with docsbot.ai

* feat: add OpenAIFM provider and update audio model references

- Added new OpenAIFM provider in g4f/Provider/audio/OpenAIFM.py for text-to-speech functionality
- Updated PollinationsAI.py to rename "gpt-4o-audio" to "gpt-4o-mini-audio"
- Added OpenAIFM to audio provider imports in g4f/Provider/audio/__init__.py
- Modified save_response_media() in g4f/image/copy_images.py to handle source_url separately from media_url
- Added new gpt_4o_mini_tts AudioModel in g4f/models.py with OpenAIFM as best provider
- Updated ModelUtils dictionary in models.py to include both gpt_4o_mini_audio and gpt_4o_mini_tts

* fix: improve PuterJS provider and add Gemini to best providers

- Changed client_id generation in PuterJS from time-based to UUID format
- Fixed duplicate json import in PuterJS.py
- Added uuid module import in PuterJS.py
- Changed host header from "api.puter.com" to "puter.com"
- Modified error handling to use Exception instead of RateLimitError
- Added Gemini to best_provider list for gemini-2.5-flash model
- Added Gemini to best_provider list for gemini-2.5-pro model
- Fixed missing newline at end of Gemini.py file

---------

Co-authored-by: kqlio67 <kqlio67.noreply.github.com>
2025-05-19 11:44:15 +02:00
hlohaus
082c152248 Fix unittests 2025-05-17 11:08:52 +02:00
hlohaus
3775c1e06d fix: improve error handling and add type checks in various providers and API
- Updated error handling in g4f/Provider/DDG.py to raise ResponseError instead of yield error strings
- Replaced yield statements with raises in g4f/Provider/DDG.py for HTTP and response errors
- Added response raising in g4f/Provider/DeepInfraChat.py for image upload responses
- Included model alias validation and error raising in g4f/Provider/hf/HuggingFaceMedia.py
- Corrected model alias dictionary key in g4f/Provider/hf_space/StabilityAI_SD35Large.py
- Ensured referrer parameter default value in g4f/Provider/PollinationsImage.py
- Removed duplicate imports and adjusted get_models method in g4f/Provider/har/__init__.py
- Modified g4f/gui/server/api.py to remove unused conversation parameter in _create_response_stream
- Fixed logic to handle single exception in g4f/providers/retry_provider.py
- Added missing import of JsonConversation in g4f/providers/retry_provider.py
- Corrected stream_read_files to replace extension in return string in g4f/tools/files.py
2025-05-17 10:02:13 +02:00
kqlio67
c3d61ad9e3 refactor: update providers and models for better compatibility
- 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
2025-05-12 20:24:36 +03:00
H Lohaus
dc0705c082 Update models.py 2025-04-26 12:34:25 +02:00
hlohaus
e83282fc4b feat: add EdgeTTS audio provider and global image→media refactor
- **Docs**
  - `docs/file.md`: update upload instructions to use inline `bucket` content parts instead of `tool_calls/bucket_tool`.
  - `docs/media.md`: add asynchronous audio transcription example, detailed explanation, and notes.

- **New audio provider**
  - Add `g4f/Provider/audio/EdgeTTS.py` implementing Edge Text‑to‑Speech (`EdgeTTS`).
  - Create `g4f/Provider/audio/__init__.py` for provider export.
  - Register provider in `g4f/Provider/__init__.py`.

- **Refactor image → media**
  - Introduce `generated_media/` directory and `get_media_dir()` helper in `g4f/image/copy_images.py`; add `ensure_media_dir()`; keep back‑compat with legacy `generated_images/`.
  - Replace `images_dir` references with `get_media_dir()` across:
    - `g4f/api/__init__.py`
    - `g4f/client/stubs.py`
    - `g4f/gui/server/api.py`
    - `g4f/gui/server/backend_api.py`
    - `g4f/image/copy_images.py`
  - Rename CLI/API config field/flag from `image_provider` to `media_provider` (`g4f/cli.py`, `g4f/api/__init__.py`, `g4f/client/__init__.py`).
  - Extend `g4f/image/__init__.py`
    - add `MEDIA_TYPE_MAP`, `get_extension()`
    - revise `is_allowed_extension()`, `to_input_audio()` to support wider media types.

- **Provider adjustments**
  - `g4f/Provider/ARTA.py`: swap `raise_error()` parameter order.
  - `g4f/Provider/Cloudflare.py`: drop unused `MissingRequirementsError` import; move `get_args_from_nodriver()` inside try; handle `FileNotFoundError`.

- **Core enhancements**
  - `g4f/providers/any_provider.py`: use `default_model` instead of literal `"default"`; broaden model/provider matching; update model list cleanup.
  - `g4f/models.py`: safeguard provider count logic when model name is falsy.
  - `g4f/providers/base_provider.py`: catch `json.JSONDecodeError` when reading auth cache, delete corrupted file.
  - `g4f/providers/response.py`: allow `AudioResponse` to accept extra kwargs.

- **Misc**
  - Remove obsolete `g4f/image.py`.
  - `g4f/Provider/Cloudflare.py`, `g4f/client/types.py`: minor whitespace and import tidy‑ups.
2025-04-19 03:20:57 +02:00
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
hlohaus
06546649db feat: add LM Arena provider, async‑ify Copilot & surface follow‑up suggestions
* **Provider/Blackbox.py**
  * Raise `RateLimitError` when `"You have reached your request limit for the hour"` substring is detected
* **Provider/Copilot.py**
  * Convert class to `AsyncGeneratorProvider`; rename `create_completion` → `create_async_generator`
  * Swap `curl_cffi.requests.Session` for `AsyncSession`; reduce default timeout to **30 s**
  * Fully async websocket flow (`await session.ws_connect`, `await wss.send/recv/close`)
  * Emit new response types: `TitleGeneration`, `SourceLink`, aggregated `Sources`
  * Track request completion with `done` flag; collect citations in `sources` dict
* **Provider/DuckDuckGo.py**
  * Replace `duckduckgo_search.DDGS` with `duckai.DuckAI`
  * Change base class to `AbstractProvider`; drop nodriver‑based auth
* **Provider/PollinationsAI.py**
  * Re‑build text/audio model lists ensuring uniqueness; remove unused `extra_text_models`
  * Fix image seed logic (`i==1` for first retry); propagate streaming `error` field via `ResponseError`
* **Provider/hf_space**
  * **New file** `LMArenaProvider.py` implementing async queue/stream client
  * Register `LMArenaProvider` in `hf_space/__init__.py`; delete `G4F` import
* **Provider/needs_auth/CopilotAccount.py**
  * Inherit order changed to `Copilot, AsyncAuthedProvider`
  * Refactor token & cookie propagation; add `cookies_to_dict` helper
* **Provider/needs_auth/OpenaiChat.py**
  * Parse reasoning thoughts/summary; yield `Reasoning` responses
  * Tighten access‑token validation and nodriver JS evaluations (`return_by_value`)
  * Extend `Conversation` with `p` and `thoughts_summary`
* **providers/response.py**
  * Add `SourceLink` response class returning single formatted citation link
* **providers/base_provider.py**
  * Serialize `AuthResult` with custom `json.dump` to handle non‑serializable fields
  * Gracefully skip empty cache files when loading auth data
* **image/copy_images.py**
  * Ignore file extensions longer than 4 chars when inferring type
* **requests/__init__.py**
  * Use `return_by_value=True` for `navigator.userAgent` extraction
* **models.py**
  * Remove `G4F` from model provider lists; update `janus_pro_7b` best providers
* **GUI server/api.py**
  * Stream `SuggestedFollowups` to client (`"suggestions"` event)
* **GUI static assets**
  * **style.css**: bold chat title, add `.suggestions` styles, remove padding from `.chat-body`
  * **chat.v1.js**
    * Capture `suggestions` packets, render buttons, and send as quick replies
    * Re‑order finish‑reason logic; adjust token count placement and system‑prompt toggling
  * **chat-top-panel / footer** interactions updated accordingly
* **gui/client/static/js/chat.v1.js** & **css** further UI refinements (scroll handling, token counting, hide prompt toggle)
* Minor updates across multiple files to match new async interfaces and headers (`userAgent`, `raise_for_status`)
2025-04-17 01:21:58 +02:00
hlohaus
03e37e0bee refactor: update string conversion, provider aliases, and model mappings
- In **g4f/Provider/Cloudflare.py**:
  - Added `from .helper import to_string`.
  - Replaced conditional string checks with `to_string(message["content"])` for both `"content"` and elements in `"parts"`.

- In **g4f/Provider/PollinationsAI.py**:
  - Removed `"o3-mini"` from the `vision_models` list.
  - Updated the alias mapping dictionary by:
    - Removing the `"o3-mini": "openai-reasoning"` entry.
    - Removing the duplicate `"gpt-4o-mini": "searchgpt"` mapping.
    - Removing the duplicate `"gemini-2.0-flash-thinking": "gemini-reasoning"` entry.
    - Removing the `"qwq-32b": "qwen-reasoning"` mapping.
    - Adding a new alias `"llama-4-scout": "llamascout"`.

- In **g4f/gui/client/static/css/style.css**:
  - Changed the `border-left` property value from `var(--colour-4)` to `var(--media-select)`.

- In **g4f/models.py**:
  - For the `"o3-mini"` model, removed `PollinationsAI` from its `best_provider` list.
  - Changed the comment from `# llama 2` to `### llama 2-4 ###` and removed redundant comments for llama 3.1 and 3.2.
  - Added a new model `llama_4_scout` with `base_provider` set to `"Meta Llama"` and `best_provider` as `IterListProvider([Cloudflare, PollinationsAI])`.
  - For the `"qwq-32b"` model, removed `PollinationsAI` from its `best_provider` list.
  - Updated the `ModelUtils` mapping to include the new `llama_4_scout` model.
2025-04-16 14:43:57 +02:00
kqlio67
54ef1a511c docs: update providers documentation and enhance support for Blackbox HAR auth
- Added "No auth / HAR file" authentication type in providers-and-models.md
- Added "Video generation" column to provider tables for future capability
- Updated model counts and provider capabilities throughout documentation
- Fixed ARTA provider with improved error handling and response validation
- Enhanced AllenAI provider with vision model support and proper image handling
- Significantly improved Blackbox provider:
  - Added HAR file authentication support
  - Added subscription status checking
  - Added premium/demo model differentiation
  - Improved session handling and error recovery
- Enhanced DDG provider with better error handling for challenges
- Improved PollinationsAI and PollinationsImage providers' model handling
- Added VideoModel class in g4f/models.py
- Added audio/video generation indicators in GUI components
- Added new Ai2 models: olmo-1-7b, olmo-2-32b, olmo-4-synthetic
- Added new commit message generation tool in etc/tool/commit.py
2025-04-04 13:36:28 +03:00
hlohaus
494746302a Update models.py 2025-03-29 20:11:32 +01:00
kqlio67
29139b1172 Add Blackbox AI Pro model and fix URL redirect format in backend_api.py 2025-03-26 18:18:01 +02:00
hlohaus
ce500f0d49 Set default model in HuggingFaceMedia
Improve handling of shared chats
Show api_key input if required
2025-03-26 01:32:05 +01:00
hlohaus
8eaaf5db95 Add HuggingFaceMedia provider with Video Generation
Add Support for Video Response in UI
Improve Support for Audio Response in UI
Fix ModelNotSupported errors in HuggingSpace providers
2025-03-23 05:27:52 +01:00
kqlio67
97f1964bb6 Standardize model configurations and enhance error handling (#2818)
* feat(docs/providers-and-models.md): add TypeGPT provider and update model support

* feat(g4f/models.py): add TypeGPT provider and enhance model configurations

* refactor(g4f/Provider/hf_space/BlackForestLabs_Flux1Dev.py): update model aliases and image models definition

* refactor(g4f/Provider/hf_space/BlackForestLabs_Flux1Schnell.py): adjust model configuration and aliases

* refactor(g4f/Provider/hf_space/CohereForAI_C4AI_Command.py): update model configuration and aliases

* refactor(g4f/Provider/hf_space/DeepseekAI_JanusPro7b.py): reorganize model classification attributes

* feat(g4f/Provider/hf_space/Microsoft_Phi_4.py): add model aliases and update vision model handling

* refactor(g4f/Provider/hf_space/Qwen_QVQ_72B.py): restructure model configuration and aliases

* feat(g4f/Provider/hf_space/Qwen_Qwen_2_5M_Demo.py): add model alias support for Qwen provider

* refactor(g4f/Provider/hf_space/Qwen_Qwen_2_72B_Instruct.py): derive model list from aliases

* refactor(g4f/Provider/hf_space/StabilityAI_SD35Large.py): adjust model list definitions using aliases

* fix(g4f/Provider/hf_space/Voodoohop_Flux1Schnell.py): correct image_models definition in Voodoohop provider

* feat(g4f/Provider/DDG.py): enhance request handling and error recovery

* feat(g4f/Provider/DeepInfraChat.py): update model configurations and request handling

* feat(g4f/Provider/TypeGPT.py): enhance TypeGPT API client with media support and async capabilities

* refactor(docs/providers-and-models.md): remove streaming column from provider tables

* Update docs/providers-and-models.md

* added(g4f/Provider/hf_space/Qwen_Qwen_2_5_Max.py): new provider

* Update g4f/Provider/hf_space/Qwen_Qwen_2_72B_Instruct.py

* added(g4f/Provider/hf_space/Qwen_Qwen_2_5.py): new provider

* Update g4f/Provider/DeepInfraChat.py g4f/Provider/TypeGPT.py

* Update g4f/Provider/LambdaChat.py

* Update g4f/Provider/DDG.py

* Update g4f/Provider/DeepInfraChat.py

* Update g4f/Provider/TypeGPT.py

* Add audio generation model and update documentation

* Update providers-and-models documentation and include ARTA in flux best providers

* Update ARTA provider details and adjust documentation for image models

* Remove redundant text_models assignment in LambdaChat provider

---------

Co-authored-by: kqlio67 <>
2025-03-22 10:49:25 +01:00
kqlio67
52ecfb5019 Add new providers and enhance existing provider configurations (#2805)
* New provider added(g4f/Provider/Websim.py)

* New provider added(g4f/Provider/Dynaspark.py)

* feat(g4f/gui/client/static/js/chat.v1.js): Enhance provider labeling for HuggingFace integrations

* feat(g4f/gui/server/api.py): add Hugging Face Space compatibility flag to provider data

* feat(g4f/models.py): add new providers and update model configurations

* Update g4f/Provider/__init__.py

* feat(g4f/Provider/AllenAI.py): expand model alias mappings for AllenAI provider

* feat(g4f/Provider/Blackbox.py): restructure image model handling and response processing

* feat(g4f/Provider/PollinationsAI.py): add new model aliases and streamline headers

* Update g4f/Provider/hf_space/*

* refactor(g4f/Provider/Copilot.py): update model alias mapping

* chore(g4f/models.py): update provider configurations for OpenAI models

* docs(docs/providers-and-models.md): update provider tables and model categorization

* fix(etc/examples/vision_images.py): update model and simplify client configuration

* fix(docs/providers-and-models.md): correct streaming status for GlhfChat provider

* docs(docs/providers-and-models.md): update provider capabilities and model documentation

* fix(models): update provider configurations for Mistral models

* fix(g4f/Provider/Blackbox.py): correct model alias key for Mistral variant

* feat(g4f/Provider/hf_space/CohereForAI_C4AI_Command.py): update supported model versions and aliases (close #2802)

* fix(documentation): correct model names and provider counts (https://github.com/xtekky/gpt4free/pull/2805#issuecomment-2727489835)

* fix(g4f/models.py): correct mistral model configurations

* fix(g4f/Provider/DeepInfraChat.py): correct mixtral-small alias key

* New provider added(g4f/Provider/LambdaChat.py)

* feat(g4f/models.py): add new providers and enhance model configurations

* docs(docs/providers-and-models.md): add LambdaChat provider and update model listings

* feat(g4f/models.py): add new Liquid AI model and enhance providers

* docs(docs/providers-and-models.md): update model listings and provider counts

* feat(g4f/Provider/LambdaChat.py): add conditional reasoning processing based on model

* fix(g4f/tools/run_tools.py): handle combined thinking tags in single chunk

* New provider added(g4f/Provider/Goabror.py)

* feat(g4f/Provider/Blackbox.py): implement dynamic session management and model access control

* refactor(g4f/models.py): update provider configurations and model entries

* docs(docs/providers-and-models.md): update model listings and provider counts

---------

Co-authored-by: kqlio67 <>
2025-03-20 17:36:00 +01:00
H Lohaus
2615237464 Update models.py 2025-03-12 15:25:37 +01:00
kqlio67
c79635aaeb Update models and providers with improved documentation and code structure (#2786)
* docs(docs/providers-and-models.md): update documentation structure and model listings

* refactor(g4f/debug.py): add type hints and docstrings

* refactor(g4f/tools/run_tools.py): Restructure tool handling and improve modularity

* refactor(g4f/providers/response.py): enhance type hints and code documentation

* feat(g4f/models.py): Update model providers and add new models

* feat(g4f/Provider/Blackbox.py): add encrypted session handling and model updates

* fix(g4f/Provider/ChatGptEs.py): migrate to curl_cffi for request handling and improve error resilience

* feat(g4f/Provider/DeepInfraChat.py): Update default model and add new DeepSeek variants

* feat(g4f/Provider/Free2GPT.py): add Gemini models and streamline headers

* feat(g4f/Provider/FreeGpt.py): Add support for Gemini 1.5 Flash model

* feat(g4f/Provider/Liaobots.py): Add Claude 3.7 models and update default GPT-4o

* fix(g4f/Provider/PollinationsAI.py): Correct model mappings and generation parameters

* feat(g4f/Provider/PollinationsImage.py): Add class identifier label

* chore(g4f/Provider/TeachAnything.py): Update default model and simplify model handling

* (g4f/Provider/Mhystical.py): Remove class implementation

* chore(g4f/Provider/Prodia.py > g4f/Provider/not_working/Prodia.py): mark Prodia provider as non-working

* feat(g4f/Provider/Blackbox.py): Add Claude 3.7 Sonnet model alias

* chore(g4f/models.py): Update model configurations

* fix(g4f/Provider/ChatGptEs.py): improve request reliability and nonce detection

---------

Co-authored-by: kqlio67 <>
2025-03-09 19:46:27 +01:00
hlohaus
da0cc3fdfc Update models list 2025-03-06 20:18:02 +01:00
hlohaus
791b9f5c5a Add default llama 3 model 2025-02-27 18:47:48 +01:00
hlohaus
1d3a139a53 Add new media selection in UI
Add HuggingFace provider provider
Auto refresh Google Gemini cookies
Add sources to search results
2025-02-26 11:41:00 +01:00
kqlio67
07a8dfdff7 AI Provider and Model Updates: Adding New, Removing Deprecated, and Enhancing Functionality (#2739)
* docs(docs/providers-and-models.md): Update provider listings and model information

* feat(g4f/models.py): update model configurations and expand provider support

* fix(g4f/gui/client/static/js/chat.v1.js): correct provider checkbox initialization logic

* feat(g4f/Provider/Blackbox.py): update model configurations and premium handling

* feat(g4f/Provider/ChatGLM.py): add finish reason handling and update default model

* chore(g4f/Provider/DDG.py): Reorder model entries for consistency

* feat(g4f/Provider/ImageLabs.py): Update default image model to sdxl-turbo

* feat(g4f/Provider/Liaobots.py): update supported model configurations and aliases

* feat(g4f/Provider/OIVSCode.py): Update API endpoint and expand model support

* fix(g4f/Provider/needs_auth/CablyAI.py): Enforce authentication requirement

* Removed the provider (g4f/Provider/BlackboxAPI.py)

* fix(g4f/providers/base_provider.py): improve cache validation in AsyncAuthedProvider

* Update g4f/models.py

* fix(g4f/Provider/Liaobots.py): remove deprecated Gemini model aliases

* chore(g4f/models.py): Remove Grok-2 and update Gemini provider configurations

* chore(docs/providers-and-models.md): Remove deprecated Grok models from provider listings

* New provider added (g4f/Provider/AllenAI.py)

* feat(g4f/models.py): Add Ai2 models and update provider references

* feat(docs/providers-and-models.md): update providers and models documentation

* fix(g4f/models.py): update experimental model provider configuration

* fix(g4f/Provider/PollinationsImage.py): Initialize image_models list and update label

* fix(g4f/Provider/PollinationsAI.py): Resolve model initialization and alias conflicts

* refactor(g4f/Provider/PollinationsAI.py): improve model initialization and error handling

* refactor(g4f/Provider/PollinationsImage.py): Improve model synchronization and initialization

* Update g4f/Provider/AllenAI.py

---------

Co-authored-by: kqlio67 <>
2025-02-24 15:53:20 +01:00
hlohaus
ba60296677 Fix unittest, update model lists 2025-02-22 13:19:52 +01:00
hlohaus
b84f35f4e4 Improve model list in HuggingFace
WakeLook and disable count tokens for performance
Export and import settings in UI
Some styling improvments in UI
Fix curl_cffi updated bugs
2025-02-22 03:33:12 +01:00
hlohaus
116c41dd27 Add mixtral_small_24b model from DDG 2025-02-21 08:51:58 +01:00
hlohaus
e53483d85b Improve tools support in OpenaiTemplate and GeminiPro
Update models in DDG, PerplexityLabs, Gemini
Fix issues with curl_cffi in new versions
2025-02-21 04:36:54 +01:00
Arken1xs
68414ece4c Small fixes and updates around various providers (#2717)
* Update DDG.py: added Llama 3.3 Instruct and o3-mini

Duck.ai now supports o3-mini, and previous Llama 3.1 70B is now replaced by Llama 3.3 70B.

* Update DDG.py: change Llama 3.3 70B Instruct ID to "meta-llama/Llama-3.3-70B-Instruct-Turbo"

Fixed typo in full model name

* Update Cerebras.py: add "deepseek-r1-distill-llama-70b" to the models list

Cerebras now provides inference for a DeepSeek-R1 distilled to Llama 3.3 70B as well.

* Update models.py: reflect changes in DDG provider

- Removed DDG from best providers list for Llama 3.1 70B
- Added DDG to best providers list for o3-mini and Llama 3.3 70B

* A small update in HuggingFaceInference get_models() method

Previously, get_models() method was returning "TypeError: string indices must be integers, not 'str' on line 31" from time to time, possibly because of network error so the models list couldn't load and method was trying to parse this data. Now the code is updated in order to check for any potential errors first.

* Update BlackboxAPI.py: remove unused imports 

format_prompt() and JSON library are not being used here, so they may be removed safely.

* Update copilot.yml

This job is failing due to the error in JavaScript code; this commit is trying to fix it.

* Update providers-and-models.md to reflect latest changes

Updated models list and removed providers that are currently not working.
2025-02-19 16:34:30 +01:00
kqlio67
b1de624963 fix(g4f/Provider/PollinationsAI.py): Remove duplicate model alias 2025-02-10 19:50:35 +02:00
kqlio67
d678255397 feat(g4f/Provider/Blackbox.py): add premium model support and validation 2025-02-10 15:44:37 +02:00
kqlio67
a7f19ea588 refactor(g4f/Provider/CablyAI.py > g4f/Provider/needs_auth/CablyAI.py): restructure provider and simplify model handling 2025-02-10 13:35:20 +02:00
kqlio67
59c65a096f feat(g4f/Provider/Blackbox.py): Add Gemini-Flash-2.0 model and improve premium handling 2025-02-07 19:50:21 +02:00
kqlio67
88e7ef98f0 Adding New Models and Enhancing Provider Functionality (#2689)
* Adding New Models and Enhancing Provider Functionality

* fix(core): handle model errors and improve configuration

- Import ModelNotSupportedError for proper exception handling in model resolution
- Update login_url configuration to reference class URL attribute dynamically
- Remove redundant typing imports after internal module reorganization

* feat(g4f/Provider/PerplexityLabs.py): Add new Perplexity models and update provider listings

- Update PerplexityLabs provider with expanded Sonar model family including pro/reasoning variants
- Add new text models: sonar-reasoning-pro to supported model catalog
- Standardize model naming conventions across provider documentation

* feat(g4f/models.py): add Sonar Reasoning Pro model configuration

- Add new  model to Perplexity AI text models section
- Include model in ModelUtils.convert mapping with PerplexityLabs provider
- Maintain consistent configuration pattern with existing Sonar variants

* feat(docs/providers-and-models.md): update provider models and add new reasoning model

- Update PerplexityLabs text models to standardized sonar naming convention
- Add new sonar-reasoning-pro model to text models table
- Include latest Perplexity AI documentation references for new model

* docs(docs/providers-and-models.md): update AI providers documentation

- Remove deprecated chatgptt.me from no-auth providers list
- Delete redundant Auth column from HuggingSpace providers table
- Update PerplexityLabs model website URLs to sonar.perplexity.ai
- Adjust provider counts for GPT-4/GPT-4o models in text models section
- Fix inconsistent formatting in image models provider listings

* chore(g4f/models.py): remove deprecated ChatGptt provider integration

- Remove ChatGptt import from provider dependencies
- Exclude ChatGptt from default model's best_provider list
- Update gpt_4 model configuration to eliminate ChatGptt reference
- Modify gpt_4o vision model provider hierarchy
- Adjust gpt_4o_mini provider selection parameters

BREAKING CHANGE: Existing integrations using ChatGptt provider will no longer function

* Disabled provider (g4f/Provider/ChatGptt.py > g4f/Provider/not_working/ChatGptt.py): Problem with Cloudflare

* fix(g4f/Provider/CablyAI.py): update API endpoints and model configurations

* docs(docs/providers-and-models.md): update model listings and provider capabilities

* feat(g4f/models.py): Add Hermes-3 model and enhance provider configs

* feat(g4f/Provider/CablyAI.py): Add free tier indicators to model aliases

* refactor(g4f/tools/run_tools.py): modularize thinking chunk handling

* fix(g4f/Provider/DeepInfraChat.py): resolve duplicate keys and enhance request headers

* feat(g4f/Provider/DeepInfraChat.py): Add multimodal image support and improve model handling

* chore(g4f/models.py): update default vision model providers

* feat(docs/providers-and-models.md): update provider capabilities and model specifications

* Update docs/client.md

* docs(docs/providers-and-models.md): Update DeepInfraChat models documentation

* feat(g4f/Provider/DeepInfraChat.py): add new vision models and expand model aliases

* feat(g4f/models.py): update model configurations and add new providers

* feat(g4f/models.py): Update model configurations and add new AI models

---------

Co-authored-by: kqlio67 <>
2025-02-07 13:54:00 +01:00
hlohaus
be8c3f7cd2 Update model list, Fix model list in CablyAI 2025-02-05 14:06:41 +01:00
hlohaus
03d0c3053f Add mew G4F provider 2025-02-05 01:29:11 +01:00
hlohaus
1ca889cb21 Fix report errors, update demo model list 2025-02-04 17:11:58 +01:00
H Lohaus
fff1ce4482 Merge pull request #2679 from kqlio67/main
Updated some providers, added new providers and added new models
2025-02-03 21:32:05 +01:00
hlohaus
0638cbc175 Improve select custom model in UI
Updates for the response of the BackendApi
Update of the demo model list
Improve web search tool
Moved copy_images to /image
2025-02-03 20:23:21 +01:00
kqlio67
95821b5b8b Update g4f/Provider/DeepInfraChat.py 2025-02-03 17:57:27 +02:00
kqlio67
197f491d43 Disabled provider 'GPROChat' 2025-02-03 16:17:41 +02:00
kqlio67
c3e4a7c4e5 The DarkAI provider is disabled 2025-02-03 16:09:37 +02:00
kqlio67
de3a710140 Update docs/providers-and-models.md g4f/models.py g4f/Provider/Liaobots.py 2025-02-03 15:16:48 +02:00
kqlio67
569077ac20 Update docs/providers-and-models.md g4f/models.py 2025-02-03 14:23:13 +02:00
kqlio67
ec8caec579 Updated some providers, added new providers and added new models 2025-02-03 14:17:33 +02:00