predict_edits_v3.rs

 1use crate::PredictEditsRequestTrigger;
 2use serde::{Deserialize, Serialize};
 3use std::borrow::Cow;
 4use std::ops::Range;
 5
 6#[derive(Debug, Deserialize, Serialize)]
 7pub struct RawCompletionRequest {
 8    pub model: String,
 9    pub prompt: String,
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub max_tokens: Option<u32>,
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub temperature: Option<f32>,
14    pub stop: Vec<Cow<'static, str>>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub environment: Option<String>,
17}
18
19#[derive(Debug, Serialize, Deserialize)]
20pub struct PredictEditsV3Request {
21    #[serde(flatten)]
22    pub input: zeta_prompt::ZetaPromptInput,
23    #[serde(default)]
24    pub trigger: PredictEditsRequestTrigger,
25}
26
27#[derive(Debug, Deserialize, Serialize)]
28pub struct PredictEditsV3Response {
29    pub request_id: String,
30    pub output: String,
31    /// The editable region byte range within `cursor_excerpt` that the
32    /// server used for this request. When present, the client should use
33    /// this range to extract the old text from its local excerpt for
34    /// diffing, rather than relying on its own format-derived range.
35    pub editable_range: Range<usize>,
36}
37
38#[derive(Debug, Deserialize, Serialize)]
39pub struct RawCompletionResponse {
40    pub id: String,
41    pub object: String,
42    pub created: u64,
43    pub model: String,
44    pub choices: Vec<RawCompletionChoice>,
45    pub usage: RawCompletionUsage,
46}
47
48#[derive(Debug, Deserialize, Serialize)]
49pub struct RawCompletionChoice {
50    pub text: String,
51    pub finish_reason: Option<String>,
52}
53
54#[derive(Debug, Serialize, Deserialize)]
55pub struct RawCompletionUsage {
56    pub prompt_tokens: u32,
57    pub completion_tokens: u32,
58    pub total_tokens: u32,
59}