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    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub model_version: Option<String>,
38}
39
40#[derive(Debug, Deserialize, Serialize)]
41pub struct RawCompletionResponse {
42    pub id: String,
43    pub object: String,
44    pub created: u64,
45    pub model: String,
46    pub choices: Vec<RawCompletionChoice>,
47    pub usage: RawCompletionUsage,
48}
49
50#[derive(Debug, Deserialize, Serialize)]
51pub struct RawCompletionChoice {
52    pub text: String,
53    pub finish_reason: Option<String>,
54}
55
56#[derive(Debug, Serialize, Deserialize)]
57pub struct RawCompletionUsage {
58    pub prompt_tokens: u32,
59    pub completion_tokens: u32,
60    pub total_tokens: u32,
61}