mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-09-26 20:31:14 +08:00
Add more contributers, add link to Swagger UI (#2443)
* Add more contributers, add link to Swagger UI * Update Dockerfile-slim * Update retry_provider.py * Add html preview to gui, fix urls in website manifest * Missing chunks in OpenaiChat
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
### Please, follow these steps to contribute:
|
||||
1. Reverse a website from this list: [sites-to-reverse](https://github.com/xtekky/gpt4free/issues/40)
|
||||
2. Add it to [./testing](https://github.com/xtekky/gpt4free/tree/main/testing)
|
||||
2. Add it to [./etc/unittest/](https://github.com/xtekky/gpt4free/tree/main/etc/unittest/)
|
||||
3. Refactor it and add it to [./g4f](https://github.com/xtekky/gpt4free/tree/main/g4f)
|
||||
|
||||
### We will be grateful to see you as a contributor!
|
100
README.md
100
README.md
@@ -163,6 +163,7 @@ How do I load the project using git and installing the project requirements?
|
||||
Read this tutorial and follow it step by step: [/docs/git](docs/git.md)
|
||||
|
||||
##### Install using Docker:
|
||||
|
||||
How do I build and run composer image from source?
|
||||
Use docker-compose: [/docs/docker](docs/docker.md)
|
||||
|
||||
@@ -212,7 +213,9 @@ print(f"Generated image URL: {image_url}")
|
||||
- **Legacy API with python modules:** [/docs/legacy](docs/legacy.md)
|
||||
|
||||
#### Web UI
|
||||
|
||||
**To start the web interface, type the following codes in python:**
|
||||
|
||||
```python
|
||||
from g4f.gui import run_gui
|
||||
|
||||
@@ -223,10 +226,15 @@ or execute the following command:
|
||||
python -m g4f.cli gui -port 8080 -debug
|
||||
```
|
||||
|
||||
#### Interference API
|
||||
You can use the Interference API to serve other OpenAI integrations with G4F.
|
||||
**See docs:** [/docs/interference](docs/interference-api.md)
|
||||
**Access with:** http://localhost:1337/v1
|
||||
### Interference API
|
||||
|
||||
The **Interference API** enables seamless integration with OpenAI's services through G4F, allowing you to deploy efficient AI solutions.
|
||||
|
||||
- **Documentation**: [Interference API Docs](docs/interference-api.md)
|
||||
- **Endpoint**: `http://localhost:1337/v1`
|
||||
- **Swagger UI**: Explore the OpenAPI documentation via Swagger UI at `http://localhost:1337/docs`
|
||||
|
||||
This API is designed for straightforward implementation and enhanced compatibility with other OpenAI integrations.
|
||||
|
||||
### Configuration
|
||||
|
||||
@@ -252,7 +260,7 @@ set_cookies(".google.com", {
|
||||
|
||||
#### Using .har and Cookie Files
|
||||
|
||||
You can place `.har` and cookie files in the default `./har_and_cookies` directory. To export a cookie file, use the [EditThisCookie Extension](https://chromewebstore.google.com/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg) available on the Chrome Web Store.
|
||||
You can place `.har` and cookie files `.json` in the default `./har_and_cookies` directory. To export a cookie file, use the [EditThisCookie Extension](https://chromewebstore.google.com/detail/editthiscookie/fngmhnnpilhplaeedifhccceomclgfbg) available on the Chrome Web Store.
|
||||
|
||||
#### Creating .har Files to Capture Cookies
|
||||
|
||||
@@ -790,12 +798,14 @@ A list of all contributors is available [here](https://github.com/xtekky/gpt4fre
|
||||
|
||||
<a href="https://github.com/xtekky" target="_blank"><img src="https://avatars.githubusercontent.com/u/98614666?v=4&s=45" width="45" title="xtekky"></a>
|
||||
<a href="https://github.com/hlohaus" target="_blank"><img src="https://avatars.githubusercontent.com/u/983577?v=4&s=45" width="45" title="hlohaus"></a>
|
||||
<a href="https://github.com/kqlio67" target="_blank"><img src="https://avatars.githubusercontent.com/u/166700875?v=4&s=45" width="45" title="kqlio67"></a>
|
||||
<a href="https://github.com/bagusindrayana" target="_blank"><img src="https://avatars.githubusercontent.com/u/36830534?v=4&s=45" width="45" title="bagusindrayana"></a>
|
||||
<a href="https://github.com/sudouser777" target="_blank"><img src="https://avatars.githubusercontent.com/u/22415463?v=4&s=45" width="45" title="sudouser777"></a>
|
||||
<a href="https://github.com/thatlukinhasguy1" target="_blank"><img src="https://avatars.githubusercontent.com/u/139662282?v=4&s=45" width="45" title="thatlukinhasguy1"></a>
|
||||
<a href="https://github.com/Commenter123321" target="_blank"><img src="https://avatars.githubusercontent.com/u/36051603?v=4&s=45" width="45" title="Commenter123321"></a>
|
||||
<a href="https://github.com/DanielShemesh" target="_blank"><img src="https://avatars.githubusercontent.com/u/20585236?v=4&s=45" width="45" title="DanielShemesh"></a>
|
||||
<a href="https://github.com/Luneye" target="_blank"><img src="https://avatars.githubusercontent.com/u/73485421?v=4&s=45" width="45" title="Luneye"></a>
|
||||
<a href="https://github.com/foxfire52" target="_blank"><img src="https://avatars.githubusercontent.com/u/185073927?v=4&s=45" width="45" title="foxfire52"></a>
|
||||
<a href="https://github.com/ezerinz" target="_blank"><img src="https://avatars.githubusercontent.com/u/100193740?v=4&s=45" width="45" title="ezerinz"></a>
|
||||
<a href="https://github.com/enganese" target="_blank"><img src="https://avatars.githubusercontent.com/u/69082498?v=4&s=45" width="45" title="enganese"></a>
|
||||
<a href="https://github.com/Lin-jun-xiang" target="_blank"><img src="https://avatars.githubusercontent.com/u/63782903?v=4&s=45" width="45" title="Lin-jun-xiang"></a>
|
||||
@@ -805,19 +815,87 @@ A list of all contributors is available [here](https://github.com/xtekky/gpt4fre
|
||||
<a href="https://github.com/repollo" target="_blank"><img src="https://avatars.githubusercontent.com/u/2671466?v=4&s=45" width="45" title="repollo"></a>
|
||||
<a href="https://github.com/hpsj" target="_blank"><img src="https://avatars.githubusercontent.com/u/54535414?v=4&s=45" width="45" title="hpsj"></a>
|
||||
<a href="https://github.com/taiyi747" target="_blank"><img src="https://avatars.githubusercontent.com/u/63543716?v=4&s=45" width="45" title="taiyi747"></a>
|
||||
<a href="https://github.com/9fo" target="_blank"><img src="https://avatars.githubusercontent.com/u/71867245?v=4&s=45" width="45" title="9fo"></a>
|
||||
<a href="https://github.com/HexyeDEV" target="_blank"><img src="https://avatars.githubusercontent.com/u/65314629?v=4&s=45" width="45" title="HexyeDEV"></a>
|
||||
<a href="https://github.com/WdR-Tech" target="_blank"><img src="https://avatars.githubusercontent.com/u/143020293?v=4&s=45" width="45" title="WdR-Tech"></a>
|
||||
<a href="https://github.com/zukixa" target="_blank"><img src="https://avatars.githubusercontent.com/u/56563509?v=4&s=45" width="45" title="zukixa"></a>
|
||||
<a href="https://github.com/ostix360" target="_blank"><img src="https://avatars.githubusercontent.com/u/55257054?v=4&s=45" width="45" title="ostix360"></a>
|
||||
<a href="https://github.com/WdR-Tech" target="_blank"><img src="https://avatars.githubusercontent.com/u/143020293?v=4&s=45" width="45" title="WdR-Tech"></a>
|
||||
<a href="https://github.com/HexyeDEV" target="_blank"><img src="https://avatars.githubusercontent.com/u/65314629?v=4&s=45" width="45" title="HexyeDEV"></a>
|
||||
<a href="https://github.com/9fo" target="_blank"><img src="https://avatars.githubusercontent.com/u/71867245?v=4&s=45" width="45" title="9fo"></a>
|
||||
<a href="https://github.com/devAdityaa" target="_blank"><img src="https://avatars.githubusercontent.com/u/77636021?v=4&s=45" width="45" title="devAdityaa"></a>
|
||||
<a href="https://github.com/editor-syntax" target="_blank"><img src="https://avatars.githubusercontent.com/u/109844019?v=4&s=45" width="45" title="editor-syntax"></a>
|
||||
<a href="https://github.com/24rr" target="_blank"><img src="https://avatars.githubusercontent.com/u/109844019?v=4&s=45" width="45" title="24rr"></a>
|
||||
<a href="https://github.com/zeng-rr" target="_blank"><img src="https://avatars.githubusercontent.com/u/47846202?v=4&s=45" width="45" title="zeng-rr"></a>
|
||||
<a href="https://github.com/rkihacker" target="_blank"><img src="https://avatars.githubusercontent.com/u/182319878?v=4&s=45" width="45" title="rkihacker"></a>
|
||||
<a href="https://github.com/naa7" target="_blank"><img src="https://avatars.githubusercontent.com/u/44613678?v=4&s=45" width="45" title="naa7"></a>
|
||||
<a href="https://github.com/ramonvc" target="_blank"><img src="https://avatars.githubusercontent.com/u/13617054?v=4&s=45" width="45" title="ramonvc"></a>
|
||||
<a href="https://github.com/ramon-victor" target="_blank"><img src="https://avatars.githubusercontent.com/u/13617054?v=4&s=45" width="45" title="ramon-victor"></a>
|
||||
<a href="https://github.com/eltociear" target="_blank"><img src="https://avatars.githubusercontent.com/u/22633385?v=4&s=45" width="45" title="eltociear"></a>
|
||||
<a href="https://github.com/kggn" target="_blank"><img src="https://avatars.githubusercontent.com/u/95663228?v=4&s=45" width="45" title="kggn"></a>
|
||||
<a href="https://github.com/xiangsx" target="_blank"><img src="https://avatars.githubusercontent.com/u/29322721?v=4&s=45" width="45" title="xiangsx"></a>
|
||||
<a href="https://github.com/ggindinson" target="_blank"><img src="https://avatars.githubusercontent.com/u/97807772?v=4&s=45" width="45" title="ggindinson"></a>
|
||||
<a href="https://github.com/ahobsonsayers" target="_blank"><img src="https://avatars.githubusercontent.com/u/32173585?v=4&s=45" width="45" title="ahobsonsayers"></a>
|
||||
<a href="https://github.com/mache102" target="_blank"><img src="https://avatars.githubusercontent.com/u/91365155?v=4&s=45" width="45" title="mache102"></a>
|
||||
<a href="https://github.com/kogakisaki" target="_blank"><img src="https://avatars.githubusercontent.com/u/95165750?v=4&s=45" width="45" title="kogakisaki"></a>
|
||||
<a href="https://github.com/Andrew-Tsegaye" target="_blank"><img src="https://avatars.githubusercontent.com/u/91322467?v=4&s=45" width="45" title="Andrew-Tsegaye"></a>
|
||||
<a href="https://github.com/omidima" target="_blank"><img src="https://avatars.githubusercontent.com/u/47784584?v=4&s=45" width="45" title="omidima"></a>
|
||||
<a href="https://github.com/nonk123" target="_blank"><img src="https://avatars.githubusercontent.com/u/43842467?v=4&s=45" width="45" title="nonk123"></a>
|
||||
<a href="https://github.com/MaxKUlish1" target="_blank"><img src="https://avatars.githubusercontent.com/u/93388714?v=4&s=45" width="45" title="MaxKUlish1"></a>
|
||||
<a href="https://github.com/AymaneHrouch" target="_blank"><img src="https://avatars.githubusercontent.com/u/36491424?v=4&s=45" width="45" title="AymaneHrouch"></a>
|
||||
<a href="https://github.com/Eikosa" target="_blank"><img src="https://avatars.githubusercontent.com/u/20538090?v=4&s=45" width="45" title="Eikosa"></a>
|
||||
<a href="https://github.com/localagi" target="_blank"><img src="https://avatars.githubusercontent.com/u/132956819?v=4&s=45" width="45" title="localagi"></a>
|
||||
<a href="https://github.com/thebigbone" target="_blank"><img src="https://avatars.githubusercontent.com/u/95130644?v=4&s=45" width="45" title="thebigbone"></a>
|
||||
<a href="https://github.com/kailust" target="_blank"><img src="https://avatars.githubusercontent.com/u/82623773?v=4&s=45" width="45" title="kailust"></a>
|
||||
<a href="https://github.com/ading2210" target="_blank"><img src="https://avatars.githubusercontent.com/u/71154407?v=4&s=45" width="45" title="ading2210"></a>
|
||||
<a href="https://github.com/Zero6992" target="_blank"><img src="https://avatars.githubusercontent.com/u/89479282?v=4&s=45" width="45" title="Zero6992"></a>
|
||||
<a href="https://github.com/mishl-dev" target="_blank"><img src="https://avatars.githubusercontent.com/u/91066601?v=4&s=45" width="45" title="mishl-dev"></a>
|
||||
<a href="https://github.com/ElonGaties" target="_blank"><img src="https://avatars.githubusercontent.com/u/59313695?v=4&s=45" width="45" title="ElonGaties"></a>
|
||||
<a href="https://github.com/TotoB12" target="_blank"><img src="https://avatars.githubusercontent.com/u/91705868?v=4&s=45" width="45" title="TotoB12"></a>
|
||||
<a href="https://github.com/malivinayak" target="_blank"><img src="https://avatars.githubusercontent.com/u/66154908?v=4&s=45" width="45" title="malivinayak"></a>
|
||||
<a href="https://github.com/Zedai00" target="_blank"><img src="https://avatars.githubusercontent.com/u/33319711?v=4&s=45" width="45" title="Zedai00"></a>
|
||||
<a href="https://github.com/catmeowjiao" target="_blank"><img src="https://avatars.githubusercontent.com/u/138079152?v=4&s=45" width="45" title="catmeowjiao"></a>
|
||||
<a href="https://github.com/cifer-sudo" target="_blank"><img src="https://avatars.githubusercontent.com/u/60644739?v=4&s=45" width="45" title="cifer-sudo"></a>
|
||||
<a href="https://github.com/eminemkun" target="_blank"><img src="https://avatars.githubusercontent.com/u/49590289?v=4&s=45" width="45" title="eminemkun"></a>
|
||||
<a href="https://github.com/kafmws" target="_blank"><img src="https://avatars.githubusercontent.com/u/33590879?v=4&s=45" width="45" title="kafmws"></a>
|
||||
<a href="https://github.com/najam-tariq" target="_blank"><img src="https://avatars.githubusercontent.com/u/103676132?v=4&s=45" width="45" title="najam-tariq"></a>
|
||||
<a href="https://github.com/ochen1" target="_blank"><img src="https://avatars.githubusercontent.com/u/59662605?v=4&s=45" width="45" title="ochen1"></a>
|
||||
<a href="https://github.com/r1di" target="_blank"><img src="https://avatars.githubusercontent.com/u/33724815?v=4&s=45" width="45" title="r1di"></a>
|
||||
<a href="https://github.com/sagadav" target="_blank"><img src="https://avatars.githubusercontent.com/u/42406802?v=4&s=45" width="45" title="sagadav"></a>
|
||||
<a href="https://github.com/snyk-bot" target="_blank"><img src="https://avatars.githubusercontent.com/u/19733683?v=4&s=45" width="45" title="snyk-bot"></a>
|
||||
<a href="https://github.com/vatva691" target="_blank"><img src="https://avatars.githubusercontent.com/u/30290559?v=4&s=45" width="45" title="vatva691"></a>
|
||||
<a href="https://github.com/Qustelm" target="_blank"><img src="https://avatars.githubusercontent.com/u/83110161?v=4&s=45" width="45" title="Qustelm"></a>
|
||||
<a href="https://github.com/HyiKi" target="_blank"><img src="https://avatars.githubusercontent.com/u/55942998?v=4&s=45" width="45" title="HyiKi"></a>
|
||||
<a href="https://github.com/0dminnimda" target="_blank"><img src="https://avatars.githubusercontent.com/u/52697657?v=4&s=45" width="45" title="0dminnimda"></a>
|
||||
<a href="https://github.com/Akash98Sky" target="_blank"><img src="https://avatars.githubusercontent.com/u/37451227?v=4&s=45" width="45" title="Akash98Sky"></a>
|
||||
<a href="https://github.com/adeyinkaezra123" target="_blank"><img src="https://avatars.githubusercontent.com/u/65364356?v=4&s=45" width="45" title="adeyinkaezra123"></a>
|
||||
<a href="https://github.com/Giancarlo-Ma" target="_blank"><img src="https://avatars.githubusercontent.com/u/65126107?v=4&s=45" width="45" title="Giancarlo-Ma"></a>
|
||||
<a href="https://github.com/gran4" target="_blank"><img src="https://avatars.githubusercontent.com/u/80655391?v=4&s=45" width="45" title="gran4"></a>
|
||||
<a href="https://github.com/guspan-tanadi" target="_blank"><img src="https://avatars.githubusercontent.com/u/36249910?v=4&s=45" width="45" title="guspan-tanadi"></a>
|
||||
<a href="https://github.com/oubrax" target="_blank"><img src="https://avatars.githubusercontent.com/u/72103863?v=4&s=45" width="45" title="oubrax"></a>
|
||||
<a href="https://github.com/hansipie" target="_blank"><img src="https://avatars.githubusercontent.com/u/5460714?v=4&s=45" width="45" title="hansipie"></a>
|
||||
<a href="https://github.com/GetTuh" target="_blank"><img src="https://avatars.githubusercontent.com/u/27581581?v=4&s=45" width="45" title="GetTuh"></a>
|
||||
<a href="https://github.com/kushal34712" target="_blank"><img src="https://avatars.githubusercontent.com/u/98145879?v=4&s=45" width="45" title="kushal34712"></a>
|
||||
<a href="https://github.com/Fubge" target="_blank"><img src="https://avatars.githubusercontent.com/u/115476150?v=4&s=45" width="45" title="Fubge"></a>
|
||||
<a href="https://github.com/Niapoll" target="_blank"><img src="https://avatars.githubusercontent.com/u/64135936?v=4&s=45" width="45" title="Niapoll"></a>
|
||||
<a href="https://github.com/OmiiiDev" target="_blank"><img src="https://avatars.githubusercontent.com/u/103533638?v=4&s=45" width="45" title="OmiiiDev"></a>
|
||||
<a href="https://github.com/RasyiidWho" target="_blank"><img src="https://avatars.githubusercontent.com/u/19422415?v=4&s=45" width="45" title="RasyiidWho"></a>
|
||||
<a href="https://github.com/RavenOwO" target="_blank"><img src="https://avatars.githubusercontent.com/u/118295106?v=4&s=45" width="45" title="RavenOwO"></a>
|
||||
<a href="https://github.com/anonymousx97" target="_blank"><img src="https://avatars.githubusercontent.com/u/88324835?v=4&s=45" width="45" title="anonymousx97"></a>
|
||||
<a href="https://github.com/krjordan" target="_blank"><img src="https://avatars.githubusercontent.com/u/10234150?v=4&s=45" width="45" title="krjordan"></a>
|
||||
<a href="https://github.com/SilverMarcs" target="_blank"><img src="https://avatars.githubusercontent.com/u/77480421?v=4&s=45" width="45" title="SilverMarcs"></a>
|
||||
<a href="https://github.com/Yusufibin" target="_blank"><img src="https://avatars.githubusercontent.com/u/71589435?v=4&s=45" width="45" title="Yusufibin"></a>
|
||||
<a href="https://github.com/yuri-val" target="_blank"><img src="https://avatars.githubusercontent.com/u/15129796?v=4&s=45" width="45" title="yuri-val"></a>
|
||||
<a href="https://github.com/yousefnegmeldin" target="_blank"><img src="https://avatars.githubusercontent.com/u/96620955?v=4&s=45" width="45" title="yousefnegmeldin"></a>
|
||||
<a href="https://github.com/perklet" target="_blank"><img src="https://avatars.githubusercontent.com/u/1035487?v=4&s=45" width="45" title="perklet"></a>
|
||||
<a href="https://github.com/varshney-yash" target="_blank"><img src="https://avatars.githubusercontent.com/u/107148830?v=4&s=45" width="45" title="varshney-yash"></a>
|
||||
<a href="https://github.com/Yoxmo" target="_blank"><img src="https://avatars.githubusercontent.com/u/94254616?v=4&s=45" width="45" title="Yoxmo"></a>
|
||||
<a href="https://github.com/yjg30737" target="_blank"><img src="https://avatars.githubusercontent.com/u/55078043?v=4&s=45" width="45" title="yjg30737"></a>
|
||||
<a href="https://github.com/williamstein" target="_blank"><img src="https://avatars.githubusercontent.com/u/1276278?v=4&s=45" width="45" title="williamstein"></a>
|
||||
<a href="https://github.com/ZachKLYeh" target="_blank"><img src="https://avatars.githubusercontent.com/u/105150034?v=4&s=45" width="45" title="ZachKLYeh"></a>
|
||||
<a href="https://github.com/alvarosoaress" target="_blank"><img src="https://avatars.githubusercontent.com/u/13721147?v=4&s=45" width="45" title="alvarosoaress"></a>
|
||||
<a href="https://github.com/bruvv" target="_blank"><img src="https://avatars.githubusercontent.com/u/3063928?v=4&s=45" width="45" title="bruvv"></a>
|
||||
<a href="https://github.com/carlinhoshk" target="_blank"><img src="https://avatars.githubusercontent.com/u/40872405?v=4&s=45" width="45" title="carlinhoshk"></a>
|
||||
<a href="https://github.com/cckuailong" target="_blank"><img src="https://avatars.githubusercontent.com/u/10824150?v=4&s=45" width="45" title="cckuailong"></a>
|
||||
<a href="https://github.com/chinmay7016" target="_blank"><img src="https://avatars.githubusercontent.com/u/75988613?v=4&s=45" width="45" title="chinmay7016"></a>
|
||||
<a href="https://github.com/diaodeng" target="_blank"><img src="https://avatars.githubusercontent.com/u/108243171?v=4&s=45" width="45" title="diaodeng"></a>
|
||||
<a href="https://github.com/monosans" target="_blank"><img src="https://avatars.githubusercontent.com/u/76561516?v=4&s=45" width="45" title="monosans"></a>
|
||||
<a href="https://github.com/Ayushpanditmoto" target="_blank"><img src="https://avatars.githubusercontent.com/u/31253617?v=4&s=45" width="45" title="Ayushpanditmoto"></a>
|
||||
<span></span>
|
||||
<img src="https://avatars.githubusercontent.com/u/71154407?s=45&v=4" width="45" title="ading2210">
|
||||
<img src="https://avatars.githubusercontent.com/u/12299238?s=45&v=4" width="45" title="xqdoo00o">
|
||||
@@ -827,7 +905,7 @@ A list of all contributors is available [here](https://github.com/xtekky/gpt4fre
|
||||
|
||||
- The [`Vercel.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/Vercel.py) file contains code from [vercel-llm-api](https://github.com/ading2210/vercel-llm-api) by [@ading2210](https://github.com/ading2210)
|
||||
- The [`har_file.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/openai/har_file.py) has input from [xqdoo00o/ChatGPT-to-API](https://github.com/xqdoo00o/ChatGPT-to-API)
|
||||
- The [`PerplexityLabs.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/openai/har_file.py) has input from [nathanrchn/perplexityai](https://github.com/nathanrchn/perplexityai)
|
||||
- The [`PerplexityLabs.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/PerplexityLabs.py) has input from [nathanrchn/perplexityai](https://github.com/nathanrchn/perplexityai)
|
||||
- The [`Gemini.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/needs_auth/Gemini.py) has input from [dsdanielpark/Gemini-API](https://github.com/dsdanielpark/Gemini-API)
|
||||
- The [`MetaAI.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/MetaAI.py) file contains code from [meta-ai-api](https://github.com/Strvm/meta-ai-api) by [@Strvm](https://github.com/Strvm)
|
||||
- The [`proofofwork.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/openai/proofofwork.py) has input from [missuo/FreeGPT35](https://github.com/missuo/FreeGPT35)
|
||||
|
@@ -14,8 +14,6 @@ RUN apt-get update && apt-get upgrade -y \
|
||||
# Add user and user group
|
||||
&& groupadd -g $G4F_USER_ID $G4F_USER \
|
||||
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
|
||||
&& mkdir -p /var/log/supervisor \
|
||||
&& chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
|
||||
&& echo "${G4F_USER}:${G4F_USER}" | chpasswd \
|
||||
&& python -m pip install --upgrade pip \
|
||||
&& apt-get clean \
|
||||
@@ -32,8 +30,7 @@ RUN mkdir -p $G4F_DIR
|
||||
COPY requirements-slim.txt $G4F_DIR
|
||||
|
||||
# Upgrade pip for the latest features and install the project's Python dependencies.
|
||||
RUN pip install --no-cache-dir -r requirements-slim.txt \
|
||||
&& pip install --no-cache-dir duckduckgo-search>=5.0
|
||||
RUN pip install --no-cache-dir -r requirements-slim.txt
|
||||
|
||||
# Copy the entire package into the container.
|
||||
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
@@ -185,12 +185,15 @@ print(base64_text)
|
||||
**Create variations of an existing image:**
|
||||
```python
|
||||
from g4f.client import Client
|
||||
from g4f.Provider import OpenaiChat
|
||||
|
||||
client = Client()
|
||||
client = Client(
|
||||
image_provider=OpenaiChat
|
||||
)
|
||||
|
||||
response = client.images.create_variation(
|
||||
image=open("cat.jpg", "rb"),
|
||||
model="bing"
|
||||
model="dall-e-3",
|
||||
# Add any other necessary parameters
|
||||
)
|
||||
|
||||
|
@@ -7,7 +7,7 @@ import g4f
|
||||
|
||||
g4f.debug.logging = True # Enable debug logging
|
||||
g4f.debug.version_check = False # Disable automatic version checking
|
||||
print(g4f.Provider.Gemini.params) # Print supported args for Bing
|
||||
print(g4f.Provider.Gemini.params) # Print supported args for Gemini
|
||||
|
||||
# Using automatic a provider for the given model
|
||||
## Streamed completion
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import requests
|
||||
|
||||
url = "https://api.github.com/repos/xtekky/gpt4free/contributors"
|
||||
url = "https://api.github.com/repos/xtekky/gpt4free/contributors?per_page=100"
|
||||
|
||||
for user in requests.get(url).json():
|
||||
print(f'<a href="https://github.com/{user["login"]}" target="_blank"><img src="{user["avatar_url"]}&s=45" width="45" title="{user["login"]}"></a>')
|
@@ -144,7 +144,7 @@ def analyze_code(pull: PullRequest, diff: str)-> list[dict]:
|
||||
else:
|
||||
changed_lines.append(f"{offset_line}:{line}")
|
||||
offset_line += 1
|
||||
|
||||
|
||||
return comments
|
||||
|
||||
def create_analyze_prompt(changed_lines: list[str], pull: PullRequest, file_path: str):
|
||||
|
@@ -1,33 +0,0 @@
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def main():
|
||||
content = create_content()
|
||||
with open("g4f/provider/__init__.py", "w", encoding="utf-8") as f:
|
||||
f.write(content)
|
||||
|
||||
|
||||
def create_content():
|
||||
path = Path()
|
||||
paths = path.glob("g4f/provider/*.py")
|
||||
paths = [p for p in paths if p.name not in ["__init__.py", "base_provider.py"]]
|
||||
classnames = [p.stem for p in paths]
|
||||
|
||||
import_lines = [f"from .{name} import {name}" for name in classnames]
|
||||
import_content = "\n".join(import_lines)
|
||||
|
||||
classnames.insert(0, "BaseProvider")
|
||||
all_content = [f' "{name}"' for name in classnames]
|
||||
all_content = ",\n".join(all_content)
|
||||
all_content = f"__all__ = [\n{all_content},\n]"
|
||||
|
||||
return f"""from .base_provider import BaseProvider
|
||||
{import_content}
|
||||
|
||||
|
||||
{all_content}
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
@@ -139,9 +139,9 @@ class You(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
else:
|
||||
yield ImageResponse(match.group(2), match.group(1))
|
||||
else:
|
||||
yield data["t"]
|
||||
yield data["t"]
|
||||
else:
|
||||
yield data["t"]
|
||||
yield data["t"]
|
||||
|
||||
@classmethod
|
||||
async def upload_file(cls, client: StreamSession, cookies: Cookies, file: bytes, filename: str = None) -> dict:
|
||||
|
@@ -128,10 +128,13 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
data=data_bytes,
|
||||
headers={
|
||||
"Content-Type": image_data["mime_type"],
|
||||
"x-ms-blob-type": "BlockBlob"
|
||||
"x-ms-blob-type": "BlockBlob",
|
||||
"x-ms-version": "2020-04-08",
|
||||
"Origin": "https://chatgpt.com",
|
||||
"Referer": "https://chatgpt.com/",
|
||||
}
|
||||
) as response:
|
||||
await raise_for_status(response, "Send file failed")
|
||||
await raise_for_status(response)
|
||||
# Post the file ID to the service and get the download URL
|
||||
async with session.post(
|
||||
f"{cls.url}/backend-api/files/{image_data['file_id']}/uploaded",
|
||||
@@ -162,7 +165,7 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
"id": str(uuid.uuid4()),
|
||||
"create_time": int(time.time()),
|
||||
"id": str(uuid.uuid4()),
|
||||
"metadata": {"serialization_metadata": {"custom_symbol_offsets": []}, "system_hints": system_hints},
|
||||
"metadata": {"serialization_metadata": {"custom_symbol_offsets": []}, "system_hints": system_hints},
|
||||
} for message in messages]
|
||||
|
||||
# Check if there is an image response
|
||||
@@ -407,7 +410,8 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
if isinstance(line, dict) and "v" in line:
|
||||
v = line.get("v")
|
||||
if isinstance(v, str) and fields.is_recipient:
|
||||
yield v
|
||||
if "p" not in line or line.get("p") == "/message/content/parts/0":
|
||||
yield v
|
||||
elif isinstance(v, list) and fields.is_recipient:
|
||||
for m in v:
|
||||
if m.get("p") == "/message/content/parts/0":
|
||||
@@ -420,7 +424,7 @@ class OpenaiChat(AsyncGeneratorProvider, ProviderModelMixin):
|
||||
fields.conversation_id = v.get("conversation_id")
|
||||
debug.log(f"OpenaiChat: New conversation: {fields.conversation_id}")
|
||||
m = v.get("message", {})
|
||||
fields.is_recipient = m.get("recipient") == "all"
|
||||
fields.is_recipient = m.get("recipient", "all") == "all"
|
||||
if fields.is_recipient:
|
||||
c = m.get("content", {})
|
||||
if c.get("content_type") == "multimodal_text":
|
||||
|
@@ -101,7 +101,7 @@ def load_cookies_from_browsers(domain_name: str, raise_requirements_error: bool
|
||||
raise MissingRequirementsError('Install "browser_cookie3" package')
|
||||
return {}
|
||||
cookies = {}
|
||||
for cookie_fn in [_g4f, chrome, chromium, opera, opera_gx, brave, edge, vivaldi, firefox]:
|
||||
for cookie_fn in browsers:
|
||||
try:
|
||||
cookie_jar = cookie_fn(domain_name=domain_name)
|
||||
if len(cookie_jar) and debug.logging:
|
||||
@@ -188,20 +188,4 @@ def read_cookie_files(dirPath: str = None):
|
||||
for domain, new_values in new_cookies.items():
|
||||
if debug.logging:
|
||||
print(f"Cookies added: {len(new_values)} from {domain}")
|
||||
CookiesConfig.cookies[domain] = new_values
|
||||
|
||||
def _g4f(domain_name: str) -> list:
|
||||
"""
|
||||
Load cookies from the 'g4f' browser (if exists).
|
||||
|
||||
Args:
|
||||
domain_name (str): The domain for which to load cookies.
|
||||
|
||||
Returns:
|
||||
list: List of cookies.
|
||||
"""
|
||||
if not has_platformdirs:
|
||||
return []
|
||||
user_data_dir = user_config_dir("g4f")
|
||||
cookie_file = os.path.join(user_data_dir, "Default", "Cookies")
|
||||
return [] if not os.path.exists(cookie_file) else chrome(cookie_file, domain_name)
|
||||
CookiesConfig.cookies[domain] = new_values
|
@@ -1064,6 +1064,47 @@ a:-webkit-any-link {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
.hljs-iframe-button, .hljs-iframe-close {
|
||||
position: absolute;
|
||||
bottom: 1rem;
|
||||
right: 1rem;
|
||||
padding: 7px;
|
||||
border-radius: .25rem;
|
||||
border: 1px solid #ffffff22;
|
||||
background-color: #2d2b57;
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.hljs-iframe-button:hover, .hljs-iframe-close:hover {
|
||||
border-color: #ffffff44;
|
||||
color: #ffffff77;
|
||||
}
|
||||
|
||||
.hljs-iframe-container {
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 1000001;
|
||||
background-color: #fff;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hljs-iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.white {
|
||||
--blur-bg: transparent;
|
||||
--accent: #007bff;
|
||||
|
@@ -3,12 +3,12 @@
|
||||
"short_name": "",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/assets/img/android-chrome-192x192.png",
|
||||
"src": "/static/img/android-chrome-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/assets/img/android-chrome-512x512.png",
|
||||
"src": "/static/img/android-chrome-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}
|
||||
|
@@ -44,6 +44,9 @@ appStorage = window.localStorage || {
|
||||
removeItem: (key) => delete self[key],
|
||||
length: 0
|
||||
}
|
||||
|
||||
appStorage.getItem("darkMode") == "false" ? document.body.classList.add("white") : null;
|
||||
|
||||
let markdown_render = () => null;
|
||||
if (window.markdownit) {
|
||||
const markdown = window.markdownit();
|
||||
@@ -56,6 +59,7 @@ if (window.markdownit) {
|
||||
.replaceAll('<code>', '<code class="language-plaintext">')
|
||||
}
|
||||
}
|
||||
|
||||
function filter_message(text) {
|
||||
return text.replaceAll(
|
||||
/<!-- generated images start -->[\s\S]+<!-- generated images end -->/gm, ""
|
||||
@@ -81,7 +85,52 @@ function fallback_clipboard (text) {
|
||||
document.body.removeChild(textBox);
|
||||
}
|
||||
|
||||
const iframe_container = Object.assign(document.createElement("div"), {
|
||||
className: "hljs-iframe-container hidden",
|
||||
});
|
||||
const iframe = Object.assign(document.createElement("iframe"), {
|
||||
className: "hljs-iframe",
|
||||
});
|
||||
iframe_container.appendChild(iframe);
|
||||
const iframe_close = Object.assign(document.createElement("button"), {
|
||||
className: "hljs-iframe-close",
|
||||
innerHTML: '<i class="fa-regular fa-x"></i>',
|
||||
});
|
||||
iframe_close.onclick = () => iframe_container.classList.add("hidden");
|
||||
iframe_container.appendChild(iframe_close);
|
||||
chat.appendChild(iframe_container);
|
||||
|
||||
class HtmlRenderPlugin {
|
||||
constructor(options = {}) {
|
||||
self.hook = options.hook;
|
||||
self.callback = options.callback
|
||||
}
|
||||
"after:highlightElement"({
|
||||
el,
|
||||
text
|
||||
}) {
|
||||
if (!el.classList.contains("language-html")) {
|
||||
return;
|
||||
}
|
||||
let button = Object.assign(document.createElement("button"), {
|
||||
innerHTML: '<i class="fa-regular fa-folder-open"></i>',
|
||||
className: "hljs-iframe-button",
|
||||
});
|
||||
el.parentElement.appendChild(button);
|
||||
button.onclick = async () => {
|
||||
let newText = text;
|
||||
if (hook && typeof hook === "function") {
|
||||
newText = hook(text, el) || text
|
||||
}
|
||||
iframe.src = `data:text/html;charset=utf-8,${encodeURIComponent(newText)}`;
|
||||
iframe_container.classList.remove("hidden");
|
||||
if (typeof callback === "function") return callback(newText, el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hljs.addPlugin(new CopyButtonPlugin());
|
||||
hljs.addPlugin(new HtmlRenderPlugin())
|
||||
let typesetPromise = Promise.resolve();
|
||||
const highlight = (container) => {
|
||||
container.querySelectorAll('code:not(.hljs').forEach((el) => {
|
||||
@@ -371,16 +420,17 @@ document.querySelector(".media_player .fa-x").addEventListener("click", ()=>{
|
||||
});
|
||||
|
||||
const prepare_messages = (messages, message_index = -1) => {
|
||||
if (message_index >= 0) {
|
||||
messages = messages.filter((_, index) => message_index >= index);
|
||||
}
|
||||
|
||||
// Removes none user messages at end
|
||||
let last_message;
|
||||
while (last_message = messages.pop()) {
|
||||
if (last_message["role"] == "user") {
|
||||
messages.push(last_message);
|
||||
break;
|
||||
if (message_index != null) {
|
||||
if (message_index >= 0) {
|
||||
messages = messages.filter((_, index) => message_index >= index);
|
||||
}
|
||||
// Removes none user messages at end
|
||||
let last_message;
|
||||
while (last_message = messages.pop()) {
|
||||
if (last_message["role"] == "user") {
|
||||
messages.push(last_message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1313,9 +1363,6 @@ async function on_api() {
|
||||
}
|
||||
const darkMode = document.getElementById("darkMode");
|
||||
if (darkMode) {
|
||||
if (!darkMode.checked) {
|
||||
document.body.classList.add("white");
|
||||
}
|
||||
darkMode.addEventListener('change', async (event) => {
|
||||
if (event.target.checked) {
|
||||
document.body.classList.remove("white");
|
||||
|
@@ -272,6 +272,7 @@ class RetryProvider(IterListProvider):
|
||||
timeout=kwargs.get("timeout", DEFAULT_TIMEOUT),
|
||||
)
|
||||
if chunk:
|
||||
yield chunk
|
||||
started = True
|
||||
elif hasattr(provider, "create_async_generator"):
|
||||
async for chunk in provider.create_async_generator(model, messages, stream=stream, **kwargs):
|
||||
|
107
g4f/stubs.py
107
g4f/stubs.py
@@ -1,107 +0,0 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Union
|
||||
|
||||
class Model():
|
||||
...
|
||||
|
||||
class ChatCompletion(Model):
|
||||
def __init__(
|
||||
self,
|
||||
content: str,
|
||||
finish_reason: str,
|
||||
completion_id: str = None,
|
||||
created: int = None
|
||||
):
|
||||
self.id: str = f"chatcmpl-{completion_id}" if completion_id else None
|
||||
self.object: str = "chat.completion"
|
||||
self.created: int = created
|
||||
self.model: str = None
|
||||
self.provider: str = None
|
||||
self.choices = [ChatCompletionChoice(ChatCompletionMessage(content), finish_reason)]
|
||||
self.usage: dict[str, int] = {
|
||||
"prompt_tokens": 0, #prompt_tokens,
|
||||
"completion_tokens": 0, #completion_tokens,
|
||||
"total_tokens": 0, #prompt_tokens + completion_tokens,
|
||||
}
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
**self.__dict__,
|
||||
"choices": [choice.to_json() for choice in self.choices]
|
||||
}
|
||||
|
||||
class ChatCompletionChunk(Model):
|
||||
def __init__(
|
||||
self,
|
||||
content: str,
|
||||
finish_reason: str,
|
||||
completion_id: str = None,
|
||||
created: int = None
|
||||
):
|
||||
self.id: str = f"chatcmpl-{completion_id}" if completion_id else None
|
||||
self.object: str = "chat.completion.chunk"
|
||||
self.created: int = created
|
||||
self.model: str = None
|
||||
self.provider: str = None
|
||||
self.choices = [ChatCompletionDeltaChoice(ChatCompletionDelta(content), finish_reason)]
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
**self.__dict__,
|
||||
"choices": [choice.to_json() for choice in self.choices]
|
||||
}
|
||||
|
||||
class ChatCompletionMessage(Model):
|
||||
def __init__(self, content: Union[str, None]):
|
||||
self.role = "assistant"
|
||||
self.content = content
|
||||
|
||||
def to_json(self):
|
||||
return self.__dict__
|
||||
|
||||
class ChatCompletionChoice(Model):
|
||||
def __init__(self, message: ChatCompletionMessage, finish_reason: str):
|
||||
self.index = 0
|
||||
self.message = message
|
||||
self.finish_reason = finish_reason
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
**self.__dict__,
|
||||
"message": self.message.to_json()
|
||||
}
|
||||
|
||||
class ChatCompletionDelta(Model):
|
||||
content: Union[str, None] = None
|
||||
|
||||
def __init__(self, content: Union[str, None]):
|
||||
if content is not None:
|
||||
self.content = content
|
||||
|
||||
def to_json(self):
|
||||
return self.__dict__
|
||||
|
||||
class ChatCompletionDeltaChoice(Model):
|
||||
def __init__(self, delta: ChatCompletionDelta, finish_reason: Union[str, None]):
|
||||
self.delta = delta
|
||||
self.finish_reason = finish_reason
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
**self.__dict__,
|
||||
"delta": self.delta.to_json()
|
||||
}
|
||||
|
||||
class Image(Model):
|
||||
url: str
|
||||
|
||||
def __init__(self, url: str) -> None:
|
||||
self.url = url
|
||||
|
||||
class ImagesResponse(Model):
|
||||
data: list[Image]
|
||||
|
||||
def __init__(self, data: list) -> None:
|
||||
self.data = data
|
Reference in New Issue
Block a user