diff options
author | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-08-25 06:41:32 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner.lohaus@netformic.com> | 2023-08-25 06:41:32 +0200 |
commit | 126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a (patch) | |
tree | 00f989c070b0c001860c39507450aaf30e4302b1 /g4f/Provider/Bard.py | |
parent | Add create_async method (diff) | |
download | gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar.gz gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar.bz2 gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar.lz gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar.xz gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.tar.zst gpt4free-126496d3cacd06a4fa8cbb4e5bde417ce6bb5b4a.zip |
Diffstat (limited to 'g4f/Provider/Bard.py')
-rw-r--r-- | g4f/Provider/Bard.py | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/g4f/Provider/Bard.py b/g4f/Provider/Bard.py index cbe728cd..a8c7d13f 100644 --- a/g4f/Provider/Bard.py +++ b/g4f/Provider/Bard.py @@ -2,42 +2,26 @@ import json import random import re -import browser_cookie3 from aiohttp import ClientSession import asyncio from ..typing import Any, CreateResult -from .base_provider import BaseProvider +from .base_provider import AsyncProvider, get_cookies -class Bard(BaseProvider): +class Bard(AsyncProvider): url = "https://bard.google.com" needs_auth = True working = True @classmethod - def create_completion( - cls, - model: str, - messages: list[dict[str, str]], - stream: bool, - proxy: str = None, - cookies: dict = {}, - **kwargs: Any, - ) -> CreateResult: - yield asyncio.run(cls.create_async(str, messages, proxy, cookies)) - - @classmethod async def create_async( cls, model: str, messages: list[dict[str, str]], proxy: str = None, - cookies: dict = {}, + cookies: dict = get_cookies(".google.com"), **kwargs: Any, ) -> str: - if not cookies: - for cookie in browser_cookie3.load(domain_name='.google.com'): - cookies[cookie.name] = cookie.value formatted = "\n".join( ["%s: %s" % (message["role"], message["content"]) for message in messages] |