Skip to content

Commit

Permalink
describegpt: rename QSV_OPENAI_KEY env var to QSV_LLM_APIKEY
Browse files Browse the repository at this point in the history
as describegpt can now support other LLMs including local ones

[skip ci]
  • Loading branch information
jqnatividad committed Apr 20, 2024
1 parent be6a9c5 commit 5b6c586
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/ENVIRONMENT_VARIABLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| `QSV_COMMENT_CHAR` | set to an ascii character. If set, any lines(including the header) that start with this character are ignored. |
| `QSV_MAX_JOBS` | number of jobs to use for multithreaded commands (currently `apply`, `applydp`, `dedup`, `diff`, `extsort`, `frequency`, `joinp`, `schema`, `snappy`, `sort`, `split`, `stats`, `to`, `tojsonl` & `validate`). If not set, max_jobs is set to the detected number of logical processors. See [Multithreading](docs/PERFORMANCE.md#multithreading) for more info. |
| `QSV_NO_UPDATE` | if set, prohibit self-update version check for the latest qsv release published on GitHub. |
| `QSV_OPENAI_KEY` | The OpenAI API key to use with the `describegpt` command. |
| `QSV_LLM_APIKEY` | The API key of the supported LLM service to use with the `describegpt` command. |
| `QSV_OUTPUT_BOM` | if set, the output will have a Byte Order Mark (BOM) at the beginning. This is
used to generate Excel-friendly CSVs on Windows. |
| `QSV_PREFER_DMY` | if set, date parsing will use DMY format. Otherwise, use MDY format (used with `datefmt`, `schema`, `sniff` & `stats` commands). |
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/describegpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describegpt options:
--tags Prints tags that categorize the dataset. Useful
for grouping datasets and filtering.
--api-key <key> The API key to use. If using Ollama, set the key to ollama.
If the QSV_OPENAI_KEY envvar is set, it will be used instead.
If the QSV_LLM_APIKEY envvar is set, it will be used instead.
--max-tokens <value> Limits the number of generated tokens in the output.
[default: 50]
--json Return results in JSON format.
Expand Down Expand Up @@ -92,7 +92,7 @@ struct PromptFile {
jsonl: bool,
}

const OPENAI_KEY_ERROR: &str = "Error: QSV_OPENAI_KEY environment variable not found.\nNote that \
const OPENAI_KEY_ERROR: &str = "Error: QSV_LLM_APIKEY environment variable not found.\nNote that \
this command uses LLMs for inferencing and is therefore prone to \
inaccurate information being produced. Verify output results \
before using them.";
Expand Down Expand Up @@ -565,11 +565,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
// Closure to check if the user gives an argument
let arg_is_some = |arg: &str| -> bool { argv.contains(&arg) };

// Check for QSV_OPENAI_KEY in environment variables
let api_key = match env::var("QSV_OPENAI_KEY") {
// Check for QSV_LLM_APIKEY in environment variables
let api_key = match env::var("QSV_LLM_APIKEY") {
Ok(val) => {
if val.is_empty() {
return fail!("Error: QSV_OPENAI_KEY environment variable is empty.");
return fail!("Error: QSV_LLM_APIKEY environment variable is empty.");
}
val
},
Expand Down

0 comments on commit 5b6c586

Please sign in to comment.