-
-
Save hpssjellis/5dfbb2fea3c257f3d5d8998164f52ff4 to your computer and use it in GitHub Desktop.
Revisions
-
svpino revised this gist
Jul 31, 2023 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,12 +27,14 @@ } response = requests.post(url, headers=headers, data=json.dumps(data)) process_id = response.json()["process_id"] status = None while True: response = requests.post( fetch_url, headers=headers, data=json.dumps({ "process_id": process_id, })).json() -
svpino revised this gist
Jul 26, 2023 . 1 changed file with 30 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,34 @@ import requests import json from time import sleep API_KEY = "INSERT YOUR API KEY HERE" AUTHORIZATION = "INSERT YOUR AUTHORIZATION TOKEN HERE" url = "https://api.monsterapi.ai/apis/add-task" fetch_url = "https://api.monsterapi.ai/apis/task-status" headers = { "x-api-key": API_KEY, "Authorization": f"Bearer {AUTHORIZATION}", "Content-Type": "application/json", } data = { "model": "llama2-7b-chat", "data": { "prompt": "How many states in the United States of America?", "top_k": 10, "top_p": 0.9, "temp": 0.1, "max_length": 1000, "beam_size": 1 } } response = requests.post(url, headers=headers, data=json.dumps(data)) status = None while True: response = requests.post( fetch_url, -
svpino created this gist
Jul 26, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ status = None while True: response = requests.post( fetch_url, headers=headers, data=json.dumps({ "process_id": process_id, })).json() status = response["response_data"]["status"] if status not in ("COMPLETED", "FAILED"): sleep(2) else: break if status == "COMPLETED": print(response["response_data"]["result"]["text"]) else: print("Error:", response["response_data"]["result"]["errorMessage"])