mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-12-24 11:34:02 +03:00
Update Readme
This commit is contained in:
parent
2ebbcdf0b8
commit
b268771baa
39
README.md
39
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
|
||||
|
Loading…
Reference in New Issue
Block a user