| 32 | return tool_name, standard_category, api_name, code_string |
| 33 | |
| 34 | def process_error(response): |
| 35 | save_cache_flag = False |
| 36 | switch_flag = False |
| 37 | if "The request to the API has timed out. Please try again later, or if the issue persists" in str(response): |
| 38 | return_dict = {"error": "API temporarily not working error...", "response": response} |
| 39 | |
| 40 | if "Your Client (working) ---> Gateway (working) ---> API (not working)" in str(response): |
| 41 | return_dict = {"error": "API not working error...", "response": response} |
| 42 | |
| 43 | elif "Unauthorized" in str(response) or "unauthorized" in str(response): |
| 44 | save_cache_flag = True |
| 45 | return_dict = {"error": "Unauthorized error...", "response": response} |
| 46 | |
| 47 | elif "You are not subscribed to this API." in str(response): |
| 48 | switch_flag = True |
| 49 | return_dict = {"error": "Unsubscribed error...", "response": response} |
| 50 | |
| 51 | elif "Too many requests" in str(response): |
| 52 | switch_flag = True |
| 53 | return_dict = {"error": "Too many requests error...", "response": response} |
| 54 | |
| 55 | elif "You have exceeded" in str(response) or "you are being rate limited" in str(response): |
| 56 | switch_flag = True |
| 57 | return_dict = {"error": "Rate limit error...", "response": response} |
| 58 | |
| 59 | elif "Access restricted. Check credits balance or enter the correct API key." in str(response): |
| 60 | switch_flag = True |
| 61 | return_dict = {"error": "Rate limit error...", "response": response} |
| 62 | |
| 63 | elif "Oops, an error in the gateway has occurred." in str(response): |
| 64 | switch_flag = True |
| 65 | return_dict = {"error": "Gateway error...", "response": response} |
| 66 | |
| 67 | elif "Blocked User. Please contact your API provider." in str(response): |
| 68 | switch_flag = True |
| 69 | return_dict = {"error": "Blocked error...", "response": response} |
| 70 | |
| 71 | elif "error" in str(response): |
| 72 | return_dict = {"error": "Message error...", "response": response} |
| 73 | |
| 74 | else: |
| 75 | save_cache_flag = True |
| 76 | return_dict = {"error": "", "response": response} |
| 77 | return return_dict, save_cache_flag, switch_flag |
| 78 | |
| 79 | def run(toolbench_code_string, toolbench_api_name, toolbench_input_params_str): |
| 80 | # get observation |