diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-08-25 18:16:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 18:16:25 +0200 |
commit | d765551b97b671b7b532371b31f2da1dc22dedc1 (patch) | |
tree | 339f0a91136f6611c186f5730d3c4e58477df25e /g4f/Provider/Bard.py | |
parent | ~ | Merge pull request #829 (diff) | |
parent | Add OpenaiChat and Hugchat Provider (diff) | |
download | gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar.gz gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar.bz2 gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar.lz gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar.xz gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.tar.zst gpt4free-d765551b97b671b7b532371b31f2da1dc22dedc1.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] |