chore: cleanup

This commit is contained in:
iff 2025-04-10 17:42:01 +02:00
parent f9b8ee44f2
commit 49dcbea59e
2 changed files with 11 additions and 12 deletions

View file

@ -7,13 +7,13 @@ Module for [pay-respects](https://codeberg.org/iff/pay-respects) to request AI f
Configuration is done via environment variables: Configuration is done via environment variables:
- `_PR_AI_API_KEY`: Your own API key - `_PR_AI_API_KEY`: Your own API key
- `_PR_AI_URL`: URL used. Any OpenAI compatible URL can be used, e.g.: - `_PR_AI_URL`: Any OpenAI compatible URL can be used, e.g.:
- `https://api.openai.com/v1/chat/completions` (Note: OpenAI's ChatGPT is very slow) - `https://api.openai.com/v1/chat/completions`: OpenAI ChatGPT
- `https://api.groq.com/openai/v1/chat/completions` - `https://api.groq.com/openai/v1/chat/completions`: GroqCloud
- `http://localhost:11434/api/chat`: Ollama - `http://localhost:11434/api/chat`: Local Ollama
- `_PR_AI_MODEL`: Model used. Reasoning models are also supported - `_PR_AI_MODEL`: Model used. Reasoning models are also supported
- `_PR_AI_DISABLE`: Setting to any value disables AI integration - `_PR_AI_DISABLE`: Setting to any value disables AI integration
- `_PR_AI_LOCALE`: Locale in which the AI explains the suggestion. Defaults to user system locale - `_PR_AI_LOCALE`: Locale in which the AI explains the suggestion. Defaults to user system locale. Useful when you use small models that speak only English, for example.
- `_PR_AI_ADDITIONAL_PROMPT`: Additional prompts to be included. (Yes, you can include role-playing prompts you pervert) - `_PR_AI_ADDITIONAL_PROMPT`: Additional prompts to be included. (Yes, you can include role-playing prompts you pervert)
- `User's environment is Zsh running in Arch Linux.` - `User's environment is Zsh running in Arch Linux.`
- `You are a cute catgirl. Always use cute phrases and expressions to prove your cuteness in the <note> section, including cat imitations like nya~, にゃ~, 喵~.` - `You are a cute catgirl. Always use cute phrases and expressions to prove your cuteness in the <note> section, including cat imitations like nya~, にゃ~, 喵~.`

View file

@ -28,6 +28,12 @@ async fn main() -> Result<(), std::io::Error> {
if std::env::var("_PR_AI_DISABLE").is_ok() { if std::env::var("_PR_AI_DISABLE").is_ok() {
return Ok(()); return Ok(());
} }
let mode = std::env::var("_PR_MODE");
if let Ok(mode) = mode {
if mode.as_str() == "noconfirm" {
return Ok(());
}
}
let locale = { let locale = {
let sys_locale = get_locale().unwrap_or("en-US".to_string()); let sys_locale = get_locale().unwrap_or("en-US".to_string());
@ -39,13 +45,6 @@ async fn main() -> Result<(), std::io::Error> {
}; };
rust_i18n::set_locale(&locale[0..2]); rust_i18n::set_locale(&locale[0..2]);
let mode = std::env::var("_PR_MODE");
if let Ok(mode) = mode {
if mode.as_str() == "noconfirm" {
return Ok(());
}
}
let command = std::env::var("_PR_LAST_COMMAND").expect("_PR_LAST_COMMAND not set"); let command = std::env::var("_PR_LAST_COMMAND").expect("_PR_LAST_COMMAND not set");
let error = std::env::var("_PR_ERROR_MSG").expect("_PR_ERROR_MSG not set"); let error = std::env::var("_PR_ERROR_MSG").expect("_PR_ERROR_MSG not set");
colored::control::set_override(true); colored::control::set_override(true);