Skip to content

Commit

Permalink
forgot clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Unischneider committed Nov 7, 2024
1 parent e281a2b commit b5dbf78
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions app/email_classification/response_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def __init__(self):
self.angelos_url = config.ANGELOS_URI
self.port = config.ANGELOS_PORT
self.api_url = f"{self.angelos_url}:{self.port}/api/v1/question/ask"
self.token_url = f"{self.angelos_url}:{self.port}/api/token"
self.session = requests.Session()
self.api_key = config.ANGELOS_APP_API_KEY
self._set_authorization_header()
Expand All @@ -25,19 +24,7 @@ def get_response(self, payload):
logging.info(f"Sending POST request to {self.api_url}")
response = self.session.post(self.api_url, json=payload, headers=self.headers)
response.raise_for_status()
logging.info(f"Request succeeded with status code: {response.status_code}")
return response.json()

except requests.HTTPError as http_err:
if response.status_code == 401:
logging.warning("Token expired or invalid. Re-authenticating.")
self._request_token()
response = self.session.post(self.api_url, json=payload, headers=self.headers)
response.raise_for_status()
return response.json()
else:
logging.error(f"HTTP error occurred: {http_err}")
raise
except Exception as err:
logging.error(f"An error occurred: {err}")
raise

0 comments on commit b5dbf78

Please sign in to comment.