This repository was archived by the owner on Aug 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path__init__.py
More file actions
46 lines (39 loc) · 1.48 KB
/
__init__.py
File metadata and controls
46 lines (39 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import logging
import os
base_url = None
api_key = None
__version__ = "1.1.0"
log_level = os.getenv("LOG_LEVEL", "INFO")
logger = logging.getLogger(name="OxAPI")
logger.setLevel(level=log_level)
try:
api_key = os.environ["OXAPI_KEY"]
except KeyError:
logger.warning(
msg="API Key not found in environment variable 'OXAPI_KEY', you should set it manually"
)
from requests import RequestException as _RequestException
from requests import get as _init_get
try:
location = _init_get("https://ipinfo.io")
if location.status_code == 200:
location = location.json()
if "country" not in location:
logger.warning(msg="Unable to perform location check.")
elif location["country"] != "US":
logger.warning(
msg="You are querying our API outside of the US. This results in significantly degraded performance."
)
else:
logger.info("Querying from within the US. Enjoy the service!")
except _RequestException:
logger.warning(msg="Unable to perform location check.")
from oxapi.asynch import AsyncCallPipe
from oxapi.config import default_api_version, default_model_version
from oxapi.nlp.classification import Classification
from oxapi.nlp.completion import Completion
from oxapi.nlp.encoding import Encoding
from oxapi.nlp.pipeline import Pipeline
from oxapi.nlp.transformation import Transformation
default_api_version: str = default_api_version
default_model_version: str = default_model_version