diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-12-02 00:34:05 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-12-02 00:34:05 +0100 |
commit | cd6ccdd03b0a29de4a86b68a711be3930919080f (patch) | |
tree | 6319d1c07a592b75bfcd2aef211ed16ec0496e1a /g4f | |
parent | Update pi provider (diff) | |
download | gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar.gz gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar.bz2 gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar.lz gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar.xz gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.tar.zst gpt4free-cd6ccdd03b0a29de4a86b68a711be3930919080f.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Pi.py | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/g4f/Provider/Pi.py b/g4f/Provider/Pi.py index 9ecebafb..8acf3ec6 100644 --- a/g4f/Provider/Pi.py +++ b/g4f/Provider/Pi.py @@ -23,32 +23,30 @@ class Pi(BaseProvider): **kwargs ) -> CreateResult: if not scraper: - scraper = cls.get_scraper() + scraper = cls.get_scraper(proxy) if not conversation: conversation = cls.start_conversation(scraper) answer = cls.ask(scraper, messages, conversation) - - last_answer = 0 for line in answer: if "text" in line: - yield line["text"][last_answer:] - last_answer = len(line["text"]) - - def get_scraper(): - scraper = create_scraper( + yield line["text"] + + def get_scraper(proxy: str): + return create_scraper( browser={ 'browser': 'chrome', 'platform': 'windows', 'desktop': True }, - sess=session() + headers={ + 'Accept': '*/*', + 'Accept-Encoding': 'deflate,gzip,br', + }, + proxies={ + "https": proxy + } ) - scraper.headers = { - 'Accept': '*/*', - 'Accept-Encoding': 'deflate,gzip,br', - } - return scraper - + def start_conversation(scraper: CloudScraper): response = scraper.post('https://pi.ai/api/chat/start', data="{}", headers={ 'accept': 'application/json', |