summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/Bard.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-08-25 18:22:25 +0200
committerGitHub <noreply@github.com>2023-08-25 18:22:25 +0200
commit473ac1450ae09cd59c7dc818a4bb272ed5640610 (patch)
tree60052aad3746053eb4aec5b7e44d75404f4d11fe /g4f/Provider/Bard.py
parentRemove judge function (diff)
parent~ | Merge pull request #841 (diff)
downloadgpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.gz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.bz2
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.lz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.xz
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.tar.zst
gpt4free-473ac1450ae09cd59c7dc818a4bb272ed5640610.zip
Diffstat (limited to 'g4f/Provider/Bard.py')
-rw-r--r--g4f/Provider/Bard.py22
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]