diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-11-17 09:28:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 09:28:55 +0100 |
commit | 053cfa6630a64caac04dbf0bc2aab177224ef807 (patch) | |
tree | 095bf4dae94e1b96e2bc2ac638d2608e1f3a4e37 /README.md | |
parent | Merge pull request #1261 from hlohaus/any (diff) | |
parent | Update Readme (diff) | |
download | gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar.gz gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar.bz2 gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar.lz gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar.xz gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.tar.zst gpt4free-053cfa6630a64caac04dbf0bc2aab177224ef807.zip |
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -243,6 +243,41 @@ for message in response: print(message) ``` +##### 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: + +```python +import g4f +from undetected_chromedriver import Chrome, ChromeOptions +from g4f.Provider import ( + Bard, + Poe, + AItianhuSpace, + MyShell, + Phind, + PerplexityAi, +) + +options = ChromeOptions() +options.add_argument("--incognito"); +browser = Chrome(options=options, headless=True) +for idx in range(10): + response = g4f.ChatCompletion.create( + model=g4f.models.default, + provider=g4f.Provider.Phind, + messages=[{"role": "user", "content": "Suggest me a name."}], + browser=browser + ) + print(f"{idx}:", response) +browser.quit() +``` + ##### Cookies Required Cookies are essential for the proper functioning of some service providers. It is imperative to maintain an active session, typically achieved by logging into your account. @@ -253,18 +288,16 @@ When running the g4f package locally, the package automatically retrieves cookie import g4f from g4f.Provider import ( - Bard, Bing, HuggingChat, OpenAssistant, - OpenaiChat, ) # Usage response = g4f.ChatCompletion.create( model=g4f.models.default, messages=[{"role": "user", "content": "Hello"}], - provider=Bard, + provider=Bing, #cookies=g4f.get_cookies(".google.com"), cookies={"cookie_name": "value", "cookie_name2": "value2"}, auth=True |