diff --git a/chat.py b/chat.py index 00cf977..47fecee 100644 --- a/chat.py +++ b/chat.py @@ -1,4 +1,4 @@ -from openai.error import AuthenticationError +from openai.error import OpenAIError from pathlib import Path from src.utils.ai import ai_settings, send_ai_request @@ -49,7 +49,7 @@ def main() -> None: with col2: is_speech_slow = speech_speed_radio() show_player(ai_content, lang_code, is_speech_slow) - except AuthenticationError as err: + except OpenAIError as err: st.error(err) diff --git a/src/utils/ai.py b/src/utils/ai.py index e51fa83..2a61ecc 100644 --- a/src/utils/ai.py +++ b/src/utils/ai.py @@ -34,10 +34,7 @@ def send_ai_request(user_text: str, ai_model: str, ai_role: str) -> Dict: model=ai_model, messages=[ {"role": "system", "content": f"You are a {ai_role}."}, - { - "role": "user", - "content": user_text - } + {"role": "user", "content": user_text}, ] ) return completion