# Objective Part of EP-10 Closes EP-118 - Describe the objective or issue this PR addresses. - If you're fixing a specific issue, use "Fixes #X" for each issue as [described in the GitHub docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword). ## Solution - Describe the solution used to achieve the objective above. ## Testing - Did you test these changes? If so, how? - Are there any parts that need more testing? - How can other people (reviewers) test your changes? Is there anything specific they need to know? - If relevant, what platforms did you test these changes on, and are there any important ones you can't test? ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase > This section is optional. If this PR does not include a visual change or does not add a new user-facing feature, you can delete this section. - Help others understand the result of this PR by showcasing your awesome work! - If this PR includes a visual change, consider adding a screenshot, GIF, or video - A before/after comparison is very useful for changes to existing features! While a showcase should aim to be brief and digestible, you can use a toggleable section to save space on longer showcases: <details> <summary>Click to view showcase</summary> My super cool demos here </details> --- Release Notes: - N/A or Added/Fixed/Improved ... Co-authored-by: Nbarry <nbarry@zed.dev>
75 lines
2.4 KiB
Rust
75 lines
2.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
use std::borrow::Cow;
|
|
use std::ops::Range;
|
|
use strum::{AsRefStr, EnumString};
|
|
|
|
pub const PREDICT_EDITS_MODE_HEADER_NAME: &str = "X-Zed-Predict-Edits-Mode";
|
|
pub const PREDICT_EDITS_REQUEST_ID_HEADER_NAME: &str = "X-Zed-Predict-Edits-Request-Id";
|
|
pub const PREDICT_EDITS_TRIGGER_HEADER_NAME: &str = "X-Zed-Predict-Edits-Trigger";
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, AsRefStr, EnumString)]
|
|
#[serde(rename_all = "snake_case")]
|
|
#[strum(serialize_all = "snake_case")]
|
|
pub enum PredictEditsMode {
|
|
Eager,
|
|
Subtle,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub struct RawCompletionRequest {
|
|
pub model: String,
|
|
pub prompt: String,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub max_tokens: Option<u32>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub temperature: Option<f32>,
|
|
pub stop: Vec<Cow<'static, str>>,
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub environment: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct PredictEditsV3Request {
|
|
#[serde(flatten)]
|
|
pub input: zeta_prompt::Zeta2PromptInput,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub struct PredictEditsV3Response {
|
|
pub request_id: String,
|
|
pub output: String,
|
|
/// The editable region byte range within `cursor_excerpt` that the
|
|
/// server used for this request. When present, the client should use
|
|
/// this range to extract the old text from its local excerpt for
|
|
/// diffing, rather than relying on its own format-derived range.
|
|
pub editable_range: Range<usize>,
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub model_version: Option<String>,
|
|
/// Predicted cursor offset within `output`.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub cursor_offset: Option<usize>,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub struct RawCompletionResponse {
|
|
pub id: String,
|
|
pub object: String,
|
|
pub created: u64,
|
|
pub model: String,
|
|
pub choices: Vec<RawCompletionChoice>,
|
|
pub usage: RawCompletionUsage,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Serialize)]
|
|
pub struct RawCompletionChoice {
|
|
pub text: String,
|
|
pub finish_reason: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
pub struct RawCompletionUsage {
|
|
pub prompt_tokens: u32,
|
|
pub completion_tokens: u32,
|
|
pub total_tokens: u32,
|
|
}
|