Download toolbench/toolenv/tools/Artificial_Intelligence_Machine_Learning/chatgpt/api.py from Septzzz/gymcl-data: direct link, hf CLI and curl.
- Browser
- Download file 2.84 kB
-
https://huggingface.co/datasets/Septzzz/gymcl-data/resolve/main/toolbench/toolenv/tools/Artificial_Intelligence_Machine_Learning/chatgpt/api.py
- Command line
-
hf download hf://datasets/Septzzz/gymcl-data/toolbench/toolenv/tools/Artificial_Intelligence_Machine_Learning/chatgpt/api.py
-
curl -L -o api.py https://huggingface.co/datasets/Septzzz/gymcl-data/resolve/main/toolbench/toolenv/tools/Artificial_Intelligence_Machine_Learning/chatgpt/api.py
2.84 kB
| import requests | |
| import json | |
| from datetime import date, datetime, timedelta | |
| import os | |
| from typing import Optional, Dict, Union, List | |
| def listengines(toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'): | |
| """ | |
| "Lists the currently available (non-finetuned) models, and provides basic information about each one such as the owner and availability." | |
| """ | |
| url = f"https://chatgpt9.p.rapidapi.com/api/chat-gpt/engines" | |
| querystring = {} | |
| headers = { | |
| "X-RapidAPI-Key": toolbench_rapidapi_key, | |
| "X-RapidAPI-Host": "chatgpt9.p.rapidapi.com" | |
| } | |
| response = requests.get(url, headers=headers, params=querystring) | |
| try: | |
| observation = response.json() | |
| except: | |
| observation = response.text | |
| return observation | |
| def retrievemodel(model_id: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'): | |
| """ | |
| "Retrieves a model instance, providing basic information about the model such as the owner and permissioning." | |
| """ | |
| url = f"https://chatgpt9.p.rapidapi.com/api/chat-gpt/models/{model_id}" | |
| querystring = {} | |
| headers = { | |
| "X-RapidAPI-Key": toolbench_rapidapi_key, | |
| "X-RapidAPI-Host": "chatgpt9.p.rapidapi.com" | |
| } | |
| response = requests.get(url, headers=headers, params=querystring) | |
| try: | |
| observation = response.json() | |
| except: | |
| observation = response.text | |
| return observation | |
| def retrieveengine(engine_id: str, toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'): | |
| """ | |
| "Retrieves a model instance, providing basic information about it such as the owner and availability." | |
| """ | |
| url = f"https://chatgpt9.p.rapidapi.com/api/chat-gpt/engines/{engine_id}" | |
| querystring = {} | |
| headers = { | |
| "X-RapidAPI-Key": toolbench_rapidapi_key, | |
| "X-RapidAPI-Host": "chatgpt9.p.rapidapi.com" | |
| } | |
| response = requests.get(url, headers=headers, params=querystring) | |
| try: | |
| observation = response.json() | |
| except: | |
| observation = response.text | |
| return observation | |
| def listmodels(toolbench_rapidapi_key: str='088440d910mshef857391f2fc461p17ae9ejsnaebc918926ff'): | |
| """ | |
| "Lists the currently available models, and provides basic information about each one such as the owner and availability." | |
| """ | |
| url = f"https://chatgpt9.p.rapidapi.com/api/chat-gpt/models" | |
| querystring = {} | |
| headers = { | |
| "X-RapidAPI-Key": toolbench_rapidapi_key, | |
| "X-RapidAPI-Host": "chatgpt9.p.rapidapi.com" | |
| } | |
| response = requests.get(url, headers=headers, params=querystring) | |
| try: | |
| observation = response.json() | |
| except: | |
| observation = response.text | |
| return observation | |