diff --git a/ai-test/README.md b/ai-test/README.md index 0c128f91..860c48db 100644 --- a/ai-test/README.md +++ b/ai-test/README.md @@ -10,9 +10,10 @@ To understand how this tool works, run: `cargo run -p ai-test -- test --help` Usage: ai-test test [OPTIONS] Options: - -p, --path - -o, --out - -h, --help Print help + -p, --path Path to YAML file with list of lists (initial question + follow-up questions) + -o, --out Path to directory to write the test results as `1.json`, `1.md`, etc + --no-subscription Perform test as free Core user without subscription + -h, --help Print help ``` For example, to request answers for all questions in the [prompts.yaml](./data/prompts.yaml) file, run (from the repository root): diff --git a/ai-test/src/ai_help.rs b/ai-test/src/ai_help.rs index c07bc4aa..08456f1a 100644 --- a/ai-test/src/ai_help.rs +++ b/ai-test/src/ai_help.rs @@ -65,6 +65,7 @@ impl Storage { pub async fn ai_help_all( path: Option>, out: impl AsRef, + no_subscription: bool, ) -> Result<(), Error> { let out = &out; std::fs::create_dir_all(out)?; @@ -96,7 +97,8 @@ pub async fn ai_help_all( }) .collect(); if let Some(req) = - prepare_ai_help_req(openai_client, supabase_pool, true, messages).await? + prepare_ai_help_req(openai_client, supabase_pool, !no_subscription, messages) + .await? { let mut res = openai_client.chat().create(req.req.clone()).await?; let res = res.choices.pop().map(|res| res.message); diff --git a/ai-test/src/main.rs b/ai-test/src/main.rs index a369e613..e72dc404 100644 --- a/ai-test/src/main.rs +++ b/ai-test/src/main.rs @@ -22,10 +22,15 @@ struct Cli { #[derive(Subcommand)] enum Commands { Test { + /// Path to YAML file with list of lists (initial question + follow-up questions). #[arg(short, long)] path: Option, + /// Path to directory to write the test results as `1.json`, `1.md`, etc. #[arg(short, long)] out: Option, + /// Perform test as free Core user without subscription. + #[arg(long, action)] + no_subscription: bool, }, } @@ -39,9 +44,13 @@ async fn main() -> Result<(), Error> { let cli = Cli::parse(); match cli.command { - Commands::Test { path, out } => { + Commands::Test { + path, + out, + no_subscription, + } => { let out = out.unwrap_or_else(|| PathBuf::from("/tmp/test")); - ai_help_all(path, out).await?; + ai_help_all(path, out, no_subscription).await?; } } Ok(())