mattoofahad commited on
Commit
55bd385
·
1 Parent(s): bc3c799

resolving linting error

Browse files
Files changed (1) hide show
  1. src/utils/openai_utils.py +21 -22
src/utils/openai_utils.py CHANGED
@@ -59,25 +59,24 @@ class OpenAIFunctions:
59
  if st.session_state.provider_select == "lm-studio":
60
  logger.info("Local Provider is Sekected")
61
  return True
62
- else:
63
- logger.info("Checking OpenAI Key")
64
- try:
65
- client = OpenAI(api_key=st.session_state.openai_api_key)
66
- client.models.list()
67
- logger.debug("OpenAI key Working")
68
- return True
69
- except openai.AuthenticationError as auth_error:
70
- with st.chat_message("assistant"):
71
- st.error(str(auth_error))
72
- logger.error("AuthenticationError: %s", auth_error)
73
- return False
74
- except openai.OpenAIError as openai_error:
75
- with st.chat_message("assistant"):
76
- st.error(str(openai_error))
77
- logger.error("OpenAIError: %s", openai_error)
78
- return False
79
- except Exception as general_error:
80
- with st.chat_message("assistant"):
81
- st.error(str(general_error))
82
- logger.error("Unexpected error: %s", general_error)
83
- return False
 
59
  if st.session_state.provider_select == "lm-studio":
60
  logger.info("Local Provider is Sekected")
61
  return True
62
+ logger.info("Checking OpenAI Key")
63
+ try:
64
+ client = OpenAI(api_key=st.session_state.openai_api_key)
65
+ client.models.list()
66
+ logger.debug("OpenAI key Working")
67
+ return True
68
+ except openai.AuthenticationError as auth_error:
69
+ with st.chat_message("assistant"):
70
+ st.error(str(auth_error))
71
+ logger.error("AuthenticationError: %s", auth_error)
72
+ return False
73
+ except openai.OpenAIError as openai_error:
74
+ with st.chat_message("assistant"):
75
+ st.error(str(openai_error))
76
+ logger.error("OpenAIError: %s", openai_error)
77
+ return False
78
+ except Exception as general_error:
79
+ with st.chat_message("assistant"):
80
+ st.error(str(general_error))
81
+ logger.error("Unexpected error: %s", general_error)
82
+ return False