|
1 | 1 | using Newtonsoft.Json; |
2 | | -using System; |
3 | 2 | using System.Collections.Generic; |
4 | | -using System.Net.Http; |
5 | | -using System.Text; |
6 | 3 | using System.Threading.Tasks; |
7 | 4 |
|
8 | 5 | namespace OpenAI_API |
9 | 6 | { |
10 | | - /// <summary> |
11 | | - /// Represents a language model |
12 | | - /// </summary> |
13 | | - public class Model |
14 | | - { |
15 | | - /// <summary> |
16 | | - /// The id/name of the model |
17 | | - /// </summary> |
18 | | - [JsonProperty("id")] |
19 | | - public string ModelID { get; set; } |
| 7 | + /// <summary> |
| 8 | + /// Represents a language model |
| 9 | + /// </summary> |
| 10 | + public class Model |
| 11 | + { |
| 12 | + /// <summary> |
| 13 | + /// The id/name of the model |
| 14 | + /// </summary> |
| 15 | + [JsonProperty("id")] |
| 16 | + public string ModelID { get; set; } |
20 | 17 |
|
21 | 18 | /// <summary> |
22 | 19 | /// The owner of this model. Generally "openai" is a generic OpenAI model, or the organization if a custom or finetuned model. |
23 | 20 | /// </summary> |
24 | 21 | [JsonProperty("owned_by")] |
25 | 22 | public string OwnedBy { get; set; } |
26 | 23 |
|
| 24 | + /// <summary> |
| 25 | + /// The type of object. Should always be 'model'. |
| 26 | + /// </summary> |
| 27 | + [JsonProperty("object")] |
| 28 | + public string Object { get; set; } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// The owner of this model. Generally "openai" is a generic OpenAI model, or the organization if a custom or finetuned model. |
| 32 | + /// </summary> |
| 33 | + [JsonProperty("created")] |
| 34 | + public long Created { get; set; } |
| 35 | + |
| 36 | + /// <summary> |
| 37 | + /// Permissions for use of the model |
| 38 | + /// </summary> |
| 39 | + [JsonProperty("permission")] |
| 40 | + public List<Permissions> Permission { get; set; } = new List<Permissions>(); |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Currently (2023-01-27) seems like this is duplicate of <see cref="ModelID"/> but including for completeness. |
| 44 | + /// </summary> |
| 45 | + [JsonProperty("root")] |
| 46 | + public string Root { get; set; } |
| 47 | + |
| 48 | + /// <summary> |
| 49 | + /// Currently (2023-01-27) seems unused, probably intended for nesting of models in a later release |
| 50 | + /// </summary> |
| 51 | + [JsonProperty("parent")] |
| 52 | + public string Parent { get; set; } |
| 53 | + |
27 | 54 | /// <summary> |
28 | 55 | /// Allows an model to be implicitly cast to the string of its <see cref="ModelID"/> |
29 | 56 | /// </summary> |
30 | 57 | /// <param name="model">The <see cref="Model"/> to cast to a string.</param> |
31 | 58 | public static implicit operator string(Model model) |
32 | | - { |
33 | | - return model?.ModelID; |
34 | | - } |
| 59 | + { |
| 60 | + return model?.ModelID; |
| 61 | + } |
35 | 62 |
|
36 | | - /// <summary> |
37 | | - /// Allows a string to be implicitly cast as an <see cref="Model"/> with that <see cref="ModelID"/> |
38 | | - /// </summary> |
39 | | - /// <param name="name">The id/<see cref="ModelID"/> to use</param> |
40 | | - public static implicit operator Model(string name) |
41 | | - { |
42 | | - return new Model(name); |
43 | | - } |
| 63 | + /// <summary> |
| 64 | + /// Allows a string to be implicitly cast as an <see cref="Model"/> with that <see cref="ModelID"/> |
| 65 | + /// </summary> |
| 66 | + /// <param name="name">The id/<see cref="ModelID"/> to use</param> |
| 67 | + public static implicit operator Model(string name) |
| 68 | + { |
| 69 | + return new Model(name); |
| 70 | + } |
44 | 71 |
|
45 | | - /// <summary> |
46 | | - /// Represents an Model with the given id/<see cref="ModelID"/> |
47 | | - /// </summary> |
48 | | - /// <param name="name">The id/<see cref="ModelID"/> to use. |
49 | | - /// </param> |
50 | | - public Model(string name) |
51 | | - { |
52 | | - this.ModelID = name; |
53 | | - } |
| 72 | + /// <summary> |
| 73 | + /// Represents an Model with the given id/<see cref="ModelID"/> |
| 74 | + /// </summary> |
| 75 | + /// <param name="name">The id/<see cref="ModelID"/> to use. |
| 76 | + /// </param> |
| 77 | + public Model(string name) |
| 78 | + { |
| 79 | + this.ModelID = name; |
| 80 | + } |
54 | 81 |
|
55 | | - /// <summary> |
56 | | - /// Represents a generic Model/model |
57 | | - /// </summary> |
58 | | - public Model() |
59 | | - { |
| 82 | + /// <summary> |
| 83 | + /// Represents a generic Model/model |
| 84 | + /// </summary> |
| 85 | + public Model() |
| 86 | + { |
60 | 87 |
|
61 | | - } |
| 88 | + } |
62 | 89 |
|
63 | 90 |
|
64 | 91 |
|
@@ -105,8 +132,90 @@ public Model() |
105 | 132 | /// <param name="auth">API authentication in order to call the API endpoint. If not specified, attempts to use a default.</param> |
106 | 133 | /// <returns>Asynchronously returns an Model with all relevant properties filled in</returns> |
107 | 134 | public async Task<Model> RetrieveModelDetailsAsync(APIAuthentication auth = null) |
108 | | - { |
109 | | - return await ModelsEndpoint.RetrieveModelDetailsAsync(this.ModelID, auth); |
110 | | - } |
111 | | - } |
| 135 | + { |
| 136 | + return await ModelsEndpoint.RetrieveModelDetailsAsync(this.ModelID, auth); |
| 137 | + } |
| 138 | + } |
| 139 | + |
| 140 | + /// <summary> |
| 141 | + /// Permissions for using the model |
| 142 | + /// </summary> |
| 143 | + public class Permissions |
| 144 | + { |
| 145 | + /// <summary> |
| 146 | + /// Permission Id (not to be confused with ModelId |
| 147 | + /// </summary> |
| 148 | + [JsonProperty("id")] |
| 149 | + public string Id { get; set; } |
| 150 | + |
| 151 | + /// <summary> |
| 152 | + /// Object type, should always be 'model_permission' |
| 153 | + /// </summary> |
| 154 | + [JsonProperty("object")] |
| 155 | + public string Object { get; set; } |
| 156 | + |
| 157 | + /// <summary> |
| 158 | + /// Unix timestamp for creation date/time |
| 159 | + /// </summary> |
| 160 | + [JsonProperty("created")] |
| 161 | + public long Created { get; set; } |
| 162 | + |
| 163 | + /// <summary> |
| 164 | + /// Can the engine (model?) be created? |
| 165 | + /// </summary> |
| 166 | + [JsonProperty("allow_create_engine")] |
| 167 | + public bool AllowCreateEngine { get; set; } |
| 168 | + |
| 169 | + /// <summary> |
| 170 | + /// Does the model support temperature sampling? |
| 171 | + /// https://beta.openai.com/docs/api-reference/completions/create#completions/create-temperature |
| 172 | + /// </summary> |
| 173 | + [JsonProperty("allow_sampling")] |
| 174 | + public bool AllowSampling { get; set; } |
| 175 | + |
| 176 | + /// <summary> |
| 177 | + /// Does the model support logprobs? |
| 178 | + /// https://beta.openai.com/docs/api-reference/completions/create#completions/create-logprobs |
| 179 | + /// </summary> |
| 180 | + [JsonProperty("allow_logprobs")] |
| 181 | + public bool AllowLogProbs { get; set; } |
| 182 | + |
| 183 | + /// <summary> |
| 184 | + /// Does the model support search indices? |
| 185 | + /// </summary> |
| 186 | + [JsonProperty("allow_search_indices")] |
| 187 | + public bool AllowSearchIndices { get; set; } |
| 188 | + |
| 189 | + /// <summary> |
| 190 | + /// ?? |
| 191 | + /// </summary> |
| 192 | + [JsonProperty("allow_view")] |
| 193 | + public bool AllowView { get; set; } |
| 194 | + |
| 195 | + /// <summary> |
| 196 | + /// Does the model allow fine tuning? |
| 197 | + /// https://beta.openai.com/docs/api-reference/fine-tunes |
| 198 | + /// </summary> |
| 199 | + [JsonProperty("allow_fine_tuning")] |
| 200 | + public bool AllowFineTuning { get; set; } |
| 201 | + |
| 202 | + /// <summary> |
| 203 | + /// Is the model only allowed for a particular organization? Seems not implemented yet. Always '*'. |
| 204 | + /// </summary> |
| 205 | + [JsonProperty("organization")] |
| 206 | + public string Organization { get; set; } |
| 207 | + |
| 208 | + /// <summary> |
| 209 | + /// Is the model part of a group? Seems not implemented yet. Always null. |
| 210 | + /// </summary> |
| 211 | + [JsonProperty("group")] |
| 212 | + public string Group { get; set; } |
| 213 | + |
| 214 | + /// <summary> |
| 215 | + /// ?? |
| 216 | + /// </summary> |
| 217 | + [JsonProperty("is_blocking")] |
| 218 | + public bool IsBlocking { get; set; } |
| 219 | + } |
| 220 | + |
112 | 221 | } |
0 commit comments