1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#![allow(dead_code)]

pub mod list_models {
    use serde::Deserialize;

    #[derive(Debug, Deserialize)]
    pub struct ModelPermission {
        id: String,
        object: String,
        created: i64,
        allow_create_engine: bool,
        allow_sampling: bool,
        allow_logprobs: bool,
        allow_search_indices: bool,
        allow_view: bool,
        allow_fine_tuning: bool,
        organization: String,
        group: Option<String>,
        is_blocking: bool,
    }

    #[derive(Debug, Deserialize)]
    pub struct Model {
        id: String,
        object: String,
        created: i64,
        owned_by: String,
        permission: Vec<ModelPermission>,
        root: String,
        parent: Option<String>,
    }

    #[derive(Debug, Deserialize)]
    pub struct ModelList {
        object: String,
        data: Vec<Model>,
    }
}

pub mod edits {
    use serde::{Deserialize, Serialize};

    #[derive(Debug, Deserialize, Serialize)]
    pub struct EditParameters {
        model: String,
        input: String,
        instructions: String,
    }

    #[derive(Debug, Deserialize)]
    pub struct EditResponse {
        object: String,
        created: i64,
        choices: Vec<Choice>,
        usage: Usage,
    }

    #[derive(Debug, Deserialize)]
    pub struct Choice {
        text: String,
        index: i32,
    }

    #[derive(Debug, Deserialize)]
    pub struct Usage {
        prompt_tokens: i32,
        completion_tokens: i32,
        total_tokens: i32,
    }
}

pub mod completions {

    use serde::{Deserialize, Serialize};

    #[derive(Debug, Deserialize, Serialize)]
    pub struct CompletionParameters {
        model: String,
        prompt: String,
        max_tokens: i32,
        temperature: f32,
        top_p: f32,
        n: i32,
        stream: bool,
        logprobs: Option<i32>,
        stop: String,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct CompletionResponse {
        id: String,
        object: String,
        created: i64,
        model: String,
        choices: Vec<CompletionChoice>,
        usage: Usage,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct CompletionChoice {
        text: String,
        index: i32,
        logprobs: Option<i32>,
        finish_reason: String,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct Usage {
        prompt_tokens: i32,
        completion_tokens: i32,
        total_tokens: i32,
    }
}

pub mod chat {
    use serde::{Deserialize, Serialize};

    #[derive(Debug, Serialize, Deserialize)]
    pub struct ChatParameters {
        model: String,
        messages: Vec<Message>,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct ChatResponse {
        id: String,
        object: String,
        created: i64,
        choices: Vec<CompletionChoice>,
        usage: Usage,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct CompletionChoice {
        index: i32,
        message: Message,
        finish_reason: String,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct Message {
        role: String,
        content: String,
    }

    #[derive(Debug, Serialize, Deserialize)]
    pub struct Usage {
        prompt_tokens: i32,
        completion_tokens: i32,
        total_tokens: i32,
    }
}