diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 55 |
1 files changed, 52 insertions, 3 deletions
@@ -99,8 +99,29 @@ or set the api base in your client to: [http://localhost:1337/v1](http://localho ##### Install using pypi: +Install all supported tools / all used packages: ``` -pip install -U "g4f[all]" +pip install -U g4f[all] +``` +Install packages for uploading / generating images: +``` +pip install -U g4f[image] +``` +Install the packages required for providers with webdriver: +``` +pip install -U g4f[webdriver] +``` +Install the packages required for the OpenaiChat provider: +``` +pip install -U g4f[openai] +``` +Install the packages required for the interference api: +``` +pip install -U g4f[api] +``` +Install the packages required for the web gui: +``` +pip install -U g4f[gui] ``` ##### or: @@ -202,8 +223,9 @@ docker-compose down ### The Web UI -To use it in the web interface, type the following codes in the command line. -```python3 +To start the web interface, type the following codes in the command line. + +```python from g4f.gui import run_gui run_gui() ``` @@ -283,6 +305,33 @@ for message in response: print(message) ``` +##### Cookies / Access Token + +For generating images with Bing and for the OpenAi Chat you need cookies or a token from your browser session. From Bing you need the "_U" cookie and from OpenAI you need the "access_token". You can pass the cookies / the access token in the create function or you use the `set_cookies` setter: + +```python +from g4f import set_cookies + +set_cookies(".bing", { + "_U": "cookie value" +}) +set_cookies("chat.openai.com", { + "access_token": "token value" +}) + +from g4f.gui import run_gui +run_gui() +``` + +Alternatively, g4f reads the cookies with “browser_cookie3” from your browser +or it starts a browser instance with selenium "webdriver" for logging in. +If you use the pip package, you have to install “browser_cookie3” or "webdriver" by yourself. + +```bash +pip install browser_cookie3 +pip install g4f[webdriver] +``` + ##### Using Browser Some providers using a browser to bypass the bot protection. They using the selenium webdriver to control the browser. The browser settings and the login data are saved in a custom directory. If the headless mode is enabled, the browser windows are loaded invisibly. For performance reasons, it is recommended to reuse the browser instances and close them yourself at the end: |