Skip to content

Commit

Permalink
working on response handling from the api
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Chartier committed Sep 20, 2024
1 parent 6c4eae0 commit f073855
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def send_to_api(api_url, bearer_token, model, content):
logging.info(f"Response content: {response.text}")

response.raise_for_status() # Will raise an error for HTTP codes 4xx or 5xx
return response.text.json().get('response', 'No text found in response')
parsed_response = response.json()
logging.info(f"Parsed Response content: {parsed_response}")
return parsed_response.get('response', 'No text found in response')
except requests.exceptions.HTTPError as http_err:
logging.error(f"HTTP error occurred: {http_err}")
logging.error("Please check the API URL, bearer token, and model in the configuration.")
Expand Down

0 comments on commit f073855

Please sign in to comment.