From 5862d55abf44c3e9bc63b4fe231c80475ec1157d Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 6 Dec 2023 13:47:22 +0100 Subject: Update Pi.py --- g4f/Provider/Pi.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/g4f/Provider/Pi.py b/g4f/Provider/Pi.py index 385f477b..529a4a52 100644 --- a/g4f/Provider/Pi.py +++ b/g4f/Provider/Pi.py @@ -27,7 +27,10 @@ class Pi(BaseProvider): session = get_session_from_browser(url=cls.url, proxy=proxy, timeout=timeout) if not conversation_id: conversation_id = cls.start_conversation(session) - answer = cls.ask(session, messages, conversation_id) + prompt = format_prompt(messages) + else: + prompt = messages[-1]["content"] + answer = cls.ask(session, prompt, conversation_id) for line in answer: if "text" in line: yield line["text"] @@ -51,9 +54,9 @@ class Pi(BaseProvider): raise RuntimeError('Error: Cloudflare detected') return response.json() - def ask(session: Session, messages: Messages, conversation_id: str): + def ask(session: Session, prompt: str, conversation_id: str): json_data = { - 'text': format_prompt(messages), + 'text': prompt, 'conversation': conversation_id, 'mode': 'BASE', } -- cgit v1.2.3