mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-05 18:20:35 -08:00
Update legacy.md
This commit is contained in:
parent
f989b52fdf
commit
509933f7b3
1 changed files with 0 additions and 29 deletions
|
|
@ -113,35 +113,6 @@ for chunk in g4f.ChatCompletion.create(
|
|||
print(chunk.alt) # Print used prompt for image generation
|
||||
```
|
||||
|
||||
##### 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,
|
||||
PerplexityAi,
|
||||
)
|
||||
|
||||
options = ChromeOptions()
|
||||
options.add_argument("--incognito");
|
||||
webdriver = Chrome(options=options, headless=True)
|
||||
for idx in range(10):
|
||||
response = g4f.ChatCompletion.create(
|
||||
model=g4f.models.default,
|
||||
provider=g4f.Provider.MyShell,
|
||||
messages=[{"role": "user", "content": "Suggest me a name."}],
|
||||
webdriver=webdriver
|
||||
)
|
||||
print(f"{idx}:", response)
|
||||
webdriver.quit()
|
||||
```
|
||||
|
||||
##### Async Support
|
||||
|
||||
To enhance speed and overall performance, execute providers asynchronously. The total execution time will be determined by the duration of the slowest provider's execution.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue