Skip to content

Commit

Permalink
v1.4.1: longer default timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
efugier committed Jul 29, 2024
1 parent 84eb58e commit 24d8d66
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "smartcat"
version = "1.4.0"
version = "1.4.1"
authors = ["Emilien Fugier <[email protected]>"]
description = '''
Putting a brain behind `cat`.
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Three files are used:
[ollama] # local API, no key required
url = "http://localhost:11434/api/chat"
default_model = "phi3"
timeout_seconds = 30
timeout_seconds = 180 # default timeout if not specified

[openai] # each supported api has their own config section with api and url
api_key = "<your_api_key>"
Expand Down Expand Up @@ -361,12 +361,14 @@ sc test -v -c src/**/*

The recording is then sent to a speech to text model, the resulting transcript is finally added to the prompt and sent to the text model to get an answer.

On linux:
On Mac:
On windows:
On linux: TODO
On Mac: TODO
On windows: TODO

To debug, you can check the `conversation.toml` file or listen to the `audio.wav` in the smart config home and see what the model heard and transcripted.

This feature shoud be offered as an extra down the road, totally optional on install. PRs are welcomed!


## How to help?

Expand Down
21 changes: 14 additions & 7 deletions src/config/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ pub struct ApiConfig {
pub default_model: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout_seconds: Option<u16>,
#[serde(
default = "default_timeout_seconds",
skip_serializing_if = "Option::is_none"
)]
pub timeout_seconds: Option<u32>,
}

pub(super) fn default_timeout_seconds() -> Option<u32> {
Some(180)
}

impl Default for ApiConfig {
Expand Down Expand Up @@ -103,7 +110,7 @@ impl ApiConfig {
url: String::from("http://localhost:11434/api/chat"),
default_model: Some(String::from("phi3")),
version: None,
timeout_seconds: Some(30),
timeout_seconds: Some(180),
}
}

Expand All @@ -114,7 +121,7 @@ impl ApiConfig {
url: String::from("https://api.openai.com/v1/chat/completions"),
default_model: Some(String::from("gpt-4")),
version: None,
timeout_seconds: Some(30),
timeout_seconds: None,
}
}

Expand All @@ -125,7 +132,7 @@ impl ApiConfig {
url: String::from("https://api.mistral.ai/v1/chat/completions"),
default_model: Some(String::from("mistral-medium")),
version: None,
timeout_seconds: Some(30),
timeout_seconds: None,
}
}

Expand All @@ -136,7 +143,7 @@ impl ApiConfig {
url: String::from("https://api.groq.com/openai/v1/chat/completions"),
default_model: Some(String::from("llama3-70b-8192")),
version: None,
timeout_seconds: Some(30),
timeout_seconds: None,
}
}

Expand All @@ -147,7 +154,7 @@ impl ApiConfig {
url: String::from("https://api.anthropic.com/v1/messages"),
default_model: Some(String::from("claude-3-opus-20240229")),
version: Some(String::from("2023-06-01")),
timeout_seconds: Some(30),
timeout_seconds: None,
}
}
}
Expand Down
35 changes: 16 additions & 19 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn is_executable_in_path(executable_name: &str) -> bool {
mod tests {
use crate::{
config::{
api::{api_keys_path, Api, ApiConfig},
api::{api_keys_path, default_timeout_seconds, Api, ApiConfig},
ensure_config_files,
prompt::{prompts_path, Prompt},
resolve_config_path,
Expand Down Expand Up @@ -293,24 +293,21 @@ mod tests {
// Check if the content matches the default values

// API
assert_eq!(
api_config.get(&Prompt::default().api.to_string()),
Some(&ApiConfig::default())
);
assert_eq!(
api_config.get(&Api::Mistral.to_string()),
Some(&ApiConfig::mistral())
);

assert_eq!(
api_config.get(&Api::Groq.to_string()),
Some(&ApiConfig::groq())
);

assert_eq!(
api_config.get(&Api::Anthropic.to_string()),
Some(&ApiConfig::anthropic())
);
for (api, expected_config) in [
(Prompt::default().api.to_string(), ApiConfig::default()),
(Api::Mistral.to_string(), ApiConfig::mistral()),
(Api::Groq.to_string(), ApiConfig::groq()),
(Api::Anthropic.to_string(), ApiConfig::anthropic()),
] {
let config = api_config.get(&api).unwrap();
assert_eq!(
ApiConfig {
timeout_seconds: default_timeout_seconds(),
..expected_config
},
*config
);
}

// Prompts
let default_prompt = Prompt::default();
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const DEFAULT_PROMPT_NAME: &str = "default";
#[command(
name = "smartcat (sc)",
author = "Emilien Fugier",
version = "1.4.0",
version = "1.4.1",
about = "Putting a brain behind `cat`. CLI interface to bring language models in the Unix ecosystem 🐈‍⬛",
long_about = None,
after_help = "Examples:
Expand Down

0 comments on commit 24d8d66

Please sign in to comment.