mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
ep: Send trigger in header (#56433)
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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Closes #ISSUE Release Notes: - N/A or Added/Fixed/Improved ...
This commit is contained in:
parent
a3781513ba
commit
8033fbfccf
3 changed files with 10 additions and 8 deletions
|
|
@ -115,7 +115,9 @@ pub struct PredictEditsBody {
|
|||
pub trigger: PredictEditsRequestTrigger,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, strum::AsRefStr)]
|
||||
#[derive(
|
||||
Default, Debug, Clone, Copy, Serialize, Deserialize, strum::AsRefStr, strum::EnumString,
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
pub enum PredictEditsRequestTrigger {
|
||||
Testing,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use crate::PredictEditsRequestTrigger;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
use std::ops::Range;
|
||||
|
|
@ -6,6 +5,7 @@ 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")]
|
||||
|
|
@ -32,8 +32,6 @@ pub struct RawCompletionRequest {
|
|||
pub struct PredictEditsV3Request {
|
||||
#[serde(flatten)]
|
||||
pub input: zeta_prompt::ZetaPromptInput,
|
||||
#[serde(default)]
|
||||
pub trigger: PredictEditsRequestTrigger,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ use client::{Client, EditPredictionUsage, NeedsLlmTokenRefresh, UserStore, globa
|
|||
use cloud_api_client::LlmApiToken;
|
||||
use cloud_api_types::{OrganizationId, SubmitEditPredictionFeedbackBody};
|
||||
use cloud_llm_client::predict_edits_v3::{
|
||||
PREDICT_EDITS_MODE_HEADER_NAME, PREDICT_EDITS_REQUEST_ID_HEADER_NAME, PredictEditsMode,
|
||||
PredictEditsV3Request, PredictEditsV3Response, RawCompletionRequest, RawCompletionResponse,
|
||||
PREDICT_EDITS_MODE_HEADER_NAME, PREDICT_EDITS_REQUEST_ID_HEADER_NAME,
|
||||
PREDICT_EDITS_TRIGGER_HEADER_NAME, PredictEditsMode, PredictEditsV3Request,
|
||||
PredictEditsV3Response, RawCompletionRequest, RawCompletionResponse,
|
||||
};
|
||||
use cloud_llm_client::{
|
||||
EditPredictionRejectReason, EditPredictionRejection,
|
||||
|
|
@ -2600,7 +2601,7 @@ impl EditPredictionStore {
|
|||
.http_client()
|
||||
.build_zed_llm_url("/predict_edits/v3", &[])?;
|
||||
|
||||
let request = PredictEditsV3Request { input, trigger };
|
||||
let request = PredictEditsV3Request { input };
|
||||
let request_id = uuid::Uuid::new_v4().to_string();
|
||||
|
||||
let json_bytes = serde_json::to_vec(&request)?;
|
||||
|
|
@ -2612,7 +2613,8 @@ impl EditPredictionStore {
|
|||
.uri(url.as_ref())
|
||||
.header("Content-Encoding", "zstd")
|
||||
.header(PREDICT_EDITS_MODE_HEADER_NAME, mode.as_ref())
|
||||
.header(PREDICT_EDITS_REQUEST_ID_HEADER_NAME, request_id.as_str());
|
||||
.header(PREDICT_EDITS_REQUEST_ID_HEADER_NAME, request_id.as_str())
|
||||
.header(PREDICT_EDITS_TRIGGER_HEADER_NAME, trigger.as_ref());
|
||||
let builder = if let Some(preferred_experiment) = preferred_experiment.as_deref() {
|
||||
builder.header(PREFERRED_EXPERIMENT_HEADER_NAME, preferred_experiment)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue