upd err handler
This commit is contained in:
parent
ccbe345bd2
commit
c2c254be4d
4
chat.py
4
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)
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user