- Added `BlackForestLabs_Flux1KontextDev.py` to `g4f/Provider/hf_space` implementing image generation with streaming via HuggingFace Space
- Registered `BlackForestLabs_Flux1KontextDev` in `g4f/Provider/hf_space/__init__.py`
- Implemented `create_async_generator` to handle media upload, token fetching, and async result streaming
- Defined `run` method to POST and GET requests to the queue endpoint using ZeroGPU headers
- Added logic to process and upload media using `FormData` and `merge_media`
- Introduced `login_url` and `get_models` method in `Azure` provider with use of `AZURE_DEFAULT_MODEL` environment variable in `g4f/Provider/needs_auth/Azure.py
* feat: add agent CLI, new providers, and update models
- Add a new `agent` mode to the CLI, a feature-rich AI coding assistant with capabilities for file system operations, code execution, git integration, and interactive chat.
- Add new provider `OperaAria` with support for vision, streaming, and conversation history.
- Add new provider `Startnest` with support for `gpt-4o-mini`, vision, and streaming.
- Move providers `FreeGpt` and `Websim` to the `not_working` directory.
- Delete the `OIVSCodeSer2` provider.
- Rename the CLI `client` mode to `chat` and refactor its argument parsing.
- In `g4f/Provider/DeepInfraChat.py`:
- Add a new `api_endpoint` attribute.
- Extensively update and reorganize the `models` list and `model_aliases` dictionary with numerous new models.
- In `g4f/Provider/LambdaChat.py`:
- Change the `default_model` to `deepseek-v3-0324`.
- In `g4f/Provider/Together.py`:
- Update aliases for `llama-3.1-405b`, `deepseek-r1`, and `flux`.
- Add new models including `gemma-3-27b`, `gemma-3n-e4b`, and `qwen-3-32b`.
- In `g4f/models.py`:
- Add new model definitions for `aria`, `deepseek_v3_0324_turbo`, `deepseek_r1_0528_turbo`, and several `gemma` variants.
- Remove the `mixtral_8x22b` model definition.
- Update the `best_provider` lists for `default`, `default_vision`, `gpt_4o_mini`, `gemini-1.5-pro`, `gemini-1.5-flash`, and others to reflect provider changes.
- In `g4f/Provider/__init__.py`:
- Add `OperaAria` and `Startnest` to the list of imported providers.
- Remove `FreeGpt`, `OIVSCodeSer2`, and `Websim` from imports.
- In `requirements.txt`:
- Add `rich` as a new dependency for the agent CLI.
* feat: add gemma-3-4b alias to DeepInfraChat
In g4f/Provider/DeepInfraChat.py, add the gemma-3-4b alias to the model_aliases dictionary.
The new alias points to the google/gemma-3-4b-it model.
* feat: add OIVSCodeSer2 provider
- Create the new provider file .
- The provider supports the model and includes a custom method to generate a .
- Import and include in .
- Add to the for in .
- Add to in .
* feat: add OIVSCodeSer2 provider
- Create the new provider file .
- The provider supports the model and includes a custom method to generate a .
- Import and include in .
- Add to the for in .
- Add to in .
* refactor: Migrate from duckduckgo-search to ddgs library
* Replaced the dependency with the new library.
* In , updated imports from to and to .
* Modified the function in to use an context manager instead of a global instance.
* Updated the function to catch the new exception.
* In , updated the web search import and installation instructions to use .
* Removed unnecessary comments and simplified f-string formatting in and .
* Added and to .
* Added , , and to the extras in .
* test: Update web search tests for ddgs library and cleanup code
* In `etc/unittest/web_search.py`, updated imports from `duckduckgo_search` to `ddgs` and `DDGSError`.
* Added an import for `MissingRequirementsError` in `etc/unittest/web_search.py`.
* Modified exception handling in web search tests to catch both `DDGSError` and `MissingRequirementsError`.
* Removed temporary modification comments in `g4f/cli/agent/agent.py` and `g4f/tools/web_search.py`.
* fix: remove unstable CLI feature due to critical errors
- Remove the experimental CLI coding assistant feature due to multiple stability issues and critical errors in production environments
- Delete the entire `g4f/cli/agent/` directory and all related functionality
- Remove `rich` dependency from `requirements.txt` as it was only used by the removed feature
- Remove `rich` from the `all` extras in `setup.py`
- Revert CLI mode naming from `chat` back to `client` for consistency
- Clean up argument parsing in CLI to remove references to the removed functionality
- Remove installation instructions and imports related to the unstable feature from documentation
This removal is necessary due to:
- Unpredictable behavior causing data loss risks
- Incompatibility with certain system configurations
- Security concerns with unrestricted file system access
- Excessive resource consumption in production environments
Note: This feature may be reintroduced in the future with a more stable and secure implementation that addresses the current limitations and safety concerns.
---------
Co-authored-by: kqlio67 <kqlio67@users.noreply.github.com>
- Added "transparent" to `image_models` in `PollinationsAI` and mapped it to "gptimage"
- Modified transparent flag handling in `_generate_image` call in `PollinationsAI`
- Removed unused `cls.get_models()` call from image generation method in `PollinationsAI`
- Replaced `AsyncGeneratorProvider` with `AsyncAuthedProvider` in `HarProvider`
- Implemented `on_auth_async` in `HarProvider` to support browser-based auth via `nodriver`
- Replaced `create_async_generator` with `create_authed` in `HarProvider` to support `AuthResult`
- Removed custom `headers` in HAR post requests; used `auth_result.get_dict()` for `StreamSession`
- Refactored `Video` provider to support optional search in `get_response`
- Added `search` parameter to `RequestConfig.get_response` and `Video.create_async_generator`
- Improved browser automation and element interaction logic in `Video` provider
- Extracted video request interception to collect URLs using `nodriver`
- Reduced video polling loop timeout from 600 to 300 iterations in `Video`
- Updated CLI `client.py` to fix handling of `conversation.conversation` assignment
- Fixed argparse config: removed `nargs='?'` and added `metavar` for `--conversation-file`
- Improved image metadata extraction in API and backend when Pillow is available
- Modified `ImageResponse.__str__` to output HTML anchor/image tags with dimensions if present
- Added support for returning `target_path` from `copy_media` if `return_target` is True
- Changed default image processing size in `process_image` from 800x400 to 400x400
- Disabled RGBA-to-RGB flattening in `process_image`
- Improved `get_args_from_nodriver` to ensure proper referer and cookie handling
- Added helper `get_target_paths_and_urls` in `Api` to extract image dimensions from disk paths
- In `Grok.py`, replaced `browser.main_tab` with `await browser.get(cls.url)` to ensure correct page initialization
- Reordered page actions in `Grok.py` by invoking `await page.reload()` after attaching request handler
- In `Video.py`, modified prompt encoding by applying `.encode()[:100].decode("utf-8", "ignore").strip()` to handle non-UTF-8 characters safely
- Replaced single try block for clicking "Create" button with retry loop (up to 60 attempts), including exception handling and fallback browser stop
- In `client.py`, changed model assignment logic to check `self.provider is None` before overwriting existing value
- Updated conversation data merging logic in `client.py` to preserve existing `self.data` using dictionary unpacking instead of overwriting completely
- Modified `.gitignore` to add `.env` entry at the end of the file
- Prevents accidental inclusion of `.env` file in git tracking
- Ensures `.env` is treated as an ignored file going forward
- Appended change resulted in no newline at end of file after addition
- Introduced `clean_name` function in `Cloudflare.py` to format model names by removing specific suffixes.
- Updated `model_aliases` in `Cloudflare` class with new model mappings, and cleaned up redundant entries.
- Set `models` in the `Cloudflare` class to use keys from `model_aliases`.
- Adjusted the caching logic in `Cloudflare` to include new headers for requests.
- Added `parent` and `login_url` attributes in `DeepInfraChat` class.
- Updated `PollinationsAI` to clean up model retrieval logic and fixed handling of existing checks.
- Refactored `HarProvider` to inherit models and aliases from `LegacyLMArena`.
- Implemented loading environment variables from `.env` file in `cookies.py`.
- Updated default headers in `defaults.py` for user agent and `sec-ch-ua`.
- Cleaned up various model references in `any_model_map.py` to reflect differences in audio, vision, and other model types.
- Added a more centralized handling for API key management in `run_tools.py` to accommodate new nomenclature.
- Enhanced existing logic to allow for more granular loading and utilization of API keys from environment variables.
- Replaced imports of `STATIC_URL` from `..constants` to `..config` in:
- `g4f/Provider/PollinationsAI.py`
- `g4f/Provider/PollinationsImage.py`
- Updated `client.py` to import `CONFIG_DIR` and `COOKIES_DIR` from `g4f.config` instead of defining platform-specific directories.
- Changed the handling of conversation history in `ConversationManager`:
- Updated `self.history` to retrieve data from `data.get("items", [])` instead of `data.get("history", [])`.
- Modified the `stream_response` function to use `media` instead of `image` for handling media content.
- Updated the `save_content` function to accept `media_content` of type `Optional[MediaResponse]` instead of `content`.
- Adjusted the `run_client_args` function to handle media URLs and files more effectively, appending valid media to a list.
- Removed the `constants.py` file and added a new `config.py` file to centralize configuration settings.
- Updated the `CookiesConfig` class to set `cookies_dir` based on the existence of `CUSTOM_COOKIES_DIR`.
- Adjusted the `render` function in `website.py` to correctly handle file paths and requests for HTML files.
- Updated various references to use the new `config` module instead of the removed `constants` module.
- Removed extension of `vision_models` into `text_models` in `PollinationsAI.get_models`
- Unified image parameter handling in `PollinationsAI.create_payload`, removing special case for `"gptimage"` model
- Added conditional inclusion of `"transparent"` and `"image"` params based on `transparent` flag and media content
- Replaced `quote_plus` with `quote` for URL encoding in query string construction
- In `OpenaiTemplate.create_payload`, wrapped media URL extraction in `iter()` to fix `next()` usage with list comprehension
- Added GithubCopilotAPI provider to g4f/Provider/needs_auth and __init__.py
- Fixed typo "GGOGLE_SID_COOKIE" to "GOOGLE_SID_COOKIE" in Gemini.py and updated all references
- Updated PollinationsAI.py:
- Refined model aliases and removed/commented unused/legacy aliases
- Updated logic for loading audio and vision models, using swap_models for alias reversals
- Adjusted get_model and model loading methods for accuracy
- Changed default model lists for text, image, and vision models
- Updated conversation title and followup labels for followups tools
- Modified save_content in g4f/cli/client.py to handle url downloads for lists, allow cookies/headers, and removed duplicate HTTP download logic
- Added asyncio sleep after stdout writes in stream_response for smoother streaming
- Changed website.py render default to "home," adjusted chat route to accept any filename, and updated filenames used for rendering
- Updated model selection in g4f/models.py by removing PollinationsAI from best_provider and changing model provider order for specific models
- Enhanced media merging in g4f/tools/media.py to clarify comment about last user message and handle content appending for lists in render_messages
- Updated OpenaiTemplate.py to add an image_url field if media with http(s) URLs is present
- Adjusted test_provider_has_model in etc/unittest/models.py to skip providers requiring auth
- Added `fallback_model = "deepseek"` to `PollinationsAI` class in `PollinationsAI.py`
- Modified `PollinationsAI._agenerate` to safely call `get_model` only if `model` is not None
- Removed unused login loop in `OpenaiChat.synthesize` method in `OpenaiChat.py`
- Replaced full CLI parser and main function implementation in `__main__.py` with import from `.main`
- Added `get_auth_result` method to `AsyncAuthedProvider` in `base_provider.py` for reusable auth retrieval
- Replaced repeated auth loading logic in `create_completion` and `create_streaming_completion` with call to `get_auth_result` in `base_provider.py
- Modify `ConversationManager.load` to fix conversation loading when `self.provider` is not set.
- Update `ConversationManager.load` to correctly handle `self.provider` and `self.data`.
- Change description in `get_parser` from "GPT CLI client with conversation history" to "G4F CLI client with conversation history".
- Improve error handling in `run_client_args` for file reading.
- Add `UnicodeDecodeError` handling when reading input files as text in `run_client_args`.
- Simplify and correct the construction of `input_text` in `run_client_args`.
- Added `timeout` parameter support to `LMArenaBeta._create_async_generator` and passed it to `StreamSession`
- Ensured fallback to `default_model` in `LMArenaBeta` if `model` is not provided
- Modified `OpenaiChat._create_completion` to rebuild messages excluding assistant roles if conversation ID exists
- Corrected OpenaiChat `nodriver_auth` to await `browser.get` and replaced page access with reload
- Improved `save_content` in `client.py` with robust content extraction, null checks, and logging for missing content
- Removed premature `input_text.strip()` in `stream_response` and relocated it to `run_client_args`
- Simplified and centralized markdown filtering call in `save_content`
- Replaced raw `print` logging in `__init__.py` with `debug.log` for `nodriver` URL opening message