upd err handler

This commit is contained in:
kosarevskiydp 2023-03-07 09:15:58 +03:00
parent ccbe345bd2
commit c2c254be4d
2 changed files with 3 additions and 6 deletions

View File

@ -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)

View File

@ -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