openai_chatgpt_api/v1/
edits.rs1use serde_derive::{Deserialize, Serialize};
2use serde_json::{ json, Value};
3use crate::error::ChatGptError;
4use crate::v1::{ChatGptRequest, convert_from_value, trim_value};
5
6#[derive(Debug, Deserialize, Serialize, Clone)]
7pub struct ChatGptResponseEdits {
8 value: Value,
9}
10
11#[derive(Debug, Deserialize, Serialize, Clone)]
12pub struct ChatGptRequestEdits {
13 model: String,
14 input: String,
15 instruction: String,
16 n: Option<isize>,
17 temperature: Option<f32>,
18 top_p: Option<f32>,
19}
20
21impl ChatGptRequest for ChatGptRequestEdits {
22 fn from_value(value: Value) -> Result<Self, ChatGptError> where Self: Sized {
23 convert_from_value(value)
24 }
25
26 fn to_value(&self) -> Value {
27 trim_value(json!(self)).unwrap()
28 }
29}
30
31impl ChatGptRequestEdits {
32 pub fn new(model: &str, instruction: &str,input:&str) -> Self {
33 Self {
34 model: model.to_string(),
35 input: input.to_string(),
36 instruction: instruction.to_string(),
37 n: None,
38 temperature: None,
39 top_p: None,
40 }
41 }
42}