diff --git a/.docs/.gitignore b/.docs/.gitignore new file mode 100644 index 00000000..cebdbd4f --- /dev/null +++ b/.docs/.gitignore @@ -0,0 +1,9 @@ +############### +# folder # +############### +/**/DROP/ +/**/TEMP/ +/**/packages/ +/**/bin/ +/**/obj/ +/**/api/ \ No newline at end of file diff --git a/.docs/docfx.json b/.docs/docfx.json new file mode 100644 index 00000000..5b700b2e --- /dev/null +++ b/.docs/docfx.json @@ -0,0 +1,65 @@ +{ + "metadata": [ + { + "src": [ + { + "src": "../OpenAI-DotNet/", + "files": [ + "**.csproj" + ], + "exclude": [ + "**/bin/**", + "**/obj/**" + ] + } + ], + "dest": "api" + } + ], + "build": { + "content": [ + { + "files": [ + "**/*.{md,yml}" + ] + }, + { + "src": "../OpenAI-DotNet-Proxy/", + "files": [ + "/*.{md,yml}" + ], + "dest": "OpenAI-DotNet-Proxy" + }, + { + "src": "../", + "files": [ + "/*.{md,yml}" + ] + } + ], + "resource": [ + { + "src": "../OpenAI-DotNet/Assets", + "files": [ + "*.png", + "*.svg", + "*.ico" + ], + "dest" : "assets" + } + ], + "output": "../_site", + "template": [ + "default", + "modern" + ], + "globalMetadata": { + "_appName": "OpenAI-DotNet", + "_appTitle": "OpenAI-DotNet", + "_appLogoPath": "assets/OpenAI-DotNet-Icon@x1.png", + "_appFaviconPath": "assets/OpenAI-DotNet-Icon@x1.png", + "_enableSearch": true, + "pdf": false + } + } +} \ No newline at end of file diff --git a/.docs/index.md b/.docs/index.md new file mode 100644 index 00000000..8309b2ae --- /dev/null +++ b/.docs/index.md @@ -0,0 +1,3 @@ +--- +redirect_url: README.html +--- \ No newline at end of file diff --git a/.docs/toc.yml b/.docs/toc.yml new file mode 100644 index 00000000..92351bd0 --- /dev/null +++ b/.docs/toc.yml @@ -0,0 +1,4 @@ +- name: Proxy + href: OpenAI-DotNet-Proxy/Readme.html +- name: API + href: api/OpenAI.OpenAIClient.html \ No newline at end of file diff --git a/.github/workflows/Publish-Nuget.yml b/.github/workflows/Publish-Nuget.yml index 554026b7..f958b8e6 100644 --- a/.github/workflows/Publish-Nuget.yml +++ b/.github/workflows/Publish-Nuget.yml @@ -1,4 +1,4 @@ -name: Nuget Publish +name: Build and Publish on: push: @@ -24,6 +24,15 @@ on: required: false default: "6.0.x" +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: false + env: DOTNET_VERSION: ${{ github.event.inputs.dotnet-version || '6.0.x' }} PACKAGE_VERSION: '' @@ -125,3 +134,33 @@ jobs: ${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet-Proxy.${{ env.PACKAGE_VERSION }}.nupkg ${{ github.workspace }}/OpenAI-DotNet/bin/Release/OpenAI-DotNet-Proxy.${{ env.PACKAGE_VERSION }}.symbols.nupkg if-no-files-found: ignore + + docs: + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: ${{ env.DOTNET_VERSION }} + + - name: build docfx + run: | + dotnet tool update -g docfx + docfx .docs/docfx.json + + - uses: actions/upload-pages-artifact@v3 + with: + path: '_site' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 4631548f..5e21e886 100644 --- a/.gitignore +++ b/.gitignore @@ -338,5 +338,12 @@ ASALocalRun/ # BeatPulse healthcheck temp database healthchecksdb + +# Visual Studio Code .vscode + +# Docfx +_site + +# Unit Test Ouputs OpenAI-DotNet-Tests/Assets/HelloWorld.mp3 diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..d2fa5f2a --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2021 Stephen Hodgson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index cbcbe3ae..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,3 +0,0 @@ -![CC-0 Public Domain](https://licensebuttons.net/p/zero/1.0/88x31.png) - -This library is licensed CC-0, in the public domain. You can use it for whatever you want, publicly or privately, without worrying about permission or licensing or whatever. It's just a wrapper around the OpenAI API, so you still need to get access to OpenAI from them directly. I am not affiliated with OpenAI and this library is not endorsed by them, I just have beta access and wanted to make a C# library to access it more easily. Hopefully others find this useful as well. Feel free to open a PR if there's anything you want to contribute. diff --git a/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs b/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs index 04afe783..1d97a0fb 100644 --- a/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs +++ b/OpenAI-DotNet-Proxy/Proxy/AbstractAuthenticationFilter.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Http; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using Microsoft.AspNetCore.Http; namespace OpenAI.Proxy { diff --git a/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs b/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs index 9e8a96f5..5805c4cb 100644 --- a/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs +++ b/OpenAI-DotNet-Proxy/Proxy/IAuthenticationFilter.cs @@ -1,4 +1,6 @@ -using System.Security.Authentication; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Security.Authentication; using Microsoft.AspNetCore.Http; namespace OpenAI.Proxy diff --git a/OpenAI-DotNet-Proxy/Proxy/OpenAIProxyStartup.cs b/OpenAI-DotNet-Proxy/Proxy/OpenAIProxyStartup.cs index 63fb11f1..28f83732 100644 --- a/OpenAI-DotNet-Proxy/Proxy/OpenAIProxyStartup.cs +++ b/OpenAI-DotNet-Proxy/Proxy/OpenAIProxyStartup.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Builder; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; diff --git a/OpenAI-DotNet-Proxy/toc.yml b/OpenAI-DotNet-Proxy/toc.yml new file mode 100644 index 00000000..437a54ce --- /dev/null +++ b/OpenAI-DotNet-Proxy/toc.yml @@ -0,0 +1,4 @@ +- name: Proxy + href: Readme.md +- name: API + href: ../api/OpenAI.OpenAIClient.html \ No newline at end of file diff --git a/OpenAI-DotNet-Tests/AbstractTestFixture.cs b/OpenAI-DotNet-Tests/AbstractTestFixture.cs index 1facbe32..8fad8793 100644 --- a/OpenAI-DotNet-Tests/AbstractTestFixture.cs +++ b/OpenAI-DotNet-Tests/AbstractTestFixture.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Hosting; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using System; using System.Net.Http; diff --git a/OpenAI-DotNet-Tests/TestFixture_03_Chat.cs b/OpenAI-DotNet-Tests/TestFixture_03_Chat.cs index 44a0c9f4..991d1a87 100644 --- a/OpenAI-DotNet-Tests/TestFixture_03_Chat.cs +++ b/OpenAI-DotNet-Tests/TestFixture_03_Chat.cs @@ -506,5 +506,67 @@ public async Task Test_03_02_GetChatVisionStreaming() Console.WriteLine($"{response.FirstChoice.Message.Role}: {response.FirstChoice} | Finish Reason: {response.FirstChoice.FinishDetails}"); response.GetUsage(); } + + [Test] + public async Task Test_04_01_GetChatLogProbs() + { + Assert.IsNotNull(OpenAIClient.ChatEndpoint); + var messages = new List + { + new Message(Role.System, "You are a helpful assistant."), + new Message(Role.User, "Who won the world series in 2020?"), + new Message(Role.Assistant, "The Los Angeles Dodgers won the World Series in 2020."), + new Message(Role.User, "Where was it played?"), + }; + var chatRequest = new ChatRequest(messages, Model.GPT3_5_Turbo, topLogProbs: 1); + var response = await OpenAIClient.ChatEndpoint.GetCompletionAsync(chatRequest); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Choices); + Assert.IsNotEmpty(response.Choices); + + foreach (var choice in response.Choices) + { + Console.WriteLine($"[{choice.Index}] {choice.Message.Role}: {choice} | Finish Reason: {choice.FinishReason}"); + } + + response.GetUsage(); + } + + [Test] + public async Task Test_04_02_GetChatLogProbsSteaming() + { + Assert.IsNotNull(OpenAIClient.ChatEndpoint); + var messages = new List + { + new Message(Role.System, "You are a helpful assistant."), + new Message(Role.User, "Who won the world series in 2020?"), + new Message(Role.Assistant, "The Los Angeles Dodgers won the World Series in 2020."), + new Message(Role.User, "Where was it played?"), + }; + var chatRequest = new ChatRequest(messages, topLogProbs: 1); + var cumulativeDelta = string.Empty; + var response = await OpenAIClient.ChatEndpoint.StreamCompletionAsync(chatRequest, partialResponse => + { + Assert.IsNotNull(partialResponse); + Assert.NotNull(partialResponse.Choices); + Assert.NotZero(partialResponse.Choices.Count); + + foreach (var choice in partialResponse.Choices.Where(choice => choice.Delta?.Content != null)) + { + cumulativeDelta += choice.Delta.Content; + } + }); + Assert.IsNotNull(response); + Assert.IsNotNull(response.Choices); + var choice = response.FirstChoice; + Assert.IsNotNull(choice); + Assert.IsNotNull(choice.Message); + Assert.IsFalse(string.IsNullOrEmpty(choice.ToString())); + Console.WriteLine($"[{choice.Index}] {choice.Message.Role}: {choice} | Finish Reason: {choice.FinishReason}"); + Assert.IsTrue(choice.Message.Role == Role.Assistant); + Assert.IsTrue(choice.Message.Content!.Equals(cumulativeDelta)); + Console.WriteLine(response.ToString()); + response.GetUsage(); + } } } \ No newline at end of file diff --git a/OpenAI-DotNet/AssemblyInfo.cs b/OpenAI-DotNet/AssemblyInfo.cs index 00f1f2a7..f69c9c7d 100644 --- a/OpenAI-DotNet/AssemblyInfo.cs +++ b/OpenAI-DotNet/AssemblyInfo.cs @@ -1,4 +1,5 @@ - +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("OpenAI-DotNet-Proxy")] diff --git a/OpenAI-DotNet/Assets/OpenAI-DotNet-Icon@x1.png b/OpenAI-DotNet/Assets/OpenAI-DotNet-Icon@x1.png new file mode 100644 index 00000000..42cc6f58 Binary files /dev/null and b/OpenAI-DotNet/Assets/OpenAI-DotNet-Icon@x1.png differ diff --git a/OpenAI-DotNet/Assistants/AssistantExtensions.cs b/OpenAI-DotNet/Assistants/AssistantExtensions.cs index 39e55299..9333ab33 100644 --- a/OpenAI-DotNet/Assistants/AssistantExtensions.cs +++ b/OpenAI-DotNet/Assistants/AssistantExtensions.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Files; using OpenAI.Threads; using System.Threading; @@ -25,7 +27,7 @@ public static async Task ModifyAsync(this AssistantResponse a /// /// . /// Optional, . - /// True, if the was successfully deleted. + /// True, if the assistant was successfully deleted. public static async Task DeleteAsync(this AssistantResponse assistant, CancellationToken cancellationToken = default) => await assistant.Client.AssistantsEndpoint.DeleteAssistantAsync(assistant.Id, cancellationToken).ConfigureAwait(false); @@ -52,7 +54,7 @@ public static async Task> ListFilesAsync(thi => await assistant.Client.AssistantsEndpoint.ListFilesAsync(assistant.Id, query, cancellationToken).ConfigureAwait(false); /// - /// Attach a file to the . + /// Attach a file to the assistant. /// /// . /// @@ -65,7 +67,7 @@ public static async Task AttachFileAsync(this AssistantRe => await assistant.Client.AssistantsEndpoint.AttachFileAsync(assistant.Id, file, cancellationToken).ConfigureAwait(false); /// - /// Uploads a new file at the specified and attaches it to the . + /// Uploads a new file at the specified path and attaches it to the assistant. /// /// . /// The local file path to upload. @@ -100,7 +102,7 @@ public static async Task RetrieveFileAsync(this Assistant // => await assistantFile.Client.FilesEndpoint.DownloadFileAsync(assistantFile.Id, directory, deleteCachedFile, cancellationToken).ConfigureAwait(false); /// - /// Remove AssistantFile. + /// Remove the file from the assistant it is attached to. /// /// /// Note that removing an AssistantFile does not delete the original File object, @@ -114,7 +116,7 @@ public static async Task RemoveFileAsync(this AssistantFileResponse file, => await file.Client.AssistantsEndpoint.RemoveFileAsync(file.AssistantId, file.Id, cancellationToken).ConfigureAwait(false); /// - /// Remove AssistantFile. + /// Remove the file from the assistant it is attached to. /// /// /// Note that removing an AssistantFile does not delete the original File object, @@ -141,7 +143,7 @@ public static async Task DeleteFileAsync(this AssistantFileResponse file, } /// - /// Removes and Deletes a file from the . + /// Removes and Deletes a file from the assistant. /// /// . /// The ID of the file to delete. diff --git a/OpenAI-DotNet/Assistants/AssistantFileResponse.cs b/OpenAI-DotNet/Assistants/AssistantFileResponse.cs index b6dc132a..b2e8fc97 100644 --- a/OpenAI-DotNet/Assistants/AssistantFileResponse.cs +++ b/OpenAI-DotNet/Assistants/AssistantFileResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Assistants/AssistantResponse.cs b/OpenAI-DotNet/Assistants/AssistantResponse.cs index 9d6e0b65..f33efd8e 100644 --- a/OpenAI-DotNet/Assistants/AssistantResponse.cs +++ b/OpenAI-DotNet/Assistants/AssistantResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -5,7 +7,7 @@ namespace OpenAI.Assistants { /// - /// Purpose-built AI that uses OpenAI�s models and calls tools. + /// Purpose-built AI that uses OpenAI's models and calls tools. /// public sealed class AssistantResponse : BaseResponse { diff --git a/OpenAI-DotNet/Assistants/AssistantsEndpoint.cs b/OpenAI-DotNet/Assistants/AssistantsEndpoint.cs index 6fd40871..8596120d 100644 --- a/OpenAI-DotNet/Assistants/AssistantsEndpoint.cs +++ b/OpenAI-DotNet/Assistants/AssistantsEndpoint.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using OpenAI.Files; using System; diff --git a/OpenAI-DotNet/Assistants/CreateAssistantRequest.cs b/OpenAI-DotNet/Assistants/CreateAssistantRequest.cs index 0a732f8a..ad42867d 100644 --- a/OpenAI-DotNet/Assistants/CreateAssistantRequest.cs +++ b/OpenAI-DotNet/Assistants/CreateAssistantRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Audio/AudioEndpoint.cs b/OpenAI-DotNet/Audio/AudioEndpoint.cs index 9c44d701..5fcd703f 100644 --- a/OpenAI-DotNet/Audio/AudioEndpoint.cs +++ b/OpenAI-DotNet/Audio/AudioEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.IO; using System.Net.Http; diff --git a/OpenAI-DotNet/Audio/AudioResponseFormat.cs b/OpenAI-DotNet/Audio/AudioResponseFormat.cs index f3b04989..12197260 100644 --- a/OpenAI-DotNet/Audio/AudioResponseFormat.cs +++ b/OpenAI-DotNet/Audio/AudioResponseFormat.cs @@ -1,4 +1,6 @@ -namespace OpenAI.Audio +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace OpenAI.Audio { public enum AudioResponseFormat { diff --git a/OpenAI-DotNet/Audio/AudioTranscriptionRequest.cs b/OpenAI-DotNet/Audio/AudioTranscriptionRequest.cs index 5656f2e8..eb643ad7 100644 --- a/OpenAI-DotNet/Audio/AudioTranscriptionRequest.cs +++ b/OpenAI-DotNet/Audio/AudioTranscriptionRequest.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; namespace OpenAI.Audio diff --git a/OpenAI-DotNet/Audio/AudioTranslationRequest.cs b/OpenAI-DotNet/Audio/AudioTranslationRequest.cs index bf63e751..7a9097b1 100644 --- a/OpenAI-DotNet/Audio/AudioTranslationRequest.cs +++ b/OpenAI-DotNet/Audio/AudioTranslationRequest.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; namespace OpenAI.Audio diff --git a/OpenAI-DotNet/Audio/SpeechRequest.cs b/OpenAI-DotNet/Audio/SpeechRequest.cs index 37fa470d..0a2f1a99 100644 --- a/OpenAI-DotNet/Audio/SpeechRequest.cs +++ b/OpenAI-DotNet/Audio/SpeechRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; using OpenAI.Extensions; using OpenAI.Models; diff --git a/OpenAI-DotNet/Audio/SpeechResponseFormat.cs b/OpenAI-DotNet/Audio/SpeechResponseFormat.cs index 5fc749b8..43fc4205 100644 --- a/OpenAI-DotNet/Audio/SpeechResponseFormat.cs +++ b/OpenAI-DotNet/Audio/SpeechResponseFormat.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI.Audio diff --git a/OpenAI-DotNet/Audio/SpeechVoice.cs b/OpenAI-DotNet/Audio/SpeechVoice.cs index 9be76c36..ba644021 100644 --- a/OpenAI-DotNet/Audio/SpeechVoice.cs +++ b/OpenAI-DotNet/Audio/SpeechVoice.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + namespace OpenAI.Audio { public enum SpeechVoice diff --git a/OpenAI-DotNet/Authentication/AuthInfo.cs b/OpenAI-DotNet/Authentication/AuthInfo.cs index 30d8f37f..94827178 100644 --- a/OpenAI-DotNet/Authentication/AuthInfo.cs +++ b/OpenAI-DotNet/Authentication/AuthInfo.cs @@ -1,4 +1,6 @@ -using System.Security.Authentication; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Security.Authentication; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Authentication/OpenAIAuthentication.cs b/OpenAI-DotNet/Authentication/OpenAIAuthentication.cs index f2ef29b5..a7582795 100644 --- a/OpenAI-DotNet/Authentication/OpenAIAuthentication.cs +++ b/OpenAI-DotNet/Authentication/OpenAIAuthentication.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; using System.Text.Json; diff --git a/OpenAI-DotNet/Authentication/OpenAIClientSettings.cs b/OpenAI-DotNet/Authentication/OpenAIClientSettings.cs index 26ae3183..da1a0fcb 100644 --- a/OpenAI-DotNet/Authentication/OpenAIClientSettings.cs +++ b/OpenAI-DotNet/Authentication/OpenAIClientSettings.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; namespace OpenAI diff --git a/OpenAI-DotNet/Chat/ChatEndpoint.cs b/OpenAI-DotNet/Chat/ChatEndpoint.cs index 83e486e4..6bf0c3ae 100644 --- a/OpenAI-DotNet/Chat/ChatEndpoint.cs +++ b/OpenAI-DotNet/Chat/ChatEndpoint.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System; using System.Collections.Generic; diff --git a/OpenAI-DotNet/Chat/ChatRequest.cs b/OpenAI-DotNet/Chat/ChatRequest.cs index 43817c93..11285fc3 100644 --- a/OpenAI-DotNet/Chat/ChatRequest.cs +++ b/OpenAI-DotNet/Chat/ChatRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Linq; @@ -9,49 +11,6 @@ namespace OpenAI.Chat { public sealed class ChatRequest { - /// - [Obsolete("Use new constructor arguments")] - public ChatRequest( - IEnumerable messages, - IEnumerable functions, - string functionCall = null, - string model = null, - double? temperature = null, - double? topP = null, - int? number = null, - string[] stops = null, - int? maxTokens = null, - double? presencePenalty = null, - double? frequencyPenalty = null, - IReadOnlyDictionary logitBias = null, - string user = null) - : this(messages, model, frequencyPenalty, logitBias, maxTokens, number, presencePenalty, ChatResponseFormat.Text, maxTokens, stops, temperature, topP, user) - { - var functionList = functions?.ToList(); - - if (functionList != null && functionList.Any()) - { - if (string.IsNullOrWhiteSpace(functionCall)) - { - FunctionCall = "auto"; - } - else - { - if (!functionCall.Equals("none") && - !functionCall.Equals("auto")) - { - FunctionCall = new JsonObject { ["name"] = functionCall }; - } - else - { - FunctionCall = functionCall; - } - } - } - - Functions = functionList?.ToList(); - } - /// public ChatRequest( IEnumerable messages, @@ -67,8 +26,9 @@ public ChatRequest( string[] stops = null, double? temperature = null, double? topP = null, + int? topLogProbs = null, string user = null) - : this(messages, model, frequencyPenalty, logitBias, maxTokens, number, presencePenalty, responseFormat, number, stops, temperature, topP, user) + : this(messages, model, frequencyPenalty, logitBias, maxTokens, number, presencePenalty, responseFormat, number, stops, temperature, topP, topLogProbs, user) { var tooList = tools?.ToList(); @@ -164,6 +124,10 @@ public ChatRequest( /// in a ban or exclusive selection of the relevant token.
/// Defaults to null /// + /// + /// An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, + /// each with an associated log probability. + /// /// /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. /// @@ -180,6 +144,7 @@ public ChatRequest( string[] stops = null, double? temperature = null, double? topP = null, + int? topLogProbs = null, string user = null) { Messages = messages?.ToList(); @@ -200,6 +165,8 @@ public ChatRequest( Stops = stops; Temperature = temperature; TopP = topP; + LogProbs = topLogProbs.HasValue ? topLogProbs.Value > 0 : null; + TopLogProbs = topLogProbs; User = user; } @@ -236,6 +203,28 @@ public ChatRequest( [JsonPropertyName("logit_bias")] public IReadOnlyDictionary LogitBias { get; } + /// + /// Whether to return log probabilities of the output tokens or not. + /// If true, returns the log probabilities of each output token returned in the content of message. + /// + /// + /// This option is currently not available on the gpt-4-vision-preview model. + /// + [JsonPropertyName("logprobs")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool? LogProbs { get; } + + /// + /// An integer between 0 and 5 specifying the number of most likely tokens to return at each token position, + /// each with an associated log probability. + /// + /// + /// must be set to true if this parameter is used. + /// + [JsonPropertyName("top_logprobs")] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public int? TopLogProbs { get; } + /// /// The maximum number of tokens allowed for the generated answer. /// By default, the number of tokens the model can return will be (4096 - prompt tokens). diff --git a/OpenAI-DotNet/Chat/ChatResponse.cs b/OpenAI-DotNet/Chat/ChatResponse.cs index e3afe48c..4491ee00 100644 --- a/OpenAI-DotNet/Chat/ChatResponse.cs +++ b/OpenAI-DotNet/Chat/ChatResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Linq; diff --git a/OpenAI-DotNet/Chat/ChatResponseFormat.cs b/OpenAI-DotNet/Chat/ChatResponseFormat.cs index 18a9b95f..28ab467c 100644 --- a/OpenAI-DotNet/Chat/ChatResponseFormat.cs +++ b/OpenAI-DotNet/Chat/ChatResponseFormat.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI.Chat diff --git a/OpenAI-DotNet/Chat/Choice.cs b/OpenAI-DotNet/Chat/Choice.cs index 87f12862..d2b20486 100644 --- a/OpenAI-DotNet/Chat/Choice.cs +++ b/OpenAI-DotNet/Chat/Choice.cs @@ -1,19 +1,34 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Chat { public sealed class Choice { + /// + /// A chat completion message generated by the model. + /// [JsonInclude] [JsonPropertyName("message")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Message Message { get; private set; } + /// + /// A chat completion delta generated by streamed model responses. + /// [JsonInclude] [JsonPropertyName("delta")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Delta Delta { get; private set; } + /// + /// The reason the model stopped generating tokens. + /// This will be stop if the model hit a natural stop point or a provided stop sequence, + /// length if the maximum number of tokens specified in the request was reached, + /// content_filter if content was omitted due to a flag from our content filters, + /// tool_calls if the model called a tool, or function_call (deprecated) if the model called a function. + /// [JsonInclude] [JsonPropertyName("finish_reason")] public string FinishReason { get; private set; } @@ -22,16 +37,28 @@ public sealed class Choice [JsonPropertyName("finish_details")] public FinishDetails FinishDetails { get; private set; } + /// + /// The index of the choice in the list of choices. + /// [JsonInclude] [JsonPropertyName("index")] public int Index { get; private set; } + /// + /// Log probability information for the choice. + /// + [JsonInclude] + [JsonPropertyName("logprobs")] + public LogProbs LogProbs { get; private set; } + public override string ToString() => Message?.Content?.ToString() ?? Delta?.Content ?? string.Empty; public static implicit operator string(Choice choice) => choice?.ToString(); internal void CopyFrom(Choice other) { + Index = other?.Index ?? 0; + if (other?.Message != null) { Message = other.Message; @@ -49,6 +76,11 @@ internal void CopyFrom(Choice other) } } + if (other?.LogProbs != null) + { + LogProbs = other.LogProbs; + } + if (!string.IsNullOrWhiteSpace(other?.FinishReason)) { FinishReason = other.FinishReason; @@ -58,8 +90,6 @@ internal void CopyFrom(Choice other) { FinishDetails = other.FinishDetails; } - - Index = other?.Index ?? 0; } } } diff --git a/OpenAI-DotNet/Chat/Content.cs b/OpenAI-DotNet/Chat/Content.cs index 92d6822a..36a4d9f0 100644 --- a/OpenAI-DotNet/Chat/Content.cs +++ b/OpenAI-DotNet/Chat/Content.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; using OpenAI.Extensions; diff --git a/OpenAI-DotNet/Chat/Conversation.cs b/OpenAI-DotNet/Chat/Conversation.cs index 2714ee28..b228c481 100644 --- a/OpenAI-DotNet/Chat/Conversation.cs +++ b/OpenAI-DotNet/Chat/Conversation.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Chat/Delta.cs b/OpenAI-DotNet/Chat/Delta.cs index 9cd6e0e4..e1f033e0 100644 --- a/OpenAI-DotNet/Chat/Delta.cs +++ b/OpenAI-DotNet/Chat/Delta.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Chat/FinishDetails.cs b/OpenAI-DotNet/Chat/FinishDetails.cs index 7d2f49fc..b917237e 100644 --- a/OpenAI-DotNet/Chat/FinishDetails.cs +++ b/OpenAI-DotNet/Chat/FinishDetails.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Chat diff --git a/OpenAI-DotNet/Chat/LogProbInfo.cs b/OpenAI-DotNet/Chat/LogProbInfo.cs new file mode 100644 index 00000000..87a9d41e --- /dev/null +++ b/OpenAI-DotNet/Chat/LogProbInfo.cs @@ -0,0 +1,45 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace OpenAI.Chat +{ + /// + /// Contains log probability information. + /// + public sealed class LogProbInfo + { + /// + /// The token. + /// + [JsonInclude] + [JsonPropertyName("token")] + public string Token { get; private set; } + + /// + /// The log probability of this token. + /// + [JsonInclude] + [JsonPropertyName("logprob")] + public float LogProb { get; private set; } + + /// + /// A list of integers representing the UTF-8 bytes representation of the token. + /// Useful in instances where characters are represented by multiple tokens and their byte + /// representations must be combined to generate the correct text representation. + /// Can be null if there is no bytes representation for the token. + /// + [JsonInclude] + [JsonPropertyName("bytes")] + public int[] Bytes { get; private set; } + + /// + /// List of the most likely tokens and their log probability, at this token position. + /// In rare cases, there may be fewer than the number of requested top_logprobs returned. + /// + [JsonInclude] + [JsonPropertyName("top_logprobs")] + public IReadOnlyList TopLogProbs { get; private set; } + } +} \ No newline at end of file diff --git a/OpenAI-DotNet/Chat/LogProbs.cs b/OpenAI-DotNet/Chat/LogProbs.cs new file mode 100644 index 00000000..855c20aa --- /dev/null +++ b/OpenAI-DotNet/Chat/LogProbs.cs @@ -0,0 +1,20 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace OpenAI.Chat +{ + /// + /// Log probability information for the choice. + /// + public sealed class LogProbs + { + /// + /// A list of message content tokens with log probability information. + /// + [JsonInclude] + [JsonPropertyName("content")] + public IReadOnlyList Content { get; private set; } + } +} \ No newline at end of file diff --git a/OpenAI-DotNet/Chat/Message.cs b/OpenAI-DotNet/Chat/Message.cs index 80869a52..0917eb98 100644 --- a/OpenAI-DotNet/Chat/Message.cs +++ b/OpenAI-DotNet/Chat/Message.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Linq; diff --git a/OpenAI-DotNet/Chat/ResponseFormat.cs b/OpenAI-DotNet/Chat/ResponseFormat.cs index d96f00ab..b0864dd9 100644 --- a/OpenAI-DotNet/Chat/ResponseFormat.cs +++ b/OpenAI-DotNet/Chat/ResponseFormat.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; using OpenAI.Extensions; diff --git a/OpenAI-DotNet/Common/BaseEndPoint.cs b/OpenAI-DotNet/Common/BaseEndPoint.cs index 8ddacd3f..1da86097 100644 --- a/OpenAI-DotNet/Common/BaseEndPoint.cs +++ b/OpenAI-DotNet/Common/BaseEndPoint.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; using System.Linq; namespace OpenAI diff --git a/OpenAI-DotNet/Common/BaseResponse.cs b/OpenAI-DotNet/Common/BaseResponse.cs index 1e29dda7..18509460 100644 --- a/OpenAI-DotNet/Common/BaseResponse.cs +++ b/OpenAI-DotNet/Common/BaseResponse.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ContentType.cs b/OpenAI-DotNet/Common/ContentType.cs index f00e3c02..5129d303 100644 --- a/OpenAI-DotNet/Common/ContentType.cs +++ b/OpenAI-DotNet/Common/ContentType.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/DeletedResponse.cs b/OpenAI-DotNet/Common/DeletedResponse.cs index d6e2db3b..01558379 100644 --- a/OpenAI-DotNet/Common/DeletedResponse.cs +++ b/OpenAI-DotNet/Common/DeletedResponse.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI { diff --git a/OpenAI-DotNet/Common/Error.cs b/OpenAI-DotNet/Common/Error.cs index f6f16ad9..d6664633 100644 --- a/OpenAI-DotNet/Common/Error.cs +++ b/OpenAI-DotNet/Common/Error.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/Event.cs b/OpenAI-DotNet/Common/Event.cs index 7193fa20..71ecc16d 100644 --- a/OpenAI-DotNet/Common/Event.cs +++ b/OpenAI-DotNet/Common/Event.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/EventResponse.cs b/OpenAI-DotNet/Common/EventResponse.cs index 46a9f534..dd693593 100644 --- a/OpenAI-DotNet/Common/EventResponse.cs +++ b/OpenAI-DotNet/Common/EventResponse.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/Function.cs b/OpenAI-DotNet/Common/Function.cs index 267f2166..d27111cb 100644 --- a/OpenAI-DotNet/Common/Function.cs +++ b/OpenAI-DotNet/Common/Function.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Nodes; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Nodes; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/IListResponse.cs b/OpenAI-DotNet/Common/IListResponse.cs index d5120476..2a9c1f1c 100644 --- a/OpenAI-DotNet/Common/IListResponse.cs +++ b/OpenAI-DotNet/Common/IListResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ImageDetail.cs b/OpenAI-DotNet/Common/ImageDetail.cs index f026d81e..91c0e2f1 100644 --- a/OpenAI-DotNet/Common/ImageDetail.cs +++ b/OpenAI-DotNet/Common/ImageDetail.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ImageFile.cs b/OpenAI-DotNet/Common/ImageFile.cs index 70cb8021..8e801798 100644 --- a/OpenAI-DotNet/Common/ImageFile.cs +++ b/OpenAI-DotNet/Common/ImageFile.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ImageUrl.cs b/OpenAI-DotNet/Common/ImageUrl.cs index 704ce04a..c52fca39 100644 --- a/OpenAI-DotNet/Common/ImageUrl.cs +++ b/OpenAI-DotNet/Common/ImageUrl.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ListQuery.cs b/OpenAI-DotNet/Common/ListQuery.cs index 54ec5c79..f489c869 100644 --- a/OpenAI-DotNet/Common/ListQuery.cs +++ b/OpenAI-DotNet/Common/ListQuery.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; namespace OpenAI diff --git a/OpenAI-DotNet/Common/ListResponse.cs b/OpenAI-DotNet/Common/ListResponse.cs index 18afb19b..fa44885a 100644 --- a/OpenAI-DotNet/Common/ListResponse.cs +++ b/OpenAI-DotNet/Common/ListResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Common/Role.cs b/OpenAI-DotNet/Common/Role.cs index 82ab906a..f3ddf017 100644 --- a/OpenAI-DotNet/Common/Role.cs +++ b/OpenAI-DotNet/Common/Role.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; namespace OpenAI diff --git a/OpenAI-DotNet/Common/SortOrder.cs b/OpenAI-DotNet/Common/SortOrder.cs index 8f92dede..639b638e 100644 --- a/OpenAI-DotNet/Common/SortOrder.cs +++ b/OpenAI-DotNet/Common/SortOrder.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/Tool.cs b/OpenAI-DotNet/Common/Tool.cs index 8c7b8c66..d35f542a 100644 --- a/OpenAI-DotNet/Common/Tool.cs +++ b/OpenAI-DotNet/Common/Tool.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Common/Usage.cs b/OpenAI-DotNet/Common/Usage.cs index d33020f8..5180c54a 100644 --- a/OpenAI-DotNet/Common/Usage.cs +++ b/OpenAI-DotNet/Common/Usage.cs @@ -1,4 +1,6 @@ -using System.Text.Json; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json; using System.Text.Json.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Embeddings/Datum.cs b/OpenAI-DotNet/Embeddings/Datum.cs index 653ae252..6728d640 100644 --- a/OpenAI-DotNet/Embeddings/Datum.cs +++ b/OpenAI-DotNet/Embeddings/Datum.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; using System.Text.Json.Serialization; namespace OpenAI.Embeddings diff --git a/OpenAI-DotNet/Embeddings/EmbeddingsEndpoint.cs b/OpenAI-DotNet/Embeddings/EmbeddingsEndpoint.cs index 8929eada..d390590b 100644 --- a/OpenAI-DotNet/Embeddings/EmbeddingsEndpoint.cs +++ b/OpenAI-DotNet/Embeddings/EmbeddingsEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System.Collections.Generic; using System.Text.Json; using System.Threading; diff --git a/OpenAI-DotNet/Embeddings/EmbeddingsRequest.cs b/OpenAI-DotNet/Embeddings/EmbeddingsRequest.cs index 16554f34..5396e454 100644 --- a/OpenAI-DotNet/Embeddings/EmbeddingsRequest.cs +++ b/OpenAI-DotNet/Embeddings/EmbeddingsRequest.cs @@ -1,4 +1,6 @@ -using OpenAI.Models; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Models; using System; using System.Collections.Generic; using System.Linq; @@ -23,13 +25,12 @@ public sealed class EmbeddingsRequest /// /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. /// - /// A valid string is a Required parameter. public EmbeddingsRequest(string input, string model = null, string user = null) : this(new List { input }, model, user) { if (string.IsNullOrWhiteSpace(input)) { - throw new ArgumentNullException(nameof(input)); + throw new ArgumentNullException(nameof(input), $"Missing required {nameof(input)} parameter"); } } @@ -48,7 +49,6 @@ public EmbeddingsRequest(string input, string model = null, string user = null) /// /// A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. /// - /// A valid string is a Required parameter. public EmbeddingsRequest(IEnumerable input, string model = null, string user = null) { Input = input?.ToList(); diff --git a/OpenAI-DotNet/Embeddings/EmbeddingsResponse.cs b/OpenAI-DotNet/Embeddings/EmbeddingsResponse.cs index 00c392c9..e64a1b48 100644 --- a/OpenAI-DotNet/Embeddings/EmbeddingsResponse.cs +++ b/OpenAI-DotNet/Embeddings/EmbeddingsResponse.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; using System.Text.Json.Serialization; namespace OpenAI.Embeddings diff --git a/OpenAI-DotNet/Extensions/JsonStringEnumConverter.cs b/OpenAI-DotNet/Extensions/JsonStringEnumConverter.cs index 900950d7..5073553e 100644 --- a/OpenAI-DotNet/Extensions/JsonStringEnumConverter.cs +++ b/OpenAI-DotNet/Extensions/JsonStringEnumConverter.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; diff --git a/OpenAI-DotNet/Extensions/JsonStringEnumConverterFactory.cs b/OpenAI-DotNet/Extensions/JsonStringEnumConverterFactory.cs index 23f85618..cdb41327 100644 --- a/OpenAI-DotNet/Extensions/JsonStringEnumConverterFactory.cs +++ b/OpenAI-DotNet/Extensions/JsonStringEnumConverterFactory.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Extensions/ResponseExtensions.cs b/OpenAI-DotNet/Extensions/ResponseExtensions.cs index 0fc56def..19eaa39a 100644 --- a/OpenAI-DotNet/Extensions/ResponseExtensions.cs +++ b/OpenAI-DotNet/Extensions/ResponseExtensions.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Globalization; using System.Linq; using System.Net.Http; diff --git a/OpenAI-DotNet/Extensions/SnakeCaseNamingPolicy.cs b/OpenAI-DotNet/Extensions/SnakeCaseNamingPolicy.cs index 61504e33..5754663d 100644 --- a/OpenAI-DotNet/Extensions/SnakeCaseNamingPolicy.cs +++ b/OpenAI-DotNet/Extensions/SnakeCaseNamingPolicy.cs @@ -1,4 +1,6 @@ -using System.Text.Json; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json; namespace OpenAI.Extensions { diff --git a/OpenAI-DotNet/Extensions/StringExtensions.cs b/OpenAI-DotNet/Extensions/StringExtensions.cs index 10ebb3fa..4308767a 100644 --- a/OpenAI-DotNet/Extensions/StringExtensions.cs +++ b/OpenAI-DotNet/Extensions/StringExtensions.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Linq; using System.Net.Http; using System.Text; diff --git a/OpenAI-DotNet/Files/FileData.cs b/OpenAI-DotNet/Files/FileData.cs index e781cfd1..8488beb1 100644 --- a/OpenAI-DotNet/Files/FileData.cs +++ b/OpenAI-DotNet/Files/FileData.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI.Files diff --git a/OpenAI-DotNet/Files/FileResponse.cs b/OpenAI-DotNet/Files/FileResponse.cs index a3ab1263..6d21a743 100644 --- a/OpenAI-DotNet/Files/FileResponse.cs +++ b/OpenAI-DotNet/Files/FileResponse.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI.Files diff --git a/OpenAI-DotNet/Files/FileUploadRequest.cs b/OpenAI-DotNet/Files/FileUploadRequest.cs index e3c39933..93f5a983 100644 --- a/OpenAI-DotNet/Files/FileUploadRequest.cs +++ b/OpenAI-DotNet/Files/FileUploadRequest.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; namespace OpenAI.Files diff --git a/OpenAI-DotNet/Files/FilesEndpoint.cs b/OpenAI-DotNet/Files/FilesEndpoint.cs index a6019ef6..4254407d 100644 --- a/OpenAI-DotNet/Files/FilesEndpoint.cs +++ b/OpenAI-DotNet/Files/FilesEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.Collections.Generic; using System.IO; diff --git a/OpenAI-DotNet/FineTuning/CreateFineTuneJobRequest.cs b/OpenAI-DotNet/FineTuning/CreateFineTuneJobRequest.cs index 0df576d3..c21248e6 100644 --- a/OpenAI-DotNet/FineTuning/CreateFineTuneJobRequest.cs +++ b/OpenAI-DotNet/FineTuning/CreateFineTuneJobRequest.cs @@ -1,4 +1,6 @@ -using OpenAI.Models; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Models; using System.Text.Json.Serialization; namespace OpenAI.FineTuning diff --git a/OpenAI-DotNet/FineTuning/EventList.cs b/OpenAI-DotNet/FineTuning/EventList.cs index af6746ba..dfcbe9a0 100644 --- a/OpenAI-DotNet/FineTuning/EventList.cs +++ b/OpenAI-DotNet/FineTuning/EventList.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/FineTuning/FineTuneJob.cs b/OpenAI-DotNet/FineTuning/FineTuneJob.cs index 785db76f..3ec115d5 100644 --- a/OpenAI-DotNet/FineTuning/FineTuneJob.cs +++ b/OpenAI-DotNet/FineTuning/FineTuneJob.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/FineTuning/FineTuneJobList.cs b/OpenAI-DotNet/FineTuning/FineTuneJobList.cs index 53966a7f..60dabe03 100644 --- a/OpenAI-DotNet/FineTuning/FineTuneJobList.cs +++ b/OpenAI-DotNet/FineTuning/FineTuneJobList.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/FineTuning/FineTuneJobResponse.cs b/OpenAI-DotNet/FineTuning/FineTuneJobResponse.cs index 48f5941a..39698615 100644 --- a/OpenAI-DotNet/FineTuning/FineTuneJobResponse.cs +++ b/OpenAI-DotNet/FineTuning/FineTuneJobResponse.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/FineTuning/FineTuningEndpoint.cs b/OpenAI-DotNet/FineTuning/FineTuningEndpoint.cs index f9aa8878..d64f195c 100644 --- a/OpenAI-DotNet/FineTuning/FineTuningEndpoint.cs +++ b/OpenAI-DotNet/FineTuning/FineTuningEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.Collections.Generic; using System.Text.Json; diff --git a/OpenAI-DotNet/FineTuning/HyperParameters.cs b/OpenAI-DotNet/FineTuning/HyperParameters.cs index bda27412..948f9b2f 100644 --- a/OpenAI-DotNet/FineTuning/HyperParameters.cs +++ b/OpenAI-DotNet/FineTuning/HyperParameters.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.FineTuning { diff --git a/OpenAI-DotNet/FineTuning/HyperParams.cs b/OpenAI-DotNet/FineTuning/HyperParams.cs index 8d137055..5b5282b9 100644 --- a/OpenAI-DotNet/FineTuning/HyperParams.cs +++ b/OpenAI-DotNet/FineTuning/HyperParams.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.FineTuning { diff --git a/OpenAI-DotNet/FineTuning/JobStatus.cs b/OpenAI-DotNet/FineTuning/JobStatus.cs index 38da1c6c..d5f6f8a5 100644 --- a/OpenAI-DotNet/FineTuning/JobStatus.cs +++ b/OpenAI-DotNet/FineTuning/JobStatus.cs @@ -1,4 +1,6 @@ -namespace OpenAI.FineTuning +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace OpenAI.FineTuning { public enum JobStatus { diff --git a/OpenAI-DotNet/Images/AbstractBaseImageRequest.cs b/OpenAI-DotNet/Images/AbstractBaseImageRequest.cs index d30ba7b0..cf9b3599 100644 --- a/OpenAI-DotNet/Images/AbstractBaseImageRequest.cs +++ b/OpenAI-DotNet/Images/AbstractBaseImageRequest.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Images/ImageEditRequest.cs b/OpenAI-DotNet/Images/ImageEditRequest.cs index 2fc813c1..d298b623 100644 --- a/OpenAI-DotNet/Images/ImageEditRequest.cs +++ b/OpenAI-DotNet/Images/ImageEditRequest.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; namespace OpenAI.Images diff --git a/OpenAI-DotNet/Images/ImageGenerationRequest.cs b/OpenAI-DotNet/Images/ImageGenerationRequest.cs index 797281e1..cca15d0b 100644 --- a/OpenAI-DotNet/Images/ImageGenerationRequest.cs +++ b/OpenAI-DotNet/Images/ImageGenerationRequest.cs @@ -1,4 +1,6 @@ -using OpenAI.Models; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Models; using System; using System.Text.Json.Serialization; using OpenAI.Extensions; diff --git a/OpenAI-DotNet/Images/ImageResult.cs b/OpenAI-DotNet/Images/ImageResult.cs index 079aef15..d47187f7 100644 --- a/OpenAI-DotNet/Images/ImageResult.cs +++ b/OpenAI-DotNet/Images/ImageResult.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.Images { diff --git a/OpenAI-DotNet/Images/ImageSize.cs b/OpenAI-DotNet/Images/ImageSize.cs index 6087f895..0c7d458f 100644 --- a/OpenAI-DotNet/Images/ImageSize.cs +++ b/OpenAI-DotNet/Images/ImageSize.cs @@ -1,4 +1,6 @@ -namespace OpenAI.Images +// Licensed under the MIT License. See LICENSE in the project root for license information. + +namespace OpenAI.Images { public enum ImageSize { diff --git a/OpenAI-DotNet/Images/ImageVariationRequest.cs b/OpenAI-DotNet/Images/ImageVariationRequest.cs index 24cb53b4..a4948e82 100644 --- a/OpenAI-DotNet/Images/ImageVariationRequest.cs +++ b/OpenAI-DotNet/Images/ImageVariationRequest.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.IO; namespace OpenAI.Images diff --git a/OpenAI-DotNet/Images/ImagesEndpoint.cs b/OpenAI-DotNet/Images/ImagesEndpoint.cs index 4f4930ef..3f6f39f6 100644 --- a/OpenAI-DotNet/Images/ImagesEndpoint.cs +++ b/OpenAI-DotNet/Images/ImagesEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.Collections.Generic; using System.IO; diff --git a/OpenAI-DotNet/Images/ImagesResponse.cs b/OpenAI-DotNet/Images/ImagesResponse.cs index 79254f75..addd5e00 100644 --- a/OpenAI-DotNet/Images/ImagesResponse.cs +++ b/OpenAI-DotNet/Images/ImagesResponse.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; using System.Text.Json.Serialization; namespace OpenAI.Images diff --git a/OpenAI-DotNet/Images/ResponseFormat.cs b/OpenAI-DotNet/Images/ResponseFormat.cs index 180d07d1..24c23246 100644 --- a/OpenAI-DotNet/Images/ResponseFormat.cs +++ b/OpenAI-DotNet/Images/ResponseFormat.cs @@ -1,4 +1,6 @@ -using System.Runtime.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Runtime.Serialization; namespace OpenAI.Images { diff --git a/OpenAI-DotNet/Models/Model.cs b/OpenAI-DotNet/Models/Model.cs index 583a5374..6ed3e7ef 100644 --- a/OpenAI-DotNet/Models/Model.cs +++ b/OpenAI-DotNet/Models/Model.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Models/ModelsEndpoint.cs b/OpenAI-DotNet/Models/ModelsEndpoint.cs index ab04fd98..db99dc74 100644 --- a/OpenAI-DotNet/Models/ModelsEndpoint.cs +++ b/OpenAI-DotNet/Models/ModelsEndpoint.cs @@ -1,4 +1,6 @@ -using OpenAI.Extensions; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Extensions; using System; using System.Collections.Generic; using System.Text.Json; diff --git a/OpenAI-DotNet/Models/Permission.cs b/OpenAI-DotNet/Models/Permission.cs index c046cf12..b7cde025 100644 --- a/OpenAI-DotNet/Models/Permission.cs +++ b/OpenAI-DotNet/Models/Permission.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI.Models diff --git a/OpenAI-DotNet/Moderations/Categories.cs b/OpenAI-DotNet/Moderations/Categories.cs index f2a12ec8..768d5fd2 100644 --- a/OpenAI-DotNet/Moderations/Categories.cs +++ b/OpenAI-DotNet/Moderations/Categories.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.Moderations { diff --git a/OpenAI-DotNet/Moderations/ModerationResult.cs b/OpenAI-DotNet/Moderations/ModerationResult.cs index 83ece0e3..5ece4cc0 100644 --- a/OpenAI-DotNet/Moderations/ModerationResult.cs +++ b/OpenAI-DotNet/Moderations/ModerationResult.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.Moderations { diff --git a/OpenAI-DotNet/Moderations/ModerationsEndpoint.cs b/OpenAI-DotNet/Moderations/ModerationsEndpoint.cs index cc3993ea..8cc0ff22 100644 --- a/OpenAI-DotNet/Moderations/ModerationsEndpoint.cs +++ b/OpenAI-DotNet/Moderations/ModerationsEndpoint.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System; using System.Linq; diff --git a/OpenAI-DotNet/Moderations/ModerationsRequest.cs b/OpenAI-DotNet/Moderations/ModerationsRequest.cs index 4891c63c..a8dfc7e6 100644 --- a/OpenAI-DotNet/Moderations/ModerationsRequest.cs +++ b/OpenAI-DotNet/Moderations/ModerationsRequest.cs @@ -1,4 +1,6 @@ -using System.Text.Json.Serialization; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Text.Json.Serialization; namespace OpenAI.Moderations { diff --git a/OpenAI-DotNet/Moderations/ModerationsResponse.cs b/OpenAI-DotNet/Moderations/ModerationsResponse.cs index 9c5b9de7..a670802f 100644 --- a/OpenAI-DotNet/Moderations/ModerationsResponse.cs +++ b/OpenAI-DotNet/Moderations/ModerationsResponse.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System.Collections.Generic; using System.Text.Json.Serialization; namespace OpenAI.Moderations diff --git a/OpenAI-DotNet/Moderations/Scores.cs b/OpenAI-DotNet/Moderations/Scores.cs index 7e395463..5b6b519c 100644 --- a/OpenAI-DotNet/Moderations/Scores.cs +++ b/OpenAI-DotNet/Moderations/Scores.cs @@ -1,4 +1,6 @@ -using System; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Text.Json.Serialization; namespace OpenAI.Moderations diff --git a/OpenAI-DotNet/OpenAI-DotNet.csproj b/OpenAI-DotNet/OpenAI-DotNet.csproj index 0b765b0d..dba6722e 100644 --- a/OpenAI-DotNet/OpenAI-DotNet.csproj +++ b/OpenAI-DotNet/OpenAI-DotNet.csproj @@ -2,9 +2,12 @@ net6.0 latest - false - Stephen Hodgson OpenAI-DotNet + OpenAI-DotNet + OpenAI-DotNet + RageAgainstThePixel + Stephen Hodgson, Roger Pincombe + 2024 A simple C# .NET client library for OpenAI to use though their RESTful API. Independently developed, this is not an official library and I am not affiliated with OpenAI. An OpenAI API account is required. @@ -12,14 +15,26 @@ An OpenAI API account is required. Forked from [OpenAI-API-dotnet](https://github.com/OkGoDoIt/OpenAI-API-dotnet). More context [on Roger Pincombe's blog](https://rogerpincombe.com/openai-dotnet-api). - 2023 - CC0-1.0 + true https://github.com/RageAgainstThePixel/OpenAI-DotNet https://github.com/RageAgainstThePixel/OpenAI-DotNet OpenAI, AI, ML, API, gpt-4, gpt-3.5-tubo, gpt-3, chatGPT, chat-gpt, gpt-2, gpt, dall-e-2, dall-e-3 - OpenAI-DotNet - 7.5.0 + false + README.md + LICENSE + Assets\OpenAI-DotNet-Icon.png + true + false + OpenAI-DotNet.pfx + True + True + 7.6.0 +Version 7.6.0 +- Changed License to MIT +- Added OpenAI.Chat logprob parameters +- Added SourceLink references for debugging +- Added Docfx build workflow Version 7.5.0 - Changed OpenAIClient to implement IDisposable. - Disposing OpenAICLient is now required if you're not passing a custom HttpClient. @@ -243,16 +258,7 @@ Version 4.4.0 - Updated CompletionRequest to accept IEnumerable<string> values for prompts and stopSequences - Refactored all endpoints to use new response validation extension - Added CancellationToken to most endpoints that had long running operations - - false - OpenAI-DotNet.pfx - true - OpenAI-DotNet - RageAgainstThePixel - README.md - Assets\OpenAI-DotNet-Icon.png - True - True + @@ -260,6 +266,12 @@ Version 4.4.0 \ + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + True diff --git a/OpenAI-DotNet/OpenAIClient.cs b/OpenAI-DotNet/OpenAIClient.cs index 02a673e0..976fbc75 100644 --- a/OpenAI-DotNet/OpenAIClient.cs +++ b/OpenAI-DotNet/OpenAIClient.cs @@ -1,4 +1,6 @@ -using OpenAI.Assistants; +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using OpenAI.Assistants; using OpenAI.Audio; using OpenAI.Chat; using OpenAI.Completions; @@ -34,10 +36,18 @@ public sealed class OpenAIClient : IDisposable /// potentially loading from environment vars or from a config file. /// /// - /// Optional, for specifying OpenAI deployments to Azure or proxy domain. + /// The API client settings for specifying OpenAI deployments to Azure, a proxy domain, + /// or to attempt to use the , + /// potentially loading from environment vars or from a config file. /// /// A . /// Raised when authentication details are missing or invalid. + /// + /// implements to manage the lifecycle of the resources it uses, including . + /// When you initialize , it will create an internal instance if one is not provided. + /// This internal HttpClient is disposed of when OpenAIClient is disposed of. + /// If you provide an external HttpClient instance to OpenAIClient, you are responsible for managing its disposal. + /// public OpenAIClient(OpenAIAuthentication openAIAuthentication = null, OpenAIClientSettings clientSettings = null, HttpClient client = null) { OpenAIAuthentication = openAIAuthentication ?? OpenAIAuthentication.Default; diff --git a/OpenAI-DotNet/Threads/Annotation.cs b/OpenAI-DotNet/Threads/Annotation.cs index 703fd573..586416d4 100644 --- a/OpenAI-DotNet/Threads/Annotation.cs +++ b/OpenAI-DotNet/Threads/Annotation.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/AnnotationType.cs b/OpenAI-DotNet/Threads/AnnotationType.cs index 2f180f0c..e767c346 100644 --- a/OpenAI-DotNet/Threads/AnnotationType.cs +++ b/OpenAI-DotNet/Threads/AnnotationType.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI diff --git a/OpenAI-DotNet/Threads/CodeInterpreter.cs b/OpenAI-DotNet/Threads/CodeInterpreter.cs index 260bc8fc..e48723fb 100644 --- a/OpenAI-DotNet/Threads/CodeInterpreter.cs +++ b/OpenAI-DotNet/Threads/CodeInterpreter.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/CodeInterpreterImageOutput.cs b/OpenAI-DotNet/Threads/CodeInterpreterImageOutput.cs index 1bef8dd3..d5401e97 100644 --- a/OpenAI-DotNet/Threads/CodeInterpreterImageOutput.cs +++ b/OpenAI-DotNet/Threads/CodeInterpreterImageOutput.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/CodeInterpreterOutputType.cs b/OpenAI-DotNet/Threads/CodeInterpreterOutputType.cs index 9353318e..727afe95 100644 --- a/OpenAI-DotNet/Threads/CodeInterpreterOutputType.cs +++ b/OpenAI-DotNet/Threads/CodeInterpreterOutputType.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/CodeInterpreterOutputs.cs b/OpenAI-DotNet/Threads/CodeInterpreterOutputs.cs index 77c5662e..f7070fa1 100644 --- a/OpenAI-DotNet/Threads/CodeInterpreterOutputs.cs +++ b/OpenAI-DotNet/Threads/CodeInterpreterOutputs.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/Content.cs b/OpenAI-DotNet/Threads/Content.cs index e1db35f8..597b28b5 100644 --- a/OpenAI-DotNet/Threads/Content.cs +++ b/OpenAI-DotNet/Threads/Content.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/ContentText.cs b/OpenAI-DotNet/Threads/ContentText.cs index f26f0fd3..a2dc32c2 100644 --- a/OpenAI-DotNet/Threads/ContentText.cs +++ b/OpenAI-DotNet/Threads/ContentText.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/CreateMessageRequest.cs b/OpenAI-DotNet/Threads/CreateMessageRequest.cs index 8aa8a03a..556eda8e 100644 --- a/OpenAI-DotNet/Threads/CreateMessageRequest.cs +++ b/OpenAI-DotNet/Threads/CreateMessageRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/CreateRunRequest.cs b/OpenAI-DotNet/Threads/CreateRunRequest.cs index 88fba8e6..48765a6b 100644 --- a/OpenAI-DotNet/Threads/CreateRunRequest.cs +++ b/OpenAI-DotNet/Threads/CreateRunRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/CreateThreadAndRunRequest.cs b/OpenAI-DotNet/Threads/CreateThreadAndRunRequest.cs index 9ae286a2..fe867b7d 100644 --- a/OpenAI-DotNet/Threads/CreateThreadAndRunRequest.cs +++ b/OpenAI-DotNet/Threads/CreateThreadAndRunRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/CreateThreadRequest.cs b/OpenAI-DotNet/Threads/CreateThreadRequest.cs index 101dcd7c..cb0d1c6b 100644 --- a/OpenAI-DotNet/Threads/CreateThreadRequest.cs +++ b/OpenAI-DotNet/Threads/CreateThreadRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/FileCitation.cs b/OpenAI-DotNet/Threads/FileCitation.cs index 00ce8af7..80c74543 100644 --- a/OpenAI-DotNet/Threads/FileCitation.cs +++ b/OpenAI-DotNet/Threads/FileCitation.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/FilePath.cs b/OpenAI-DotNet/Threads/FilePath.cs index 77d0b768..2d476156 100644 --- a/OpenAI-DotNet/Threads/FilePath.cs +++ b/OpenAI-DotNet/Threads/FilePath.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/FunctionCall.cs b/OpenAI-DotNet/Threads/FunctionCall.cs index df75e1bb..86862d35 100644 --- a/OpenAI-DotNet/Threads/FunctionCall.cs +++ b/OpenAI-DotNet/Threads/FunctionCall.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/Message.cs b/OpenAI-DotNet/Threads/Message.cs index 64017a46..f60795b9 100644 --- a/OpenAI-DotNet/Threads/Message.cs +++ b/OpenAI-DotNet/Threads/Message.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/MessageFileResponse.cs b/OpenAI-DotNet/Threads/MessageFileResponse.cs index e6d76b6f..ad483d8b 100644 --- a/OpenAI-DotNet/Threads/MessageFileResponse.cs +++ b/OpenAI-DotNet/Threads/MessageFileResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/MessageResponse.cs b/OpenAI-DotNet/Threads/MessageResponse.cs index 6c3e105f..e62243f9 100644 --- a/OpenAI-DotNet/Threads/MessageResponse.cs +++ b/OpenAI-DotNet/Threads/MessageResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Linq; diff --git a/OpenAI-DotNet/Threads/RequiredAction.cs b/OpenAI-DotNet/Threads/RequiredAction.cs index 3025d684..5fb5c376 100644 --- a/OpenAI-DotNet/Threads/RequiredAction.cs +++ b/OpenAI-DotNet/Threads/RequiredAction.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/RunResponse.cs b/OpenAI-DotNet/Threads/RunResponse.cs index eacdba19..a3a639b7 100644 --- a/OpenAI-DotNet/Threads/RunResponse.cs +++ b/OpenAI-DotNet/Threads/RunResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System; using System.Collections.Generic; @@ -7,7 +9,7 @@ namespace OpenAI.Threads { /// /// An invocation of an Assistant on a Thread. - /// The Assistant uses it�s configuration and the Thread�s Messages to perform tasks by calling models and tools. + /// The Assistant uses it's configuration and the Thread's Messages to perform tasks by calling models and tools. /// As part of a Run, the Assistant appends Messages to the Thread. /// public sealed class RunResponse : BaseResponse diff --git a/OpenAI-DotNet/Threads/RunStatus.cs b/OpenAI-DotNet/Threads/RunStatus.cs index da50011d..0baf79b8 100644 --- a/OpenAI-DotNet/Threads/RunStatus.cs +++ b/OpenAI-DotNet/Threads/RunStatus.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/RunStepMessageCreation.cs b/OpenAI-DotNet/Threads/RunStepMessageCreation.cs index a3697097..eb3dc75d 100644 --- a/OpenAI-DotNet/Threads/RunStepMessageCreation.cs +++ b/OpenAI-DotNet/Threads/RunStepMessageCreation.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/RunStepResponse.cs b/OpenAI-DotNet/Threads/RunStepResponse.cs index 4b4543bf..cabf0c3f 100644 --- a/OpenAI-DotNet/Threads/RunStepResponse.cs +++ b/OpenAI-DotNet/Threads/RunStepResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System; using System.Collections.Generic; @@ -7,8 +9,8 @@ namespace OpenAI.Threads { /// /// A detailed list of steps the Assistant took as part of a Run. - /// An Assistant can call tools or create Messages during it�s run. - /// Examining Run Steps allows you to introspect how the Assistant is getting to it�s final results. + /// An Assistant can call tools or create Messages during it's run. + /// Examining Run Steps allows you to introspect how the Assistant is getting to it's final results. /// public sealed class RunStepResponse : BaseResponse { diff --git a/OpenAI-DotNet/Threads/RunStepType.cs b/OpenAI-DotNet/Threads/RunStepType.cs index 6ba91a26..7c438e8d 100644 --- a/OpenAI-DotNet/Threads/RunStepType.cs +++ b/OpenAI-DotNet/Threads/RunStepType.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Runtime.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/StepDetails.cs b/OpenAI-DotNet/Threads/StepDetails.cs index 32b3c684..dd2f735c 100644 --- a/OpenAI-DotNet/Threads/StepDetails.cs +++ b/OpenAI-DotNet/Threads/StepDetails.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/SubmitToolOutputs.cs b/OpenAI-DotNet/Threads/SubmitToolOutputs.cs index c496c3f7..810d3c63 100644 --- a/OpenAI-DotNet/Threads/SubmitToolOutputs.cs +++ b/OpenAI-DotNet/Threads/SubmitToolOutputs.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/SubmitToolOutputsRequest.cs b/OpenAI-DotNet/Threads/SubmitToolOutputsRequest.cs index 97fab3c0..6c05c0ce 100644 --- a/OpenAI-DotNet/Threads/SubmitToolOutputsRequest.cs +++ b/OpenAI-DotNet/Threads/SubmitToolOutputsRequest.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/TextContent.cs b/OpenAI-DotNet/Threads/TextContent.cs index 1485e661..b6402607 100644 --- a/OpenAI-DotNet/Threads/TextContent.cs +++ b/OpenAI-DotNet/Threads/TextContent.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Collections.Generic; using System.Text.Json.Serialization; diff --git a/OpenAI-DotNet/Threads/ThreadExtensions.cs b/OpenAI-DotNet/Threads/ThreadExtensions.cs index 770254ae..a56199df 100644 --- a/OpenAI-DotNet/Threads/ThreadExtensions.cs +++ b/OpenAI-DotNet/Threads/ThreadExtensions.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Threading; diff --git a/OpenAI-DotNet/Threads/ThreadResponse.cs b/OpenAI-DotNet/Threads/ThreadResponse.cs index b860abf1..cd458cd1 100644 --- a/OpenAI-DotNet/Threads/ThreadResponse.cs +++ b/OpenAI-DotNet/Threads/ThreadResponse.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -6,7 +8,7 @@ namespace OpenAI.Threads { /// /// A conversation session between an Assistant and a user. - /// Threads store Messages and automatically handle truncation to fit content into a model�s context. + /// Threads store Messages and automatically handle truncation to fit content into a model's context. /// public sealed class ThreadResponse : BaseResponse { diff --git a/OpenAI-DotNet/Threads/ThreadsEndpoint.cs b/OpenAI-DotNet/Threads/ThreadsEndpoint.cs index b613f11b..c9b03f7c 100644 --- a/OpenAI-DotNet/Threads/ThreadsEndpoint.cs +++ b/OpenAI-DotNet/Threads/ThreadsEndpoint.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using OpenAI.Extensions; using System.Collections.Generic; using System.Text.Json; diff --git a/OpenAI-DotNet/Threads/ToolCall.cs b/OpenAI-DotNet/Threads/ToolCall.cs index 37dc4a0d..274588a3 100644 --- a/OpenAI-DotNet/Threads/ToolCall.cs +++ b/OpenAI-DotNet/Threads/ToolCall.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/OpenAI-DotNet/Threads/ToolOutput.cs b/OpenAI-DotNet/Threads/ToolOutput.cs index a89f2e26..76eb45f9 100644 --- a/OpenAI-DotNet/Threads/ToolOutput.cs +++ b/OpenAI-DotNet/Threads/ToolOutput.cs @@ -1,3 +1,5 @@ +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System.Text.Json.Serialization; namespace OpenAI.Threads diff --git a/README.md b/README.md index 7942c3fc..4db0cb19 100644 --- a/README.md +++ b/README.md @@ -1398,9 +1398,3 @@ var request = new EditRequest("What day of the wek is it?", "Fix the spelling mi var response = await api.EditsEndpoint.CreateEditAsync(request); Console.WriteLine(response); ``` - -## License - -![CC-0 Public Domain](https://licensebuttons.net/p/zero/1.0/88x31.png) - -This library is licensed CC-0, in the public domain. You can use it for whatever you want, publicly or privately, without worrying about permission or licensing or whatever. It's just a wrapper around the OpenAI API, so you still need to get access to OpenAI from them directly. I am not affiliated with OpenAI and this library is not endorsed by them, I just have beta access and wanted to make a C# library to access it more easily. Hopefully others find this useful as well. Feel free to open a PR if there's anything you want to contribute.