Skip to content

Commit

Permalink
feat: speed boost
Browse files Browse the repository at this point in the history
  • Loading branch information
Strvm committed Jul 28, 2024
1 parent 85c463d commit 7626121
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/meta_ai_api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "1.2.0"
__version__ = "1.2.1"
from .main import MetaAI # noqa
15 changes: 6 additions & 9 deletions src/meta_ai_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ def get_access_token(self) -> str:
access_token = auth_json["data"]["xab_abra_accept_terms_of_service"][
"new_temp_user_auth"
]["access_token"]

# Need to sleep for a bit, for some reason the API doesn't like it when we send request too quickly
# (maybe Meta needs to register Cookies on their side?)
time.sleep(1)

return access_token

def prompt(
Expand Down Expand Up @@ -148,9 +153,6 @@ def prompt(
auth_payload = {"fb_dtsg": self.cookies["fb_dtsg"]}
url = "https://www.meta.ai/api/graphql/"

# Need to sleep for a bit, for some reason the API doesn't like it when we send request too quickly
# (maybe Meta needs to register Cookies on their side?)
time.sleep(1)
if not self.external_conversation_id or new_conversation:
external_id = str(uuid.uuid4())
self.external_conversation_id = external_id
Expand Down Expand Up @@ -407,9 +409,4 @@ def fetch_sources(self, fetch_id: str) -> List[Dict]:

if __name__ == "__main__":
meta = MetaAI()
# resp = meta.prompt("What was the Warriors score last game?", stream=False)
resp = meta.prompt("what is 2 + 2?", stream=False)
print(resp)

resp = meta.prompt("what was my previous question?", stream=False)
print(resp)
resp = meta.prompt("What was the Warriors score last game?", stream=False)

0 comments on commit 7626121

Please sign in to comment.