Skip to content

Commit

Permalink
switching gpt model, making 429s hard stop
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDietzMorris committed Oct 24, 2024
1 parent 723651e commit 6b6f999
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions parsers/LitCoin/src/bagel/bagel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

# output of parse_gpt looks like {"entity": triple["object"], "qualifier": triple["object_qualifier"]}
session = requests.Session()
retries = Retry(total=8,
backoff_factor=.75,
retries = Retry(total=6,
backoff_factor=1,
status_forcelist=[502, 503, 504, 520, 429])
session.mount('http://', HTTPAdapter(max_retries=retries))
session.mount('https://', HTTPAdapter(max_retries=retries))
Expand Down
2 changes: 1 addition & 1 deletion parsers/LitCoin/src/bagel/bagel_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def query(prompt, requests_session):
}

payload = {
"model": "gpt-4-0125-preview",
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
Expand Down
10 changes: 8 additions & 2 deletions parsers/LitCoin/src/loadLitCoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
import json

import requests.exceptions

from Common.biolink_utils import BiolinkUtils
from Common.loader_interface import SourceDataLoader
from Common.biolink_constants import PUBLICATIONS
Expand Down Expand Up @@ -216,10 +218,12 @@ def parse_data(self) -> dict:
abstract_id=abstract_id)
self.bagel_results_lookup[subject_name] = bagel_results
bagelized_success += 1
except Exception as e:
except requests.exceptions.HTTPError as e:
self.logger.error(f'Failed Bagelization: {type(e)}:{e}')
skipped_records += 1
bagelization_errors += 1
if e.response.status_code == 429:
raise e
continue
else:
bagel_results = self.bagel_results_lookup[subject_name]
Expand All @@ -246,10 +250,12 @@ def parse_data(self) -> dict:
abstract_id=abstract_id)
self.bagel_results_lookup[object_name] = bagel_results
bagelized_success += 1
except Exception as e:
except requests.exceptions.HTTPError as e:
self.logger.error(f'Failed Bagelization: {type(e)}:{e}')
skipped_records += 1
bagelization_errors += 1
if e.response.status_code == 429:
raise e
continue
else:
bagel_results = self.bagel_results_lookup[object_name]
Expand Down

0 comments on commit 6b6f999

Please sign in to comment.