"""API interactions for the Kwest API.""" | |
import os | |
import requests | |
API_URL = os.getenv("API_URL", None) | |
AUTH_TOKEN = os.getenv("AUTH_TOKEN", None) | |
if not API_URL or not AUTH_TOKEN: | |
raise ValueError("API_URL and AUTH_TOKEN secrets must be set in the environment variables.") | |
def check_if_input_is_valid(input_str: str) -> bool: | |
"""Check if the input string is valid for the API.""" | |
response = requests.post( | |
f"{API_URL}/check-input", | |
headers={"Authorization": f"{AUTH_TOKEN}"}, | |
json={"input": input_str}, | |
) | |
if response.status_code == 200: | |
return response.json()["output"] | |
else: | |
return None | |