Commit Graph

8 Commits

Author SHA1 Message Date
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
hlohaus 06df47f279 Refactor provider methods to unify async and sync handling, enhance clarity, and improve error management 2026-04-16 02:38:03 +02: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 2befef988b feat: refactor provider create functions to class attributes and update calls
- Added `create_function` and `async_create_function` class attributes with default implementations in `base_provider.py` for `AbstractProvider`, `AsyncProvider`, and `AsyncGeneratorProvider`
- Updated `get_create_function` and `get_async_create_function` methods to return these class attributes
- Replaced calls to `provider.get_create_function()` and `provider.get_async_create_function()` with direct attribute access `provider.create_function` and `provider.async_create_function` across `g4f/__init__.py`, `g4f/client/__init__.py`, `g4f/providers/retry_provider.py`, and `g4f/tools/run_tools.py`
- Removed redundant `get_create_function` and `get_async_create_function` methods from `providers/base_provider.py` and `providers/types.py`
- Ensured all provider response calls now use the class attributes for creating completions asynchronously and synchronously as needed
2025-06-12 12:45:55 +02:00
hlohaus c97ba0c88e Add audio transcribing example and support
Add Grok Chat provider
Rename images parameter to media
Update demo homepage
2025-03-21 03:17:45 +01:00
hlohaus 3e7af90949 Add ARTA image provider
Add ToolSupport in PollinationsAI provider
Add default value for model in chat completions
Add Streaming Support for PollinationsAI provider
2025-03-11 02:49:24 +01:00
hlohaus d11aabcd56 Add ToolSupportProvider 2025-03-01 09:38:57 +01:00
hlohaus 989f02fc31 Add ToolSupportProvider 2025-03-01 01:46:04 +01:00