barunsaha commited on
Commit
4bd6659
1 Parent(s): 437156d

Increase LLM request timeout

Browse files
Files changed (1) hide show
  1. helpers/llm_helper.py +7 -1
helpers/llm_helper.py CHANGED
@@ -11,6 +11,7 @@ from global_config import GlobalConfig
11
 
12
  HF_API_URL = f"https://api-inference.huggingface.co/models/{GlobalConfig.HF_LLM_MODEL_NAME}"
13
  HF_API_HEADERS = {"Authorization": f"Bearer {GlobalConfig.HUGGINGFACEHUB_API_TOKEN}"}
 
14
 
15
  logger = logging.getLogger(__name__)
16
 
@@ -59,7 +60,12 @@ def hf_api_query(payload: dict) -> dict:
59
  """
60
 
61
  try:
62
- response = http_session.post(HF_API_URL, headers=HF_API_HEADERS, json=payload, timeout=15)
 
 
 
 
 
63
  result = response.json()
64
  except requests.exceptions.Timeout as te:
65
  logger.error('*** Error: hf_api_query timeout! %s', str(te))
 
11
 
12
  HF_API_URL = f"https://api-inference.huggingface.co/models/{GlobalConfig.HF_LLM_MODEL_NAME}"
13
  HF_API_HEADERS = {"Authorization": f"Bearer {GlobalConfig.HUGGINGFACEHUB_API_TOKEN}"}
14
+ REQUEST_TIMEOUT = 35
15
 
16
  logger = logging.getLogger(__name__)
17
 
 
60
  """
61
 
62
  try:
63
+ response = http_session.post(
64
+ HF_API_URL,
65
+ headers=HF_API_HEADERS,
66
+ json=payload,
67
+ timeout=REQUEST_TIMEOUT
68
+ )
69
  result = response.json()
70
  except requests.exceptions.Timeout as te:
71
  logger.error('*** Error: hf_api_query timeout! %s', str(te))