Skip to content

Commit f2ad0d7

Browse files
agu-zmgsloanprobably-neb
authored
zeta cli: Print log paths when running predict (zed-industries#42396)
Release Notes: - N/A Co-authored-by: Michael Sloan <mgsloan@gmail.com> Co-authored-by: Ben Kunkle <ben@zed.dev>
1 parent 777b465 commit f2ad0d7

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

crates/zeta_cli/src/paths.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,11 @@ pub static CACHE_DIR: LazyLock<PathBuf> =
66
pub static REPOS_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_DIR.join("zeta-repos"));
77
pub static WORKTREES_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_DIR.join("zeta-worktrees"));
88
pub static LOGS_DIR: LazyLock<PathBuf> = LazyLock::new(|| TARGET_DIR.join("zeta-logs"));
9+
pub static LOGS_SEARCH_PROMPT: LazyLock<PathBuf> =
10+
LazyLock::new(|| LOGS_DIR.join("search_prompt.md"));
11+
pub static LOGS_SEARCH_QUERIES: LazyLock<PathBuf> =
12+
LazyLock::new(|| LOGS_DIR.join("search_queries.json"));
13+
pub static LOGS_PREDICTION_PROMPT: LazyLock<PathBuf> =
14+
LazyLock::new(|| LOGS_DIR.join("prediction_prompt.md"));
15+
pub static LOGS_PREDICTION_RESPONSE: LazyLock<PathBuf> =
16+
LazyLock::new(|| LOGS_DIR.join("prediction_response.md"));

crates/zeta_cli/src/predict.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
use crate::PromptFormat;
22
use crate::example::{ActualExcerpt, ExpectedExcerpt, NamedExample};
33
use crate::headless::ZetaCliAppState;
4-
use crate::paths::{CACHE_DIR, LOGS_DIR};
4+
use crate::paths::{
5+
CACHE_DIR, LOGS_DIR, LOGS_PREDICTION_PROMPT, LOGS_PREDICTION_RESPONSE, LOGS_SEARCH_PROMPT,
6+
LOGS_SEARCH_QUERIES,
7+
};
58
use ::serde::Serialize;
69
use anyhow::{Result, anyhow};
710
use clap::Args;
@@ -61,6 +64,15 @@ pub async fn run_zeta2_predict(
6164
.await
6265
.unwrap();
6366
result.write(args.format, std::io::stdout()).unwrap();
67+
68+
println!("## Logs\n");
69+
println!("Search prompt: {}", LOGS_SEARCH_PROMPT.display());
70+
println!("Search queries: {}", LOGS_SEARCH_QUERIES.display());
71+
println!("Prediction prompt: {}", LOGS_PREDICTION_PROMPT.display());
72+
println!(
73+
"Prediction response: {}",
74+
LOGS_PREDICTION_RESPONSE.display()
75+
);
6476
}
6577

6678
thread_local! {
@@ -147,12 +159,12 @@ pub async fn zeta2_predict(
147159
match event {
148160
zeta2::ZetaDebugInfo::ContextRetrievalStarted(info) => {
149161
start_time = Some(info.timestamp);
150-
fs::write(LOGS_DIR.join("search_prompt.md"), &info.search_prompt)?;
162+
fs::write(&*LOGS_SEARCH_PROMPT, &info.search_prompt)?;
151163
}
152164
zeta2::ZetaDebugInfo::SearchQueriesGenerated(info) => {
153165
search_queries_generated_at = Some(info.timestamp);
154166
fs::write(
155-
LOGS_DIR.join("search_queries.json"),
167+
&*LOGS_SEARCH_QUERIES,
156168
serde_json::to_string_pretty(&info.search_queries).unwrap(),
157169
)?;
158170
}
@@ -164,7 +176,7 @@ pub async fn zeta2_predict(
164176
let prediction_started_at = Instant::now();
165177
start_time.get_or_insert(prediction_started_at);
166178
fs::write(
167-
LOGS_DIR.join("prediction_prompt.md"),
179+
&*LOGS_PREDICTION_PROMPT,
168180
&request.local_prompt.unwrap_or_default(),
169181
)?;
170182

@@ -198,7 +210,7 @@ pub async fn zeta2_predict(
198210
let response = request.response_rx.await?.0.map_err(|err| anyhow!(err))?;
199211
let response = zeta2::text_from_response(response).unwrap_or_default();
200212
let prediction_finished_at = Instant::now();
201-
fs::write(LOGS_DIR.join("prediction_response.md"), &response)?;
213+
fs::write(&*LOGS_PREDICTION_RESPONSE, &response)?;
202214

203215
let mut result = result.lock().unwrap();
204216

0 commit comments

Comments
 (0)