XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

feat: add OllamaSwarm provider, fofa scraper, update OperaAria, and fix Gemini images

This PR introduces a brand new provider, a tool for discovering open Ollama instances, massive updates to OperaAria, and several critical media/image fixes. 1. New Provider: OllamaSwarm * Added OllamaSwarm provider (g4f/Provider/OllamaSwarm.py), which acts as an intelligent rotator/balancer across multiple public, free Ollama servers. * Automatically handles routing requests to available nodes and gracefully skipping dead ones. * Added corresponding model definitions in g4f/models.py and registered the provider in __init__.py. 2. FOFA Ollama Parser (etc/tool/fofa_ollama_parser.py) * Created a highly effective scraper tool to automatically discover open Ollama instances via the FOFA search engine. * Uses standard web scraping with a free fofa_token cookie, eliminating the need for paid API credits. * Can automatically update the cached servers list directly into OllamaSwarm.py. 3. OperaAria Improvements * Heavily refactored and updated the OperaAria.py provider to improve stability, handle authentication better, and match recent API changes from Opera. 4. Gemini Image Fixes (Gemini.py) * Image parsing fix: Gemini recently stopped wrapping images in [Imagen of ...] tags. Changed the image extraction logic to reliably pull directly from the JSON metadata array (response_part[4][0][12][7][0]). * High-Res Images: Appended =s2048 to Gemini's gg-dl image URLs, forcing Google to return the original 1408x768 resolution instead of downscaled 512x279 thumbnails. 5. Image & Media Utilities (g4f/image/__init__.py & copy_images.py) * Crash fix: Fixed an issue where .seek(0) was incorrectly called on PIL.Image.Image instead of BytesIO during byte conversion. * Format detection: Improved detect_file_type to accurately distinguish between Ogg audio vs video, and EBML formats (WebM vs MKV). * Aspect ratios: Expanded ratio_map to support many more aspect ratios (21:9, 5:4, 3:2, etc.). * Transparency: process_image now properly retains PNG transparency. * Robust URI parsing: Fixed potential AttributeError when response.method is missing in copy_images.py.

8a90cfeb
kqlio67 <kqlio67@users.noreply.github.com>
提交于

代码差异

10 个文件 +1658 -459
Added g4f/Provider/OllamaSwarm.py +404 -0
Modified g4f/Provider/__init__.py +1 -0
Modified g4f/Provider/needs_auth/Gemini.py +34 -16
Modified g4f/gui/server/website.py +7 -3
Modified g4f/image/__init__.py +127 -180
Modified g4f/image/copy_images.py +81 -48
Modified g4f/models.py +21 -0
Modified g4f/tools/media.py +6 -3