Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ai-test): add --no-subscription flag #413

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions ai-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <PATH>
-o, --out <OUT>
-h, --help Print help
-p, --path <PATH> Path to YAML file with list of lists (initial question + follow-up questions)
-o, --out <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):
Expand Down
4 changes: 3 additions & 1 deletion ai-test/src/ai_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ impl Storage {
pub async fn ai_help_all(
path: Option<impl AsRef<Path>>,
out: impl AsRef<Path>,
no_subscription: bool,
) -> Result<(), Error> {
let out = &out;
std::fs::create_dir_all(out)?;
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions ai-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PathBuf>,
/// Path to directory to write the test results as `1.json`, `1.md`, etc.
#[arg(short, long)]
out: Option<PathBuf>,
/// Perform test as free Core user without subscription.
#[arg(long, action)]
no_subscription: bool,
},
}

Expand All @@ -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(())
Expand Down
Loading