Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
fix: properly initialize Bing API
Browse files Browse the repository at this point in the history
  • Loading branch information
cycneuramus committed May 26, 2023
1 parent 5c41f3b commit 3cb37e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ class BingAPI:
def __init__(self, conversation_style, cookie_path):
self.conversation_style = conversation_style
self.cookie_path = cookie_path
self.chat = self._create_chat
self.cookies = self._parse_cookies()
self.chat = Bing(cookies=self.cookies)

async def _create_chat(self, cookie_path):
if cookie_path is None:
return await Bing.create()
def _parse_cookies(self):
if self.cookie_path is None:
return None
else:
cookies = json.loads(open(cookie_path, encoding="utf-8").read())
return await Bing.create(cookies=cookies)
return json.loads(open(self.cookie_path, encoding="utf-8").read())

def _cleanup_footnote_marks(self, response):
return re.sub(r"\[\^(\d+)\^\]", r"[\1]", response)
Expand Down

0 comments on commit 3cb37e8

Please sign in to comment.