Commit Graph

20 Commits

Author SHA1 Message Date
hlohaus
e238ca3a58 refactor: update model mappings, error handling, and file utils
- Changed `generate_commit_message` return to `.strip("`").strip()` in `commit.py`
- Added new model mappings in `PollinationsAI.py`, including `gpt-4.1`, `gpt-4.1-mini`, and `deepseek-r1-distill-*`
- Removed `print` debug statement from `PollinationsAI.py` request payload
- Replaced temp file handling in `MarkItDown.py` with `get_tempfile` utility
- Added `get_tempfile` function to `files.py` for consistent tempfile creation
- Added `gpt-4.1` to `text_models` list in `models.py`
- Added `ModelNotSupportedError` to exception handling in `OpenaiChat.py`
- Updated message content creation to use `to_string()` in `OpenaiChat.py`
- Wrapped `get_model()` in try-except to ignore `ModelNotSupportedError` in `OpenaiChat.py`
- Adjusted `convert` endpoint in `api/__init__.py` to accept optional `provider` param
- Refactored `/api/markitdown` to reuse `convert()` handler in `api/__init__.py
2025-04-26 17:50:48 +02:00
hlohaus
8f63f656a2 feat: enhance HAR provider, image handling, markdown upload & cache
- **g4f/Provider/har/__init__.py**
  - `get_models`/`create_async`: iterate over `(domain, harFile)` and filter with `domain in request_url`
  - `read_har_files` now yields `(domain, har_data)`; fixes file variable shadowing and uses `json.load`
  - remove stray `print`, add type hint for `find_str`, replace manual loops with `yield from`
  - small whitespace clean-up

- **g4f/Provider/needs_auth/Grok.py**
  - `ImagePreview` now passes `auth_result.cookies` and `auth_result.headers`

- **g4f/Provider/needs_auth/OpenaiChat.py**
  - add `Union` import; rename/refactor `get_generated_images` → `get_generated_image`
  - support `file-service://` and `sediment://` pointers; choose correct download URL
  - return `ImagePreview` or `ImageResponse` accordingly and stream each image part
  - propagate 422 errors, update prompt assignment and image handling paths

- **g4f/client/__init__.py**
  - drop unused `ignore_working` parameter in sync/async `Completions`
  - normalise `media` argument: accept single tuple, infer filename when missing, fix index loop
  - `Images.create_variation` updated to use the new media logic

- **g4f/gui/server/api.py**
  - expose `latest_version_cached` via `?cache=` query parameter

- **g4f/gui/server/backend_api.py**
  - optional Markdown extraction via `MarkItDown`; save rendered text as `<file>.md`
  - upload flow rewrites: copy to temp file, move to bucket/media dir, clean temp, store filenames
  - introduce `has_markitdown` guard and improved logging/exception handling

- **g4f/tools/files.py**
  - remove trailing spaces in HAR code-block header string

- **g4f/version.py**
  - add `latest_version_cached` `@cached_property` for memoised version lookup
2025-04-24 15:18:21 +02:00
hlohaus
c083f85206 feat: improve file handling and streamline provider implementations
- Added file upload usage example with bucket_id in docs/file.md
- Fixed ARTA provider by refactoring error handling with a new raise_error function
- Simplified aspect_ratio handling in ARTA with proper default
- Improved AllenAI provider by cleaning up image handling logic
- Fixed Blackbox provider's media handling to properly process images
- Updated file tools to handle URL downloads correctly
- Fixed bucket_id pattern matching in ToolHandler.process_bucket_tool
- Cleaned up imports in typing.py by removing unnecessary sys import
- Fixed inconsistent function parameters in g4f/tools/files.py
- Fixed return value of upload_and_process function to return bucket_id
2025-04-08 19:00:44 +02:00
hlohaus
6c8387f045 Update handle media uploads 2025-03-30 00:04:13 +01:00
hlohaus
fa17ce1bd6 Delete buckets with the conversation
Fix lightbox for uploaded images
Fix save media content
Fix TypeGPT and Cloudflare provider
2025-03-29 11:22:22 +01:00
hlohaus
46d0b87008 Add example for video generation
Add support for images in messages
2025-03-27 09:38:31 +01:00
hlohaus
3c546897ec Fix missing bucket cache file 2025-03-25 12:39:03 +01:00
hlohaus
e76e5f7835 Use dynamtic aspect_ratio for image and video size 2025-03-23 14:47:26 +01:00
hlohaus
6314d27dc4 Fix url download function 2025-02-22 14:20:54 +01:00
hlohaus
ba60296677 Fix unittest, update model lists 2025-02-22 13:19:52 +01:00
hlohaus
796d6d6e14 Fix errors on read buckets
Update requirements for docx
2025-02-19 17:10:03 +01:00
hlohaus
5676752ca4 Fix copy_images, Add support .arc files 2025-02-12 16:30:24 +01:00
hlohaus
9994bb67a1 Add zerogpu_uuid to demo 2025-02-05 17:07:20 +01:00
hlohaus
efacc15d92 Support options like max_depth in downloads.json
Add created buckets automatic to messages
Don't add images to scrape result without title
2025-01-28 22:33:49 +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
2360cc3330 Fix issue with old conversations 2025-01-07 00:26:01 +01:00
Heiner Lohaus
2e531d227c Fix invalid escape in requests module
Add none auth with OpenAI using nodriver
Fix missing 1 required positional argument: 'cls'
Update count tokens in GUI
Fix streaming example in requests guide
Remove ChatGptEs as default model
2025-01-06 23:20:29 +01:00
Heiner Lohaus
12c413fd2e Add Edge as Browser for nodriver
Fix for RetryProviders doesn't retry
Add retry and continue for DuckDuckGo provider
Add cache for Cloudflare provider
Add cache for prompts on gui home
Add scroll to bottom checkbox in gui
Improve prompts on home gui
Fix response content type in api for files
2025-01-05 17:02:15 +01:00
Heiner Lohaus
0d59789eed Add File API Documentation for Python and JS
Format Bucket Placeholder in GUI
2025-01-01 14:01:33 +01:00
Heiner Lohaus
7893a0835e Add filessupport, scrape and refine your data
Remove Webdriver usages
Add continue messages for other providers
2025-01-01 04:20:02 +01:00