193 Commits

Author SHA1 Message Date
H Lohaus 2e7a021097 Update __main__.py 2026-04-21 22:42:29 +02:00
hlohaus cc0ad7a9f8 Refactor provider method handling for improved clarity and consistency; update mocks and add SKILL.md for usage guidance 2026-04-17 14:07:49 +02:00
copilot-swe-agent[bot] f79edb397d Use request.url.netloc (ASGI scope) instead of Host header for CSP origin
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/d964c73c-85bc-432d-b14b-20f8ea2de94e

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:39:58 +00:00
copilot-swe-agent[bot] dafc1d9341 Serve /pa/files HTML with CSP sandbox+request origin for true localStorage isolation
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/d964c73c-85bc-432d-b14b-20f8ea2de94e

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:38:12 +00:00
copilot-swe-agent[bot] 63e6ddfd7e Tighten CSP (connect-src/object-src none), add Permissions-Policy, document localStorage same-origin behavior
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/bf9b023a-6921-41be-b964-7b245db2fb4f

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:30:03 +00:00
copilot-swe-agent[bot] 4e55c65474 Address review: rename _get_safe_types, clarify .py/.env whitelist exclusion tests
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/b7cbc71b-2455-4cd2-be09-f5516e4a08ee

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:16:38 +00:00
copilot-swe-agent[bot] 6ff49cb2c1 Add /pa/files/* workspace file serving route (HTML/CSS/JS/images), fix orphaned responses dict syntax bug
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/b7cbc71b-2455-4cd2-be09-f5516e4a08ee

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:14:53 +00:00
copilot-swe-agent[bot] dd9230ef4e Add PaProviderRegistry, /pa/* API routes (providers list, chat/completions, backend-api/v2/conversation)
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/e0daf662-ee35-43ac-bdef-27dd570bc00d

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 19:03:48 +00:00
copilot-swe-agent[bot] d2f2af886c Address review: add input validation for timeout/max_depth, clarify test comment
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/41556926-6205-4207-b36b-e10e22a8b87e

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 17:46:18 +00:00
copilot-swe-agent[bot] 5616349135 Harden sandbox security: execution timeout, max recursion depth, output size cap
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/41556926-6205-4207-b36b-e10e22a8b87e

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 17:43:33 +00:00
copilot-swe-agent[bot] 00b2b70a94 Add --safe mode to MCP server: lock module allowlist and block workspace root listing
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/d29e72a3-7dc7-4d2d-897d-3dfb79ba6382

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 17:24:20 +00:00
copilot-swe-agent[bot] 0501738d76 Address code review: improve type hints, security docs, FileListTool skipped count, dynamic _TOOL_COUNT
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/1b3f481e-143f-4c30-9982-1063c0338ec3

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 16:22:19 +00:00
copilot-swe-agent[bot] a5b4675d66 Add .pa.py safe executor, workspace file tools, and MCP server integration
Agent-Logs-Url: https://github.com/xtekky/gpt4free/sessions/1b3f481e-143f-4c30-9982-1063c0338ec3

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-04-04 16:19:37 +00:00
hlohaus a1cdfe3f97 fix: Remove LMArena from best provider list for flux-kontext model 2026-04-04 01:36:43 +02:00
hlohaus c2cb04eee5 fix(read_text): improve regex to capture text block endings 2026-04-01 22:59:01 +02:00
hlohaus e6b5e4adfc feat: Support hyphenated keys in evaluate_condition and update user quota structure 2026-03-31 15:26:28 +02:00
hlohaus 7bee687024 fix: Update socket import path in safety URL tests 2026-03-21 21:56:28 +01:00
hlohaus 7448194cac feat: Add YAML import check and skip tests if not available 2026-03-21 21:46:32 +01:00
hlohaus b6a6db2c2e feat: Enhance URL safety checks and integrate is_safe_url across image handling #3397 2026-03-21 21:38:38 +01:00
hlohaus 7a4bf072de fix: Update image references and enhance cookie acceptance handling in Yupp and LMArena providers 2026-03-20 17:01:09 +01:00
H Lohaus d20b992876 Merge pull request #3394 from xtekky/copilot/add-config-yaml-custom-routing
Add config.yaml custom model routing with quota-aware provider selection
2026-03-20 10:49:02 +01:00
copilot-swe-agent[bot] 8fd8cd5c80 Fix evaluate_condition to support provider-specific quota dict formats
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-03-19 15:28:00 +00:00
copilot-swe-agent[bot] 5ff28514cd Add config.yaml custom model routing support
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2026-03-19 14:28:41 +00:00
PR Bot d93dbf45d5 feat: upgrade MiniMax default model to M2.7
- Add MiniMax-M2.7 and MiniMax-M2.7-highspeed to model list
- Set MiniMax-M2.7 as default model
- Keep all previous models as alternatives
- Add model routing entries in any_model_map
- Add unit tests for MiniMax provider
2026-03-18 17:21:01 +08:00
haosenwang1018 4ac78c9ef5 fix: replace bare except clauses with except Exception
Bare `except:` catches BaseException including KeyboardInterrupt and
SystemExit. Replaced 34 instances with `except Exception:`.
2026-02-25 11:49:12 +00:00
hlohaus 02de2704c7 Add support for custom cookies directory in CLI arguments and update run_api_args to handle it 2026-02-24 13:30:11 +01:00
H Lohaus 21380803a5 Update copilot.py 2026-02-21 12:55:12 +01:00
hlohaus a9395404ff feat: implement quota retrieval for providers and update related methods 2026-02-20 20:58:09 +01:00
Marcos Vinícius Claudiano 405868c576 feat: add tool_call emulation for OpenAI API (#3352)
* feat: add tool_call emulation for OpenAI API

Avoid forcing PollinationsAI when tools are present, and add an opt-in tool_emulation mode (or G4F_TOOL_EMULATION=1) to emit OpenAI-compatible tool_calls for providers that ignore tools.

* fix: avoid duplicate stream kwarg in tool emulation

Tool emulation calls the upstream provider with stream=False; remove stream/stream_timeout from forwarded kwargs to prevent conflicts.

* fix: prefer non-auth providers when api_key missing

When routing via AnyProvider without an api_key, try providers with needs_auth=false first to reduce MissingAuthError for tool-enabled clients like MarksCode.

* test: cover tool call emulation

Route tool_emulation through ToolSupportProvider (avoid circular imports) and add unittest coverage for multi-tool JSON plans and run_tools integration.
2026-02-09 12:01:52 +01:00
hlohaus e1b7471f9f fix: Update references from 'nest_asyncio' to 'nest-asyncio2' across the codebase 2026-01-27 11:29:43 +01:00
hlohaus 6052775fdf Refactor API base URL references across providers
- Changed `api_base` to `base_url` in multiple provider files for consistency.
- Updated method signatures and internal references to use `base_url` instead of `api_base`.
- Adjusted the `OpenaiTemplate` class to accommodate the new `base_url` parameter.
- Enhanced the `ClientFactory` to support custom provider creation with `base_url`.
- Modified API request handling in the backend to align with the new naming convention.
2025-12-25 22:09:20 +01:00
H Lohaus 9535512efe Merge pull request #3286 from michaelbrinkworth/add-ai-badger
add AI Badgr as a OpenAI-compatible backend
2025-12-12 14:50:52 +01:00
copilot-swe-agent[bot] 2e83084718 Remove deprecated and not_working providers
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-12-11 17:42:31 +00:00
michael m 8516f167ea feat: add AI Badgr as OpenAI-compatible provider
- Add AIBadgr provider class extending OpenaiTemplate
- API endpoint: https://aibadgr.com/api/v1
- Full support for streaming, system messages, and message history
- Add example usage script in etc/examples/aibadgr.py
- Provider requires API key authentication
2025-12-11 08:26:45 +10:00
hlohaus af56ac0c03 Enhance MCP server tests to reflect updated tool count; improve model fetching with timeout handling in providers 2025-11-02 08:01:20 +01:00
copilot-swe-agent[bot] a15618a80e Add HTTP transport mode for MCP server with --http flag
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-11-01 05:25:49 +00:00
copilot-swe-agent[bot] 1e895fbb6a Add comprehensive MCP documentation and examples
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-11-01 05:13:47 +00:00
copilot-swe-agent[bot] 0c2a2b00c3 Add MCP server tests, documentation, and README updates
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-11-01 05:10:49 +00:00
copilot-swe-agent[bot] e1214e4372 Add MCP server implementation with web search, scraping, and image generation tools
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-11-01 05:06:46 +00:00
H Lohaus 8366a2956a Update backend.py 2025-10-04 19:30:32 +02:00
H Lohaus f17056ff71 Update backend.py 2025-10-04 19:29:09 +02:00
hlohaus 242c8281fd Enhance template.html with improved structure and styling; add table of contents, translation button, and accessibility features. 2025-10-04 15:15:23 +02:00
hlohaus 2dfa807cfb Refactor provider type determination to use 'chat' for non-image models and update download URL configuration 2025-09-04 12:07:42 +02:00
Copilot 43898f081a Standardize reasoning field to OpenAI format while maintaining input compatibility (#3136)
* Initial plan

* Add comprehensive reasoning field standardization tests

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

* Standardize reasoning field to OpenAI format while maintaining input compatibility

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

* Rename reasoning_content parameter to reasoning for consistent naming

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

* Address review comments: remove hardcoded path and rename reasoning_content to reasoning

Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
2025-08-21 16:06:36 +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 2aa40bb8a8 Fix unittests 2025-08-08 02:20:19 +02:00
hlohaus 499dcc0154 refactor: replace see_stream with sse_stream and update md2html output logic
- Replaced all imports and usages of `see_stream` with `sse_stream` across:
  - `g4f/Provider/Kimi.py`
  - `g4f/Provider/hf_space/BlackForestLabs_Flux1KontextDev.py`
  - `g4f/Provider/needs_auth/PuterJS.py`
  - `g4f/Provider/template/OpenaiTemplate.py`
  - `g4f/requests/__init__.py` (renamed function `see_stream` to `sse_stream`)
- Modified `g4f/Provider/needs_auth/GeminiPro.py`:
  - Updated `default_model` from `gemini-2.5-flash-preview-04-17` to `gemini-2.5-flash`
  - Removed `gemini-2.5-flash-preview-04-17` from `fallback_models`
- Updated `etc/tool/md2html.py`:
  - Added `re` import
  - Changed `process_single_file_with_output` to check if output file exists
  - If exists, uses regex to update `<title>` and `itemprop="text">` content instead of writing full template
  - If not, generates HTML using the template as before
2025-07-29 19:57:13 +02:00
hlohaus 44c7e7735a Fix uittests 2025-07-13 13:16:02 +02:00
H Lohaus afe62c308e Update copilot.py 2025-07-11 09:27:46 +02:00
kqlio67 7965487830 feat: add new providers and update models (#3075)
* 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>
2025-07-11 03:50:59 +02:00