chore: quick return for empty runtime key

This commit is contained in:
iff 2024-11-20 08:47:58 +01:00
parent d1b42d1c59
commit e15ff2d2b4
2 changed files with 8 additions and 3 deletions

View file

@ -185,7 +185,7 @@ If it's useful to you, **please share this project and spread the word**. Also c
> Configuration is done via environment variables: > Configuration is done via environment variables:
> >
> - `_PR_AI_API_KEY`: You own API key > - `_PR_AI_API_KEY`: You own API key. Set it to an empty value disables AI integration
> - `_PR_AI_URL`: URL used. Defaults to `https://api.groq.com/openai/v1/chat/completions` > - `_PR_AI_URL`: URL used. Defaults to `https://api.groq.com/openai/v1/chat/completions`
> - `_PR_AI_MODEL`: Model used. Defaults to `llama3-8b-8192` > - `_PR_AI_MODEL`: Model used. Defaults to `llama3-8b-8192`
> >

View file

@ -50,7 +50,12 @@ pub fn ai_suggestion(last_command: &str, error_msg: &str) -> Option<AISuggest> {
}; };
let api_key = match api_key { let api_key = match api_key {
Some(key) => key, Some(key) => {
if key.is_empty() {
return None;
}
key
}
None => { None => {
return None; return None;
} }
@ -81,7 +86,7 @@ You run the command `{last_command}` and get the following error message: `{erro
``` ```
{{"command":"your suggestion","note":"why you think this command will fix the error"}} {{"command":"your suggestion","note":"why you think this command will fix the error"}}
``` ```
{set_locale}If you don't know the answer or can't provide a good suggestion, please reply the command field with `None` and a explanation in note {set_locale}If you can't provide a good suggestion, please reply the command field with `None` and a explanation in note
"# "#
); );