XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Update Readme

b268771b
Heiner Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +36 -3
Modified README.md +36 -3
@@ -243,6 +243,41 @@ for message in response:
243 243 print(message)
244 244 ```
245 245
246 ##### Using Browser
247
248 Some providers using a browser to bypass the bot protection.
249 They using the selenium webdriver to control the browser.
250 The browser settings and the login data are saved in a custom directory.
251 If the headless mode is enabled, the browser windows are loaded invisibly.
252 For performance reasons, it is recommended to reuse the browser instances
253 and close them yourself at the end:
254
255 ```python
256 import g4f
257 from undetected_chromedriver import Chrome, ChromeOptions
258 from g4f.Provider import (
259 Bard,
260 Poe,
261 AItianhuSpace,
262 MyShell,
263 Phind,
264 PerplexityAi,
265 )
266
267 options = ChromeOptions()
268 options.add_argument("--incognito");
269 browser = Chrome(options=options, headless=True)
270 for idx in range(10):
271 response = g4f.ChatCompletion.create(
272 model=g4f.models.default,
273 provider=g4f.Provider.Phind,
274 messages=[{"role": "user", "content": "Suggest me a name."}],
275 browser=browser
276 )
277 print(f"{idx}:", response)
278 browser.quit()
279 ```
280
246 281 ##### Cookies Required
247 282
248 283 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
253 288 import g4f
254 289
255 290 from g4f.Provider import (
256 Bard,
257 291 Bing,
258 292 HuggingChat,
259 293 OpenAssistant,
260 OpenaiChat,
261 294 )
262 295
263 296 # Usage
264 297 response = g4f.ChatCompletion.create(
265 298 model=g4f.models.default,
266 299 messages=[{"role": "user", "content": "Hello"}],
267 provider=Bard,
300 provider=Bing,
268 301 #cookies=g4f.get_cookies(".google.com"),
269 302 cookies={"cookie_name": "value", "cookie_name2": "value2"},
270 303 auth=True