summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2023-11-17 05:22:45 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2023-11-17 05:22:45 +0100
commitb268771baa4ddceee220da70c24fa9b8d93bedba (patch)
tree56c228467146039b48c5d291e3c03d291a07fcca
parentRemove virtualdisplay and add headless mode (diff)
downloadgpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar.gz
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar.bz2
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar.lz
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar.xz
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.tar.zst
gpt4free-b268771baa4ddceee220da70c24fa9b8d93bedba.zip
-rw-r--r--README.md39
1 files changed, 36 insertions, 3 deletions
diff --git a/README.md b/README.md
index 058a605b..9f0494f9 100644
--- a/README.md
+++ b/README.md
@@ -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