Skip to content

Commit c8c14d1

Browse files
authored
Merge pull request #111 from srcnalt/checkup
Missing Member Handling remvoed
2 parents a165a22 + 6ea3e46 commit c8c14d1

18 files changed

Lines changed: 122 additions & 2457 deletions

Runtime/DataTypes.cs

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public struct ChatChoice
118118
public ChatMessage Delta { get; set; }
119119
public int? Index { get; set; }
120120
public string FinishReason { get; set; }
121+
public string Logprobs { get; set; }
121122
}
122123

123124
public struct ChatMessage
@@ -160,63 +161,7 @@ public struct CreateAudioResponse: IResponse
160161
public string Text { get; set; }
161162
}
162163
#endregion
163-
164-
#region Completions API Data Types
165-
public sealed class CreateCompletionRequest
166-
{
167-
public string Model { get; set; }
168-
public string Prompt { get; set; } = "<|endoftext|>";
169-
public string Suffix { get; set; }
170-
public int? MaxTokens { get; set; } = 16;
171-
public float? Temperature { get; set; } = 1;
172-
public float? TopP { get; set; } = 1;
173-
public int N { get; set; } = 1;
174-
public bool Stream { get; set; } = false;
175-
public int? Logpropbs { get; set; }
176-
public bool? Echo { get; set; } = false;
177-
public string Stop { get; set; }
178-
public float? PresencePenalty { get; set; } = 0;
179-
public float? FrequencyPenalty { get; set; } = 0;
180-
public int? BestOf { get; set; } = 1;
181-
public Dictionary<string, string> LogitBias { get; set; }
182-
public string User { get; set; }
183-
}
184-
185-
public struct CreateCompletionResponse: IResponse
186-
{
187-
public ApiError Error { get; set; }
188-
public string Warning { get; set; }
189-
public string Id { get; set; }
190-
public string Object { get; set; }
191-
public long Created { get; set; }
192-
public string Model { get; set; }
193-
public List<Choice> Choices { get; set; }
194-
public Usage Usage { get; set; }
195-
}
196-
#endregion
197-
198-
#region Edits API Data Types
199-
public sealed class CreateEditRequest
200-
{
201-
public string Model { get; set; }
202-
public string Input { get; set; } = "";
203-
public string Instruction { get; set; }
204-
public float? Temperature { get; set; } = 1;
205-
public float? TopP { get; set; } = 1;
206-
public int? N { get; set; } = 1;
207-
}
208164

209-
public struct CreateEditResponse: IResponse
210-
{
211-
public ApiError Error { get; set; }
212-
public string Warning { get; set; }
213-
public string Object { get; set; }
214-
public long Created { get; set; }
215-
public List<Choice> Choices { get; set; }
216-
public Usage Usage { get; set; }
217-
}
218-
#endregion
219-
220165
#region Images API Data Types
221166
public class CreateImageRequestBase
222167
{

Runtime/OpenAIApi.cs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public OpenAIApi(string apiKey = null, string organization = null)
5454
{
5555
NamingStrategy = new CustomNamingStrategy()
5656
},
57-
MissingMemberHandling = MissingMemberHandling.Error,
5857
Culture = CultureInfo.InvariantCulture
5958
};
6059

@@ -217,35 +216,7 @@ public async Task<OpenAIModel> RetrieveModel(string id)
217216
var path = $"{BASE_PATH}/models/{id}";
218217
return await DispatchRequest<OpenAIModelResponse>(path, UnityWebRequest.kHttpVerbGET);
219218
}
220-
221-
/// <summary>
222-
/// Creates a completion for the provided prompt and parameters.
223-
/// </summary>
224-
/// <param name="request">See <see cref="CreateCompletionRequest"/></param>
225-
/// <returns>See <see cref="CreateCompletionResponse"/></returns>
226-
public async Task<CreateCompletionResponse> CreateCompletion(CreateCompletionRequest request)
227-
{
228-
var path = $"{BASE_PATH}/completions";
229-
var payload = CreatePayload(request);
230-
return await DispatchRequest<CreateCompletionResponse>(path, UnityWebRequest.kHttpVerbPOST, payload);
231-
}
232-
233-
/// <summary>
234-
/// Creates a chat completion request as in ChatGPT.
235-
/// </summary>
236-
/// <param name="request">See <see cref="CreateChatCompletionRequest"/></param>
237-
/// <param name="onResponse">Callback function that will be called when stream response is updated.</param>
238-
/// <param name="onComplete">Callback function that will be called when stream response is completed.</param>
239-
/// <param name="token">Cancellation token to cancel the request.</param>
240-
public void CreateCompletionAsync(CreateCompletionRequest request, Action<List<CreateCompletionResponse>> onResponse, Action onComplete, CancellationTokenSource token)
241-
{
242-
request.Stream = true;
243-
var path = $"{BASE_PATH}/completions";
244-
var payload = CreatePayload(request);
245-
246-
DispatchRequest(path, UnityWebRequest.kHttpVerbPOST, onResponse, onComplete, token, payload);
247-
}
248-
219+
249220
/// <summary>
250221
/// Creates a chat completion request as in ChatGPT.
251222
/// </summary>
@@ -275,18 +246,6 @@ public void CreateChatCompletionAsync(CreateChatCompletionRequest request, Actio
275246
DispatchRequest(path, UnityWebRequest.kHttpVerbPOST, onResponse, onComplete, token, payload);
276247
}
277248

278-
/// <summary>
279-
/// Creates a new edit for the provided input, instruction, and parameters.
280-
/// </summary>
281-
/// <param name="request">See <see cref="CreateEditRequest"/></param>
282-
/// <returns>See <see cref="CreateEditResponse"/></returns>
283-
public async Task<CreateEditResponse> CreateEdit(CreateEditRequest request)
284-
{
285-
var path = $"{BASE_PATH}/edits";
286-
var payload = CreatePayload(request);
287-
return await DispatchRequest<CreateEditResponse>(path, UnityWebRequest.kHttpVerbPOST, payload);
288-
}
289-
290249
/// <summary>
291250
/// Creates an image given a prompt.
292251
/// </summary>

Samples~/Text Completion Chat.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

Samples~/Text Completion Chat/Received Message.prefab

Lines changed: 0 additions & 221 deletions
This file was deleted.

Samples~/Text Completion Chat/Received Message.prefab.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)