Commit Graph

43 Commits

Author SHA1 Message Date
hlohaus
0804d6836a Comment out JSDELIVR_URL replacement in render function to prevent URL rewriting 2025-09-11 22:59:04 +02:00
hlohaus
d7375d4c6c Add Claude provider with authentication handling and update Nvidia provider 2025-09-11 20:55:31 +02:00
hlohaus
0f8853d9f3 Fix latest_version handling in render function to correctly append query string 2025-09-07 02:54:09 +02:00
hlohaus
99e647a016 Update render function to use GITHUB_URL for download URL handling 2025-09-07 02:44:05 +02:00
hlohaus
3852fda31d Refactor render function to simplify download URL handling by removing version query parameter 2025-09-07 02:42:06 +02:00
hlohaus
130a429500 Update download URL in website.py to use GITHUB_URL for improved version handling 2025-09-07 02:27:29 +02:00
hlohaus
9b4727b2f1 Update render function to use latest_version for download URL and cache handling 2025-09-07 01:57:38 +02:00
hlohaus
bc77a9226e Update render function to include version in download URL and improve cache handling 2025-09-07 01:39:12 +02:00
hlohaus
ffae27b3cf Refactor render function in website.py to improve HTML handling and caching logic 2025-09-07 01:02:35 +02:00
hlohaus
2030bdd62a Fix JSDELIVR_URL replacement in render function to ensure correct path formatting 2025-09-05 04:08:46 +02:00
hlohaus
7c5ec5325a Update EasyChat and OpenRouter classes, modify backend API timing, and enhance website rendering 2025-09-04 02:42:04 +02:00
hlohaus
bdc356c4c2 refactor: replace constants module with config module
- 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.
2025-07-09 23:21:03 +02:00
hlohaus
6c126e468c feat: update providers, model selection, media handling, and routing
- 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
2025-07-09 19:36:58 +02:00
hlohaus
e18297f358 Update PuterJS 2025-06-14 20:42:29 +02:00
hlohaus
986c48bf49 Use tempfile if cookies dir is not writeable 2025-06-14 12:37:34 +02:00
hlohaus
4d3d717dc2 Use tempfile if cookies dir is not writeable 2025-06-14 12:31:12 +02:00
hlohaus
1b5942c51f Use tempfile if cookies dir is not writeable 2025-06-14 12:29:49 +02:00
hlohaus
ae5d7a193a Update website.py 2025-06-14 00:13:19 +02:00
hlohaus
c3aca8964c refactor: adjust model check, tool calls, and response handling logic
- Updated `thinking_enabled` condition in `DeepSeekAPI.py` to ensure `model` is not None before checking substring
- Removed default `tool_calls` value in `/backend-api/v2/create` route in `backend_api.py`
- Simplified response caching logic by consolidating `cast_str` handling and ensuring `response` is a string before writing
- Adjusted response filtering logic to handle string vs iterable cases more consistently
- Refined safe search tag check in file matching loop to only test the first tag against MIME type in `backend_api.py`
- Changed default filename from "index" to "home" in `_index` method of `website.py
2025-05-21 15:05:43 +02:00
hlohaus
9461949542 feat: improve media handling, file conversion, and error management
- Added UUID-based "x-xai-request-id" header and 403 error handling in Grok.py
- Updated backend_api.py to handle empty media results and unsupported file types with error raising and file cleanup
- Simplified render logic in website.py by removing is_live flag and related code
- Changed "audio/wav" MIME type to "audio/x-wav" in image/__init__.py
- Added is_valid_media and is_valid_audio functions to image/__init__.py for stricter media validation
- Enhanced MarkItDown integration in markitdown/__init__.py with convert_stream method supporting non-seekable streams
- Modified _transcribe_audio.py to use recognize_faster_whisper if available, fallback to recognize_google
- Updated providers/helper.py to prioritize "text" key in to_string function
- Improved stream_read_files in files.py to skip DOWNLOADS_FILE and adjust code block formatting
- Added get_filename_from_url utility in files.py for consistent filename generation from URLs
- Enhanced download_urls in files.py to use MarkItDown for URL conversion and improved error logging
- Improved render_part and related functions in media.py to use new media validation logic and handle more cases
- Adjusted merge_media and render_messages in media.py for stricter part filtering and validation
2025-05-20 22:40:12 +02:00
hlohaus
57cbd55d74 feat: integrate Pollinations AI enhancements and simplify gpt4free references
- Replaced the large GitHub project stats table in `README.md` with summaries and logos for Pollinations AI and MoneyPrinter V2
- Introduced `STATIC_URL` and `DIST_DIR` constants in new `g4f/constants.py` and used them across multiple files
- Updated `PollinationsAI.py` to support conversation title and follow-up generation using tool calls
- Modified `PollinationsAI.py` and `PollinationsImage.py` to use `STATIC_URL` for the `referrer` header
- Enhanced `PollinationsAI.stream_complete` to yield `ToolCalls`, `TitleGeneration`, and `SuggestedFollowups`
- Added `ToolCalls` handling in `client/__init__.py` to support non-stream and stream modes
- Updated `ChatCompletionDelta` model in `client/stubs.py` to support `ToolCalls`
- Modified `HarProvider` to merge `DEFAULT_HEADERS` into request headers
- Improved `OpenaiChat.py` by adding optional chaining to page evaluation expressions for robustness
- Updated `any_provider.py` to force use of `PollinationsAI` if `tools` key is present in kwargs
- Refactored `is_content` into a reusable function in `providers/response.py` and used in `retry_provider.py`
- Updated `gui/server/website.py` to use `STATIC_URL` and simplify `GPT4FREE_URL` handling
- Removed redundant constants from `version.py` and imported them from `constants.py
2025-05-18 01:54:09 +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
hlohaus
8c3764dfeb feat: enhance audio model handling and improve image URL resolution
- Updated `PollinationsAI` to exclude "gemini" model from `audio_models`
- Added logic in `PollinationsAI` to expand `audio_models` with voices from `default_audio_model`
- Appended voice names to `text_models` list in `PollinationsAI` if present in `default_audio_model`
- Modified `PollinationsAI._generate_text` to inject `audio` parameters when a voice model is used
- Updated `save_response_media` call to include voice name in model list
- Changed `OpenaiChat.get_generated_image` to support both `file-service://` and `sediment://` URLs using `conversation_id`
- Modified `OpenaiChat.create_messages` to optionally pass `prompt`
- Adjusted `OpenaiChat.run` to determine `prompt` explicitly and set messages accordingly
- Updated `OpenaiChat.iter_messages_line` to handle `None` in `fields.p` safely
- Passed `prompt` and `conversation_id` to `OpenaiChat.get_generated_image` inside image parsing loop
- Fixed redirect logic in `backend_api.py` to safely handle missing `skip` query param
- Enhanced `render` function in `website.py` to support live file serving with `live` query param
- Added new route `/dist/<path:name>` to serve static files from `DIST_DIR` in `website.py`
- Adjusted `render` to include `.live` suffix in cache filename when applicable
- Modified HTML replacements in `render` to preserve local `dist/` path if `add_origion` is True
2025-04-21 08:43:32 +02:00
hlohaus
236d2aa114 Remove client files from main package 2025-04-20 20:44:10 +02:00
hlohaus
d38755b42a Code review changes 2025-03-30 17:57:42 +02:00
hlohaus
a1871dafeb Improve background page
Improve share js functions
Fix photoswipe in UI
Support n parameter in PollinationsAI
2025-03-26 21:39:19 +01:00
hlohaus
13810b8ae0 Use loading icon 2025-03-25 11:55:29 +01:00
hlohaus
142e4876ae Add background page 2025-03-25 04:32:11 +01:00
hlohaus
ae1fae7ef0 Add chat share function 2025-03-25 01:46:57 +01:00
hlohaus
5cbbe2fd3d Fix model and provider in chat completion response
Add login button to HuggingFace demo
Custom conversation ids in chat ui
Remove rate limiter in demo mode
Improve YouTube support in Gemini
2025-02-24 08:53:43 +01:00
hlohaus
31a4812d7a Improve copy_images api
Update share target support
Improve search enabled hightlight
2025-02-05 22:11:19 +01:00
hlohaus
19bf5b7ef6 Fix upload files in demo mode
Updates for memory with mem0
Fix asyncio import in nodriver function
Add provider specific api endpoints
Support for open settings in UI at /chat/settings
2025-01-26 21:56:31 +01:00
hlohaus
595dafd71a Fix some issues in the demo 2025-01-26 17:44:04 +01:00
hlohaus
ab04d1d894 Increase max token in HuggingfaceAPI
Restore browser instance on start up errors in nodriver
Restored instances can be used as usual or to stop the browser
Add demo modus to web ui for HuggingSpace
Add rate limit support to web ui. Simply install flask_limiter
Add home for demo with Access Token input and validation
Add stripped model list for demo
Add ignores for encoding error in web_search and file upload
2025-01-26 02:48:43 +01:00
Heiner Lohaus
486e9a9122 Add login_url to authed providers
Create a home page for the GUI
Fix CopyButton in Code Highlight
2025-01-03 02:40:21 +01:00
Heiner Lohaus
651df0cf82 Add some arguments to chat completion api, update discord links 2024-11-27 14:44:24 +01:00
H Lohaus
804a80bc7c Arm2 (#2414)
* Fix arm v7 build / improve api

* Update stubs.py

* Fix unit tests
2024-11-24 17:43:45 +01:00
kqlio67
078edc6f61 feat(g4f/gui/server/website.py): add redirect for /images/ endpoint 2024-10-25 20:07:24 +03:00
Heiner Lohaus
926ddfd543 Add WhiteRabbitNeo Provider, Many tiny improvments in the gui 2024-04-08 07:24:00 +02:00
Heiner Lohaus
905ced06bd Serverless webview gui 2024-03-16 10:48:37 +01:00
Heiner Lohaus
8cc6000ffb Add Pyinstaller support, Use curl_cffi in You provider 2024-03-15 11:46:06 +01:00
ⲘrṨhส∂ow
3982f39424 'Refactored by Sourcery' (#1125)
Co-authored-by: Sourcery AI <>
2023-10-23 09:46:25 +02:00
abc
7e4e374f62 ~ | new g4f GUI 2023-10-06 19:52:17 +01:00