Skip to content

Commit

Permalink
Update Pi.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hlohaus authored Dec 6, 2023
1 parent c429ec6 commit 5862d55
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions g4f/Provider/Pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def create_completion(
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"]
Expand All @@ -51,9 +54,9 @@ def get_chat_history(session: Session, conversation_id: str):
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',
}
Expand Down

0 comments on commit 5862d55

Please sign in to comment.