forked from janhq/cortex.cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.h
More file actions
71 lines (57 loc) · 1.53 KB
/
file.h
File metadata and controls
71 lines (57 loc) · 1.53 KB
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
#pragma once
#include <string>
#include "common/json_serializable.h"
namespace OpenAi {
/**
* The File object represents a document that has been uploaded to OpenAI.
*/
struct File : public JsonSerializable {
/**
* The file identifier, which can be referenced in the API endpoints.
*/
std::string id;
/**
* The object type, which is always file.
*/
std::string object = "file";
/**
* The size of the file, in bytes.
*/
uint64_t bytes;
/**
* The Unix timestamp (in seconds) for when the file was created.
*/
uint32_t created_at;
/**
* The name of the file.
*/
std::string filename;
/**
* The intended purpose of the file. Supported values are assistants,
* assistants_output, batch, batch_output, fine-tune, fine-tune-results
* and vision.
*/
std::string purpose;
~File() = default;
static cpp::result<File, std::string> FromJson(const Json::Value& json) {
File file;
file.id = std::move(json["id"].asString());
file.object = "file";
file.bytes = json["bytes"].asUInt64();
file.created_at = json["created_at"].asUInt();
file.filename = std::move(json["filename"].asString());
file.purpose = std::move(json["purpose"].asString());
return file;
}
cpp::result<Json::Value, std::string> ToJson() {
Json::Value root;
root["id"] = id;
root["object"] = object;
root["bytes"] = bytes;
root["created_at"] = created_at;
root["filename"] = filename;
root["purpose"] = purpose;
return root;
}
};
} // namespace OpenAi