Commit graph

3989 commits

Author SHA1 Message Date
hlohaus
6c40bfdeb8 Update model map 2025-08-10 05:15:31 +02:00
hlohaus
f12649c1d3 Add OpenRouterFree provider 2025-08-10 05:07:55 +02:00
hlohaus
9defe08a41 Add raise_for_status in share auth 2025-08-10 01:33:39 +02:00
hlohaus
c69b6af69a Add share auth for EasyChat 2025-08-10 01:10:49 +02:00
hlohaus
b8edf24654 Update LMArena provider 2025-08-09 23:20:01 +02:00
hlohaus
de2a173cda Update LMArena provider 2025-08-09 23:12:20 +02:00
hlohaus
a0802b5c62 Update LMArena provider 2025-08-09 23:09:59 +02:00
hlohaus
8a5e5fbd70 Update LMArena provider 2025-08-09 23:07:49 +02:00
Oppon
bd87f40ca5
Enable reasoning model on GLM provider 2025-08-09 17:35:08 -03:00
hlohaus
a0a7a54b11 Remove print 2025-08-09 18:33:23 +02:00
hlohaus
b851fc36cb Ollama load api_key 2025-08-09 18:10:37 +02:00
hlohaus
012604a54f Fix loop in Ollama 2025-08-09 18:07:21 +02:00
hlohaus
28c4c61fdd refactor: simplify model alias management and update providers
- Removed specific model aliases for various models (e.g., "gpt-4.1-mini", "phi-4", "grok-3-mini").
- Replaced the `get_model` method with a simplified approach using `get_alias` for alias resolution.
- Updated model alias management in `PollinationsAI` to handle model aliases in `get_models` method.
- Refined the logic for adding models to `text_models` and `vision_models` in `PollinationsAI`.
- Replaced `deepseek-v3` and other model aliases with direct models in `PollinationsAI`.
- Modified `Ollama` class to handle local models and improve model fetching with API key.
- Changed the `create_async_generator` in `Ollama` to support local model handling and proxy use.
- Updated `Azure` class to remove unused `extra_body` argument and streamline stream handling.
- Updated model providers in `g4f/models.py` to remove certain providers (e.g., `PollinationsAI`) from `best_provider` lists for some models.
2025-08-09 17:22:47 +02:00
H Lohaus
0c69ba8fc3
Update typing.py 2025-08-09 14:12:48 +02:00
hlohaus
ddb5d5b5c4 Fix audio models 2025-08-09 11:20:29 +02:00
hlohaus
ea08a7a57d Add model tags to /api 2025-08-09 10:40:47 +02:00
hlohaus
ddab0ffa07 Remove fingerprint 2025-08-09 10:20:56 +02:00
hlohaus
17d36d5106 Add check fingerprint 2025-08-09 09:52:26 +02:00
hlohaus
adb756ef45 Add -e option to CLI client 2025-08-09 08:00:47 +02:00
hlohaus
8e6ddfbf47 Improve CLI commands 2025-08-09 07:01:27 +02:00
H Lohaus
23d4c6eb38
Update backend_api.py 2025-08-09 05:00:41 +02:00
hlohaus
ab6303da55 Fix unittests 2025-08-09 04:48:42 +02:00
hlohaus
71adc96bce Update model list 2025-08-09 04:44:58 +02:00
hlohaus
6fad9c5d58 refactor: update cookie browsers var and LMArenaBeta availability logic
- In `g4f/Provider/needs_auth/LMArenaBeta.py`, import `has_nodriver` from `...requests` in the same line as other imports
- Change `working` attribute to be set based on `has_nodriver` instead of `True`
- Add new class attribute `active_by_default = True` to `LMArenaBeta`
- In `g4f/cli/__init__.py`, change `--cookie-browsers` argument choices to use `g4f.cookies.BROWSERS` instead of `g4f.cookies.browsers`
- In `g4f/cli/__init__.py`, update `run_api_args` to assign to `g4f.cookies.BROWSERS` instead of `g4f.cookies.browsers`
- In `g4f/gui/gui_parser.py`, change import from `browsers` to `BROWSERS`
- In `g4f/gui/gui_parser.py`, update `--cookie-browsers` argument choices to use `BROWSERS` instead of `browsers`
- In `g4f/gui/run.py`, update `run_gui_args` to assign to `g4f.cookies.BROWSERS` instead of `g4f.cookies.browsers
2025-08-09 03:30:37 +02:00
hlohaus
b6f51f00d8 refactor: restructure core utilities, typing, and request handling
- In `g4f/__init__.py`, changed logger setup to use fixed "g4f" name and refactored `ChatCompletion.create` and `create_async` to share `_prepare_request` logic for preprocessing arguments
- In `g4f/config.py`, added `__future__.annotations`, `lru_cache` import, wrapped `get_config_dir` with `@lru_cache`, and simplified platform branch logic
- In `g4f/cookies.py`, added typing imports, renamed `browsers` to `BROWSERS`, reformatted `DOMAINS`, updated docstrings, improved loop logic in `load_cookies_from_browsers` with additional exception handling, split HAR/JSON parsing into `_parse_har_file` and `_parse_json_cookie_file`, and enhanced `read_cookie_files` with optional filters and `.env` loading
- In `g4f/debug.py`, added enable/disable logging functions, updated log handler typing, appended messages to `logs` in `log()`, and improved `error()` formatting
- In `g4f/errors.py`, introduced base `G4FError` and updated all exception classes to inherit from it or relevant subclasses, with descriptive docstrings for each
- In `g4f/files.py`, added `max_length` parameter to `secure_filename`, adjusted regex formatting, and added docstring; updated `get_bucket_dir` to sanitize parts inline with docstring
- In `g4f/typing.py`, added `__future__.annotations`, reorganized imports, restricted PIL import to type-checking, defined `ContentPart` and `Message` TypedDicts, updated type aliases and `__all__` to include new types
- In `g4f/version.py`, added `lru_cache` and request timeout constant, applied caching to `get_pypi_version` and `get_github_version`, added response validation and explicit exceptions, refactored `VersionUtils.current_version` with clearer sources and error on miss, changed `check_version` to return a boolean with optional silent mode, and improved error handling outputs
2025-08-09 03:29:44 +02:00
hlohaus
b6dd7b39be Fix add user in Nvidia 2025-08-09 01:51:44 +02:00
hlohaus
f3923f8e50 feat: add new GPT-5 support and improve captcha handling
- **g4f/Provider/Copilot.py**
  - Added `"Smart (GPT-5)"` to `models` list.
  - Added `"gpt-5"` alias mapping to `"GPT-5"` in `model_aliases`.
  - Introduced `mode` selection logic to support `"smart"` mode for GPT-5 models alongside existing `"reasoning"` and `"chat"` modes.
- **g4f/Provider/EasyChat.py**
  - Added `get_models` class method to map `-free` models to aliases and store them in `cls.models`.
  - Resolved model via `cls.get_model(model)` at start of `create_async_generator`.
  - Reset `cls.captchaToken` to `None` at the beginning of `callback`.
  - Wrapped main generator logic in a loop to allow retry once if `CLEAR-CAPTCHA-TOKEN` error occurs, clearing auth file and resetting args.
- **g4f/Provider/needs_auth/OpenaiChat.py**
  - Added handling for image models: detect and set `image_model` flag, use `default_model` when sending requests if image model selected, and include `"picture_v2"` in `system_hints` when applicable.
  - Replaced textarea/button detection code in page load sequence with `nodriver` `select` calls, sending "Hello" before clicking send button, and included profile button selection if class needs auth.
- **g4f/Provider/openai/models.py**
  - Changed `default_image_model` from `"dall-e-3"` to `"gpt-image"`.
  - Added `"gpt-5"` and `"gpt-5-thinking"` to `text_models` list.
  - Added alias mapping for `"dall-e-3"` pointing to new `default_image_model`.
2025-08-09 01:33:56 +02:00
hlohaus
ba1f9bb3c3 Log requests 2025-08-08 11:44:58 +02:00
hlohaus
31fee02cce feat: add Qwen provider with conversation support and stream handling
- Added `Qwen` to `g4f/Provider/__init__.py` for provider registration
- Created new Qwen provider in `g4f/Provider/Qwen.py` using `AsyncGeneratorProvider`
- Implemented conversation state via new `JsonConversation` argument
- Replaced raw `print` statements with `debug.log` for internal logging
- Introduced `get_last_user_message()` for improved prompt extraction
- Added support for `Reasoning` and `Usage` response types during SSE parsing
- Replaced manual SSE parsing with `sse_stream()` utility from `requests`
- Added `active_by_default = True` to `Qwen` and modified related headers
- Tracked message and parent IDs for contextual threading
- Updated `Usage` class in `g4f/providers/response.py` to support `input_tokens` and `output_tokens`
- Refactored Nvidia provider: removed unused attributes and set `models_needs_auth = True
2025-08-08 10:56:48 +02:00
H Lohaus
95e2b697c0
Merge pull request #3119 from restartxx/feature/qwen-provider
feat: Add provider for chat.qwen.ai
2025-08-08 09:35:35 +02:00
lorriscript
608d0b140b
Feat/provider Nvidia (#3117)
* Nvidia provider + listing of all models categorized + working for Chat LLMs

---------

Co-authored-by: grubux <lehuedelorris@gmail.com>
2025-08-08 09:35:02 +02:00
hlohaus
8100b38dea Add models_needs_auth to Azure 2025-08-08 09:29:21 +02:00
hlohaus
da324565ad Test search 2025-08-08 07:21:57 +02:00
hlohaus
66bb4ce511 Test search 2025-08-08 07:19:23 +02:00
hlohaus
41716dadd2 Test search 2025-08-08 07:18:18 +02:00
Oppon
da40335033
feat: Add provider for chat.qwen.ai 2025-08-08 00:28:02 -03:00
hlohaus
c019c2c4b6 Fix model names 2025-08-08 04:01:56 +02:00
hlohaus
f93786fc6c Update model list 2025-08-08 02:45:17 +02:00
hlohaus
2aa40bb8a8 Fix unittests 2025-08-08 02:20:19 +02:00
hlohaus
5b65101a2a feat: add delays and input actions for captcha and auth flows
- Added `await asyncio.sleep(1)` inside captcha verification loop in `EasyChat.py` to introduce delay between checks
- Modified `Grok.py` to send "Hello" input to a selected textarea element during auth flow
- Added delay after sending keys to textarea in `Grok.py` using `await asyncio.sleep(1)`
- Added logic to select and click a submit button if present in `Grok.py` during header check loop
- All changes are within the `EasyChat` and `Grok` class definitions respectively
2025-08-08 01:46:15 +02:00
hlohaus
4164cb5978 Move on_request function 2025-08-08 01:37:10 +02:00
hlohaus
b9dfe1a460 feat: add EasyChat and GLM providers, update HuggingFace and SSE parsing
- Added new `EasyChat` provider (`g4f/Provider/EasyChat.py`) with captcha handling, nodriver callback, and token caching
- Added new `GLM` provider (`g4f/Provider/GLM.py`) with model retrieval, auth token fetch, and SSE streaming support
- Updated `g4f/Provider/__init__.py` to import `EasyChat` and `GLM`
- Modified `LMArenaBeta` in `g4f/Provider/needs_auth/LMArenaBeta.py` to remove nodriver availability check and always use `get_args_from_nodriver` with callback
- Updated `HuggingFaceAPI` in `g4f/Provider/needs_auth/hf/HuggingFaceAPI.py` to use `default_model` from `models` instead of `default_llama_model` and removed commented `max_inputs_lenght` param
- Updated `HuggingFace` in `g4f/Provider/needs_auth/hf/__init__.py` to import `default_model` instead of `default_vision_model`, set `default_model` class attribute, and commented out HuggingFaceInference and image model handling logic
- Modified `OpenaiTemplate` in `g4f/Provider/template/OpenaiTemplate.py` to prefer `"name"` over `"id"` when populating `vision_models`, `models`, and `models_count`
- Enhanced `sse_stream` in `g4f/requests/__init__.py` to strip and skip empty `data:` lines, handle JSON decode errors, and raise `ValueError` on invalid JSON
2025-08-08 01:19:32 +02:00
hlohaus
f8f8251cee Add model count for FenayAI 2025-08-07 06:34:59 +02:00
hlohaus
b4c3c30766 Fix auth with api_key 2025-08-07 04:39:10 +02:00
hlohaus
b3c1d1f3b1 Check api_key for models 2025-08-07 03:02:50 +02:00
hlohaus
9563f8df3a feat: Update environment variables and modify model mappings
- Added `OPENROUTER_API_KEY` and `AZURE_API_KEYS` to `example.env`.
- Updated `AZURE_DEFAULT_MODEL` to "model-router" in `example.env`.
- Added `AZURE_ROUTES` with multiple model URLs in `example.env`.
- Changed the mapping for `"phi-4-multimodal"` in `DeepInfraChat.py` to `"microsoft/Phi-4-multimodal-instruct"`.
- Added `media` parameter to `GptOss.create_completion` method and raised a `ValueError` if `media` is provided.
- Updated `model_aliases` in `any_model_map.py` to include new mappings for various models.
- Removed several model aliases from `PollinationsAI` in `any_model_map.py`.
- Added new models and updated existing models in `model_map` across various files, including `any_model_map.py` and `__init__.py`.
- Refactored `AnyModelProviderMixin` to include `model_aliases` and updated the logic for handling model aliases.
2025-08-07 01:21:22 +02:00
hlohaus
2c3a437c75 Add FenayAI provider 2025-08-06 22:33:01 +02:00
hlohaus
a62a1b6e71 Update models list 2025-08-06 20:54:32 +02:00
hlohaus
fe79b11070 Fix Azure image 2025-08-06 08:16:27 +02:00
hlohaus
05784da883 Fix PerplexityLabs 2025-08-06 08:06:54 +02:00