olaf-bu commited on
Commit
969710e
·
1 Parent(s): 4220176

fixed typo; change exception sequence in app.py (according pylint)

Browse files
Files changed (3) hide show
  1. agent.py +1 -1
  2. app.py +3 -3
  3. model.py +3 -3
agent.py CHANGED
@@ -56,6 +56,6 @@ class Agent:
56
  """
57
  logger.debug('question is [%s]', question)
58
  answer = self.agent.run(self.prompt.format(question=question, context=file_path))
59
- looger.debug('got answer [%s]', answer)
60
  answer = str(answer).strip("'").strip('"').strip()
61
  return answer
 
56
  """
57
  logger.debug('question is [%s]', question)
58
  answer = self.agent.run(self.prompt.format(question=question, context=file_path))
59
+ logger.debug('got answer [%s]', answer)
60
  answer = str(answer).strip("'").strip('"').strip()
61
  return answer
app.py CHANGED
@@ -68,13 +68,13 @@ def run_and_submit_all(profile: Optional[gr.OAuthProfile]):
68
  print('Fetched questions list is empty.')
69
  return 'Fetched questions list is empty or invalid format.', None
70
  print(f'Fetched {len(questions_data)} questions.')
71
- except requests.exceptions.RequestException as e:
72
- print(f'Error fetching questions: {e}')
73
- return f'Error fetching questions: {e}', None
74
  except requests.exceptions.JSONDecodeError as e:
75
  print(f'Error decoding JSON response from questions endpoint: {e}')
76
  print(f'Response text: {response.text[:500]}')
77
  return f'Error decoding server response for questions: {e}', None
 
 
 
78
  except Exception as e:
79
  print(f'An unexpected error occurred fetching questions: {e}')
80
  return f'An unexpected error occurred fetching questions: {e}', None
 
68
  print('Fetched questions list is empty.')
69
  return 'Fetched questions list is empty or invalid format.', None
70
  print(f'Fetched {len(questions_data)} questions.')
 
 
 
71
  except requests.exceptions.JSONDecodeError as e:
72
  print(f'Error decoding JSON response from questions endpoint: {e}')
73
  print(f'Response text: {response.text[:500]}')
74
  return f'Error decoding server response for questions: {e}', None
75
+ except requests.exceptions.RequestException as e:
76
+ print(f'Error fetching questions: {e}')
77
+ return f'Error fetching questions: {e}', None
78
  except Exception as e:
79
  print(f'An unexpected error occurred fetching questions: {e}')
80
  return f'An unexpected error occurred fetching questions: {e}', None
model.py CHANGED
@@ -25,7 +25,7 @@ def get_huggingface_api_model(model_id: str, **kwargs) -> HfApiModel:
25
  logger.warning('HUGGINGFACEHUB_API_TOKEN not in environment')
26
  api_key = os.getenv('HF_TOKEN')
27
  if not api_key:
28
- looger.error('no API Token for huggingface')
29
  raise ValueError('neither HUGGINGFACEHUB_API_TOKEN nor HF_TOKEN is set')
30
  logger.info('using env-var "HF_TOKEN" for Huggingface access')
31
 
@@ -48,7 +48,7 @@ def get_inference_client_model(model_id: str, **kwargs) -> InferenceClientModel:
48
  logger.warning('HUGGINGFACEHUB_API_TOKEN not in environment')
49
  api_key = os.getenv('HF_TOKEN')
50
  if not api_key:
51
- looger.error('no API Token for huggingface')
52
  raise ValueError('neither HUGGINGFACEHUB_API_TOKEN nor HF_TOKEN is set')
53
  logger.info('using env-var "HF_TOKEN" for Huggingface access')
54
 
@@ -68,7 +68,7 @@ def get_openai_server_model(model_id: str, **kwargs) -> OpenAIServerModel:
68
  """
69
  api_key = os.getenv('OPENAI_API_KEY')
70
  if not api_key:
71
- looger.error('no API Token for openAI')
72
  raise ValueError('OPENAI_API_KEY is not set')
73
 
74
  api_base = os.getenv('OPENAI_API_BASE') # ?? should it silently default to https://api.openai.com/v1/ ?
 
25
  logger.warning('HUGGINGFACEHUB_API_TOKEN not in environment')
26
  api_key = os.getenv('HF_TOKEN')
27
  if not api_key:
28
+ logger.error('no API Token for huggingface')
29
  raise ValueError('neither HUGGINGFACEHUB_API_TOKEN nor HF_TOKEN is set')
30
  logger.info('using env-var "HF_TOKEN" for Huggingface access')
31
 
 
48
  logger.warning('HUGGINGFACEHUB_API_TOKEN not in environment')
49
  api_key = os.getenv('HF_TOKEN')
50
  if not api_key:
51
+ logger.error('no API Token for huggingface')
52
  raise ValueError('neither HUGGINGFACEHUB_API_TOKEN nor HF_TOKEN is set')
53
  logger.info('using env-var "HF_TOKEN" for Huggingface access')
54
 
 
68
  """
69
  api_key = os.getenv('OPENAI_API_KEY')
70
  if not api_key:
71
+ logger.error('no API Token for openAI')
72
  raise ValueError('OPENAI_API_KEY is not set')
73
 
74
  api_base = os.getenv('OPENAI_API_BASE') # ?? should it silently default to https://api.openai.com/v1/ ?