rfp-recommendations / services.py
brainsqueeze's picture
First commit
1c6c5d7 verified
raw
history blame
1.41 kB
import os
from common.base.api_base_async import BaseAsyncAPI
from common.base.api_base import BaseAPI
class RfpRecommend(BaseAPI):
def __init__(self):
super().__init__(
url=os.getenv("RFP_RECOMMENDATION_URL"),
headers={"x-api-key": os.getenv("RFP_RECOMMENDATION_API_KEY")},
total_retries=5,
backoff_factor=10
)
def __call__(self, candid_entity_id: int):
results = self.get(candid_entity_id=candid_entity_id)
return results
class Inferencing(BaseAsyncAPI):
def __init__(self):
super().__init__(
url=os.getenv("AUTOCODING_API_URL"),
headers={"x-api-key": os.getenv("AUTOCODING_API_KEY")}
)
async def __call__(self, text: str, taxonomy: str = "pcs",
chunk: bool = False, high_precision: bool = False
):
result = self.post(payload={
"text": text,
"taxonomy": taxonomy,
"chunk": chunk,
"high_precision": high_precision
})
return result
class Entities(BaseAsyncAPI):
def __init__(self):
super().__init__(
url=os.getenv("DOCUMENT_API_URL").replace("/analyze", "/entities"),
headers={"x-api-key": os.getenv("DOCUMENT_API_KEY")}
)
async def __call__(self, text: str):
result = self.post(payload={"text": text})
return result