返回提交历史
Modified
docs/legacy.md
+0
-29
XFEstudio/gpt4free
Update legacy.md
509933f7
代码差异
1 个文件
+0
-29
@@ -113,35 +113,6 @@ for chunk in g4f.ChatCompletion.create(
113
113
print(chunk.alt) # Print used prompt for image generation
114
114
```
115
115
116
##### Using Browser
117
118
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:
119
120
```python
121
import g4f
122
from undetected_chromedriver import Chrome, ChromeOptions
123
from g4f.Provider import (
124
Bard,
125
Poe,
126
AItianhuSpace,
127
MyShell,
128
PerplexityAi,
129
)
130
131
options = ChromeOptions()
132
options.add_argument("--incognito");
133
webdriver = Chrome(options=options, headless=True)
134
for idx in range(10):
135
response = g4f.ChatCompletion.create(
136
model=g4f.models.default,
137
provider=g4f.Provider.MyShell,
138
messages=[{"role": "user", "content": "Suggest me a name."}],
139
webdriver=webdriver
140
)
141
print(f"{idx}:", response)
142
webdriver.quit()
143
```
144
145
116
##### Async Support
146
117
147
118
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.