zeta2 cli: Include section ranges in new full output format (#39203)
Release Notes: - N/A --------- Co-authored-by: Oleksiy Syvokon <oleksiy.syvokon@gmail.com>
This commit is contained in:
co-authored by
Oleksiy Syvokon
parent
35749e99e5
commit
df43a2d3b1
Generated
+1
@@ -3217,6 +3217,7 @@ dependencies = [
|
||||
"indoc",
|
||||
"ordered-float 2.10.1",
|
||||
"rustc-hash 2.1.1",
|
||||
"serde",
|
||||
"strum 0.27.1",
|
||||
"workspace-hack",
|
||||
]
|
||||
|
||||
@@ -17,5 +17,6 @@ cloud_llm_client.workspace = true
|
||||
indoc.workspace = true
|
||||
ordered-float.workspace = true
|
||||
rustc-hash.workspace = true
|
||||
serde.workspace = true
|
||||
strum.workspace = true
|
||||
workspace-hack.workspace = true
|
||||
|
||||
@@ -5,6 +5,7 @@ use cloud_llm_client::predict_edits_v3::{self, Event, PromptFormat, ReferencedDe
|
||||
use indoc::indoc;
|
||||
use ordered_float::OrderedFloat;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde::Serialize;
|
||||
use std::fmt::Write;
|
||||
use std::sync::Arc;
|
||||
use std::{cmp::Reverse, collections::BinaryHeap, ops::Range, path::Path};
|
||||
@@ -75,7 +76,7 @@ pub enum DeclarationStyle {
|
||||
Declaration,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
pub struct SectionLabels {
|
||||
pub excerpt_index: usize,
|
||||
pub section_ranges: Vec<(Arc<Path>, Range<usize>)>,
|
||||
|
||||
@@ -122,7 +122,7 @@ enum OutputFormat {
|
||||
#[default]
|
||||
Prompt,
|
||||
Request,
|
||||
Both,
|
||||
Full,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -299,15 +299,17 @@ async fn get_context(
|
||||
.await?;
|
||||
|
||||
let planned_prompt = cloud_zeta2_prompt::PlannedPrompt::populate(&request)?;
|
||||
let prompt_string = planned_prompt.to_prompt_string()?.0;
|
||||
let (prompt_string, section_labels) = planned_prompt.to_prompt_string()?;
|
||||
|
||||
match zeta2_args.output_format {
|
||||
OutputFormat::Prompt => anyhow::Ok(prompt_string),
|
||||
OutputFormat::Request => {
|
||||
anyhow::Ok(serde_json::to_string_pretty(&request)?)
|
||||
}
|
||||
OutputFormat::Both => anyhow::Ok(serde_json::to_string_pretty(&json!({
|
||||
OutputFormat::Full => anyhow::Ok(serde_json::to_string_pretty(&json!({
|
||||
"request": request,
|
||||
"prompt": prompt_string,
|
||||
"section_labels": section_labels,
|
||||
}))?),
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user