eval: Add support for reading from a .env
file (#29426)
This PR adds support for the eval to read environment variables from a `.env` file located in the `crates/eval` directory. For instance, you can use it to set your Anthropic API key: ``` ANTHROPIC_API_KEY=<secret> ``` Release Notes: - N/A
This commit is contained in:
parent
4f9cadabf7
commit
a5405fcbd7
6 changed files with 18 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -32,4 +32,5 @@ Packages
|
||||||
xcuserdata/
|
xcuserdata/
|
||||||
|
|
||||||
# Don't commit any secrets to the repo.
|
# Don't commit any secrets to the repo.
|
||||||
|
.env
|
||||||
.env.secret.toml
|
.env.secret.toml
|
||||||
|
|
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -4548,6 +4548,12 @@ dependencies = [
|
||||||
"syn 2.0.100",
|
"syn 2.0.100",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dotenv"
|
||||||
|
version = "0.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dotenvy"
|
name = "dotenvy"
|
||||||
version = "0.15.7"
|
version = "0.15.7"
|
||||||
|
@ -4970,6 +4976,7 @@ dependencies = [
|
||||||
"collections",
|
"collections",
|
||||||
"context_server",
|
"context_server",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
|
"dotenv",
|
||||||
"env_logger 0.11.8",
|
"env_logger 0.11.8",
|
||||||
"extension",
|
"extension",
|
||||||
"fs",
|
"fs",
|
||||||
|
|
|
@ -437,6 +437,7 @@ dashmap = "6.0"
|
||||||
dap-types = { git = "https://github.com/zed-industries/dap-types", rev = "be69a016ba710191b9fdded28c8b042af4b617f7" }
|
dap-types = { git = "https://github.com/zed-industries/dap-types", rev = "be69a016ba710191b9fdded28c8b042af4b617f7" }
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
dirs = "4.0"
|
dirs = "4.0"
|
||||||
|
dotenv = "0.15.0"
|
||||||
ec4rs = "1.1"
|
ec4rs = "1.1"
|
||||||
emojis = "0.6.1"
|
emojis = "0.6.1"
|
||||||
env_logger = "0.11"
|
env_logger = "0.11"
|
||||||
|
|
|
@ -19,6 +19,7 @@ client.workspace = true
|
||||||
collections.workspace = true
|
collections.workspace = true
|
||||||
context_server.workspace = true
|
context_server.workspace = true
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
|
dotenv.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
extension.workspace = true
|
extension.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
|
|
|
@ -6,6 +6,8 @@ This eval assumes the working directory is the root of the repository. Run it wi
|
||||||
cargo run -p eval
|
cargo run -p eval
|
||||||
```
|
```
|
||||||
|
|
||||||
|
The eval will optionally read a `.env` file in `crates/eval` if you need it to set environment variables, such as API keys.
|
||||||
|
|
||||||
## Explorer Tool
|
## Explorer Tool
|
||||||
|
|
||||||
The explorer tool generates a self-contained HTML view from one or more thread
|
The explorer tool generates a self-contained HTML view from one or more thread
|
||||||
|
|
|
@ -34,9 +34,12 @@ use std::collections::VecDeque;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, LazyLock};
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
|
|
||||||
|
static CARGO_MANIFEST_DIR: LazyLock<PathBuf> =
|
||||||
|
LazyLock::new(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")));
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(name = "eval", disable_version_flag = true)]
|
#[command(name = "eval", disable_version_flag = true)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
@ -57,6 +60,8 @@ struct Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
dotenv::from_filename(CARGO_MANIFEST_DIR.join(".env")).ok();
|
||||||
|
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let system_id = ids::get_or_create_id(&ids::eval_system_id_path()).ok();
|
let system_id = ids::get_or_create_id(&ids::eval_system_id_path()).ok();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue