commit 24b2df86d380b84e89bb091a386540aa0a7e9a58 Author: birdup Date: Fri May 10 23:10:09 2024 +0500 Upload files to "/" diff --git a/anakin.py b/anakin.py new file mode 100644 index 0000000..a5e8224 --- /dev/null +++ b/anakin.py @@ -0,0 +1,57 @@ +import requests +from requests.exceptions import ChunkedEncodingError +import uuid + +# Variable section Claude 3 Sonnet Example +workspace_id = "User workspace_id_here" +app_id = "15108" +app_instance_id = "587288" +app_conversation_id = "an conversation id here" +model_id = 4 # 4 is the model id entry in list for app instancefor Claude 3 Sonnet Example +content = "how to make a scrumptious cake?" +authorization_bearer = "Put your bearer token ey..." +device_id = str(uuid.uuid4()) + +headers = { + "accept": "application/json", + "accept-language": "en-US", + "access-control-allow-origin": "*", + "authorization": f"Bearer {authorization_bearer}", + "content-type": "application/json;charset=UTF-8", + "origin": "https://app.anakin.ai", + "priority": "u=1, i", + "referer": "https://app.anakin.ai/", + "sec-ch-ua": '"Chromium";v="124", "Brave";v="124", "Not-A.Brand";v="99"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Linux"', + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "sec-gpc": "1", + "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36", + "x-app-id;": "", + "x-client-mode": "web", + "x-client-version": "1.0.4-release.202405070429", + "x-device-id": device_id +} + +def generate_unique_id(): + return str(uuid.uuid4()) + +# Request 1 +url = f"https://api.anakin.ai/api/v1/workspaces/0/apps/{app_id}/app-conversation-messages" +uniq_id = generate_unique_id() +data = f'{{"uniqId":"{uniq_id}","appInstanceId":"{app_instance_id}","appConversationId":"{app_conversation_id}","content":"{content}","modelId":{model_id}}}' +with requests.Session() as session: + try: + response = session.post(url, headers=headers, data=data, stream=True) + for line in response.iter_lines(): + if line: + print(line.decode()) + except ChunkedEncodingError: + print("Streaming response ended.") + +# Request 4 +url = "https://api.anakin.ai/api/v1/user/credit?locale=en-US" +response = requests.get(url, headers=headers) +print(response.text) \ No newline at end of file