Skip to content

Commit

Permalink
zeta: Use DTOs from zed_llm_client crate (#24229)
Browse files Browse the repository at this point in the history
This PR updates the `zeta` crate to use the predictive edit DTOs defined
in the `zed_llm_client` crate.

This way we aren't duplicating their definitions (and risk them going
out of sync).

Release Notes:

- N/A
  • Loading branch information
maxdeviant authored Feb 4, 2025
1 parent d6a2a0b commit b02baea
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ wasmtime = { version = "24", default-features = false, features = [
wasmtime-wasi = "24"
which = "6.0.0"
wit-component = "0.201"
zed_llm_client = "0.1.1"
zstd = "0.11"
metal = "0.31"

Expand Down
15 changes: 0 additions & 15 deletions crates/rpc/src/llm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,3 @@ pub struct PerformCompletionParams {
pub model: String,
pub provider_request: Box<serde_json::value::RawValue>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct PredictEditsParams {
pub outline: Option<String>,
pub input_events: String,
pub input_excerpt: String,
/// Whether the user provided consent for sampling this interaction.
#[serde(default)]
pub can_collect_data: bool,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct PredictEditsResponse {
pub output_excerpt: String,
}
2 changes: 1 addition & 1 deletion crates/zeta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ log.workspace = true
menu.workspace = true
postage.workspace = true
regex.workspace = true
rpc.workspace = true
serde.workspace = true
serde_json.workspace = true
settings.workspace = true
Expand All @@ -52,6 +51,7 @@ uuid.workspace = true
workspace.workspace = true
worktree.workspace = true
zed_actions.workspace = true
zed_llm_client.workspace = true

[dev-dependencies]
collections = { workspace = true, features = ["test-support"] }
Expand Down
8 changes: 4 additions & 4 deletions crates/zeta/src/zeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use language::{
};
use language_models::LlmApiToken;
use postage::watch;
use rpc::{PredictEditsParams, PredictEditsResponse, EXPIRED_LLM_TOKEN_HEADER_NAME};
use settings::WorktreeId;
use std::{
borrow::Cow,
Expand All @@ -47,6 +46,7 @@ use telemetry_events::InlineCompletionRating;
use util::ResultExt;
use uuid::Uuid;
use worktree::Worktree;
use zed_llm_client::{PredictEditsBody, PredictEditsResponse, EXPIRED_LLM_TOKEN_HEADER_NAME};

const CURSOR_MARKER: &'static str = "<|user_cursor_is_here|>";
const START_OF_FILE_MARKER: &'static str = "<|start_of_file|>";
Expand Down Expand Up @@ -369,7 +369,7 @@ impl Zeta {
perform_predict_edits: F,
) -> Task<Result<Option<InlineCompletion>>>
where
F: FnOnce(Arc<Client>, LlmApiToken, bool, PredictEditsParams) -> R + 'static,
F: FnOnce(Arc<Client>, LlmApiToken, bool, PredictEditsBody) -> R + 'static,
R: Future<Output = Result<PredictEditsResponse>> + Send + 'static,
{
let snapshot = self.report_changes_for_buffer(&buffer, cx);
Expand Down Expand Up @@ -425,7 +425,7 @@ impl Zeta {

log::debug!("Events:\n{}\nExcerpt:\n{}", input_events, input_excerpt);

let body = PredictEditsParams {
let body = PredictEditsBody {
input_events: input_events.clone(),
input_excerpt: input_excerpt.clone(),
outline: Some(input_outline.clone()),
Expand Down Expand Up @@ -625,7 +625,7 @@ and then another
client: Arc<Client>,
llm_token: LlmApiToken,
_is_staff: bool,
body: PredictEditsParams,
body: PredictEditsBody,
) -> impl Future<Output = Result<PredictEditsResponse>> {
async move {
let http_client = client.http_client();
Expand Down

0 comments on commit b02baea

Please sign in to comment.