@@ -82,6 +82,25 @@ struct ChatCompletion {
82
82
}
83
83
};
84
84
85
+ struct Model {
86
+ std::string id;
87
+ std::string object;
88
+ long long created;
89
+ std::string owned_by;
90
+
91
+ Model () : id(), object(), created(0 ), owned_by() {}
92
+ Model (const std::string &id_) : id(id_), object(" model" ), created(0 ), owned_by(" user" ) {}
93
+ };
94
+
95
+ struct ModelList {
96
+ std::string object;
97
+ std::vector<Model> data;
98
+ ModelList (): object(" list" ) {}
99
+ ModelList (const Model &model_) : object(" list" ) {
100
+ data.push_back (model_);
101
+ }
102
+ };
103
+
85
104
struct InferenceParams {
86
105
std::vector<ChatMessage> messages;
87
106
int max_tokens;
@@ -132,6 +151,18 @@ void to_json(json& j, const ChatCompletion& completion) {
132
151
{" choices" , completion.choices }};
133
152
}
134
153
154
+ void to_json (json& j, const Model& model) {
155
+ j = json{{" id" , model.id },
156
+ {" object" , model.object },
157
+ {" created" , model.created },
158
+ {" owned_by" , model.owned_by }};
159
+ }
160
+
161
+ void to_json (json& j, const ModelList& models) {
162
+ j = json{{" object" , models.object },
163
+ {" data" , models.data }};
164
+ }
165
+
135
166
std::vector<ChatMessage> parseChatMessages (json &json){
136
167
std::vector<ChatMessage> messages;
137
168
messages.reserve (json.size ());
0 commit comments