Skip to content

Commit b66b7b6

Browse files
committed
Update readme, fix signing key, fix typos and spelling
1 parent 0876a15 commit b66b7b6

File tree

6 files changed

+58
-18
lines changed

6 files changed

+58
-18
lines changed

OpenAI_API/Completions/CompletionEndpoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class CompletionEndpoint : EndpointBase
1717
public CompletionRequest DefaultCompletionRequestArgs { get; set; } = new CompletionRequest() { Model = Model.DavinciText };
1818

1919
/// <summary>
20-
/// The name of the enpoint, which is the final path segment in the API URL. For example, "completions".
20+
/// The name of the endpoint, which is the final path segment in the API URL. For example, "completions".
2121
/// </summary>
2222
protected override string Endpoint { get { return "completions"; } }
2323

OpenAI_API/EndpointBase.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace OpenAI_API
1313
{
1414
/// <summary>
15-
/// A base object for any OpenAI API enpoint, encompassing common functionality
15+
/// A base object for any OpenAI API endpoint, encompassing common functionality
1616
/// </summary>
1717
public abstract class EndpointBase
1818
{
@@ -33,7 +33,7 @@ internal EndpointBase(OpenAIAPI api)
3333
}
3434

3535
/// <summary>
36-
/// The name of the enpoint, which is the final path segment in the API URL. Must be overriden in a derived class.
36+
/// The name of the endpoint, which is the final path segment in the API URL. Must be overriden in a derived class.
3737
/// </summary>
3838
protected abstract string Endpoint { get; }
3939

OpenAI_API/Files/FilesEndpoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class FilesEndpoint : EndpointBase
1818
internal FilesEndpoint(OpenAIAPI api) : base(api) { }
1919

2020
/// <summary>
21-
/// The name of the enpoint, which is the final path segment in the API URL. For example, "files".
21+
/// The name of the endpoint, which is the final path segment in the API URL. For example, "files".
2222
/// </summary>
2323
protected override string Endpoint { get { return "files"; } }
2424

OpenAI_API/Model/ModelsEndpoint.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace OpenAI_API.Models
1010
public class ModelsEndpoint : EndpointBase
1111
{
1212
/// <summary>
13-
/// The name of the enpoint, which is the final path segment in the API URL. For example, "models".
13+
/// The name of the endpoint, which is the final path segment in the API URL. For example, "models".
1414
/// </summary>
1515
protected override string Endpoint { get { return "models"; } }
1616

OpenAI_API/OpenAI_API.csproj

+5-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313
<RepositoryUrl>https://github.com/OkGoDoIt/OpenAI-API-dotnet</RepositoryUrl>
1414
<PackageTags>OpenAI, AI, ML, API</PackageTags>
1515
<Title>OpenAI API</Title>
16-
<PackageReleaseNotes>Updated to work with the current API as of January 12, 2023. Deprecate the Search endpoint as OpenAI has removed that API. This version includes breaking changes around specifying models to keep up with OpenAI API changes. If you had any code which used the old "engines", that will need to be updated to "models". Support for insertion, edits, and embedding is coming soon.</PackageReleaseNotes>
17-
<SignAssembly>True</SignAssembly>
18-
<AssemblyOriginatorKeyFile>D:\OneDrive - Roger Pincombe\Assets\rsa keys\okgodoit-signing.pfx</AssemblyOriginatorKeyFile>
19-
<DelaySign>false</DelaySign>
16+
<PackageReleaseNotes>Updated to work with the current API as of February 2, 2023. Added Files and Embedding endpoints. Removed the Search endpoint as OpenAI has removed that API.</PackageReleaseNotes>
2017
<PackageId>OpenAI</PackageId>
21-
<Version>1.3.0</Version>
22-
<AssemblyVersion>1.3.0.0</AssemblyVersion>
23-
<FileVersion>1.3.0.0</FileVersion>
18+
<Version>1.4.0</Version>
19+
<AssemblyVersion>1.4.0.0</AssemblyVersion>
20+
<FileVersion>1.4.0.0</FileVersion>
2421
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2522
<PackageReadmeFile>README.md</PackageReadmeFile>
23+
<ProduceReferenceAssembly>True</ProduceReferenceAssembly>
2624
</PropertyGroup>
2725

2826
<ItemGroup>

README.md

+48-6
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ A simple C# .NET wrapper library to use with OpenAI's GPT-3 API. More context [
55
## Status
66
Updated to work with the current API as of February 2, 2023. Added Files and Embedding endpoints. Removed the Search endpoint as OpenAI has removed that API.
77

8-
Thank you [@GotMike](https://github.com/gotmike), [@metjuperry](https://github.com/metjuperry), and [@Alexei000](https://github.com/Alexei000) for your contributions!
8+
Thank you [@GotMike](https://github.com/gotmike), [@gmilano](https://github.com/gmilano), [@metjuperry](https://github.com/metjuperry), and [@Alexei000](https://github.com/Alexei000) for your contributions!
99

1010
## Quick Example
1111

1212
```csharp
1313
var api = new OpenAI_API.OpenAIAPI();
1414

15-
var result = await api.Completions.CreateCompletionAsync("One Two Three One Two", temperature: 0.1);
16-
Console.WriteLine(result.ToString());
15+
var result = await api.Completions.GetCompletion("One Two Three One Two");
16+
Console.WriteLine(result);
1717
// should print something starting with "Three"
1818
```
1919

@@ -66,7 +66,7 @@ OpenAIAPI api = new OpenAIAPI(new APIAuthentication("YOUR_API_KEY","org-yourOrgH
6666
The Completion API is accessed via `OpenAIAPI.Completions`:
6767

6868
```csharp
69-
CreateCompletionAsync(CompletionRequest request)
69+
async Task<CompletionResult> CreateCompletionAsync(CompletionRequest request)
7070

7171
// for example
7272
var result = await api.Completions.CreateCompletionAsync(new CompletionRequest("One Two Three One Two", model: Model.CurieText, temperature: 0.1));
@@ -92,17 +92,59 @@ await foreach (var token in api.Completions.StreamCompletionEnumerableAsync(new
9292

9393
Or if using classic .NET framework or C# <8.0:
9494
```csharp
95-
StreamCompletionAsync(CompletionRequest request, Action<CompletionResult> resultHandler)
95+
async Task StreamCompletionAsync(CompletionRequest request, Action<CompletionResult> resultHandler)
9696

9797
// for example
9898
await api.Completions.StreamCompletionAsync(
9999
new CompletionRequest("My name is Roger and I am a principal software engineer at Salesforce. This is my resume:", Model.DavinciText, 200, 0.5, presencePenalty: 0.1, frequencyPenalty: 0.1),
100100
res => ResumeTextbox.Text += res.ToString());
101101
```
102102

103+
### Embeddings
104+
The Embedding API is accessed via `OpenAIAPI.Embeddings`:
105+
106+
```csharp
107+
async Task<EmbeddingResult> CreateEmbeddingAsync(EmbeddingRequest request)
108+
109+
// for example
110+
var result = await api.Embeddings.CreateEmbeddingAsync(new EmbeddingRequest("A test text for embedding", model: Model.AdaTextEmbedding));
111+
// or
112+
var result = await api.Completions.CreateCompletionAsync("A test text for embedding");
113+
```
114+
115+
The embedding result contains a lot of metadata, the actual vector of floats is in result.Data[].Embedding.
116+
117+
For simplicity, you can directly ask for the vector of floats and disgard the extra metadata with `api.Embeddings.GetEmbeddingsAsync("test text here")`
118+
119+
### Files (for fine-tuning)
120+
The Files API endpoint is accessed via `OpenAIAPI.Files`:
121+
122+
```csharp
123+
// uploading
124+
async Task<File> UploadFileAsync(string filePath, string purpose = "fine-tune")
125+
126+
// for example
127+
var response = await api.Files.UploadFileAsync("fine-tuning-data.jsonl");
128+
Console.Write(response.Id); //the id of the uploaded file
129+
130+
// listing
131+
async Task<List<File>> GetFilesAsync()
132+
133+
// for example
134+
var response = await api.Files.GetFilesAsync();
135+
foreach (var file in response)
136+
{
137+
Console.WriteLine(file.Name)
138+
}
139+
```
140+
141+
There are also methods to get file contents, delete a file, etc.
142+
143+
The fine-tuning endpoint itself has not yet been implemented, but will be added soon.
144+
103145
## Documentation
104146

105-
Every single class, method, and property has extensive XML documentation, so it should show up automatically in IntelliSense. That combined with the official OpenAI documentation should be enough to get started. Feel free to ping me on Twitter [@OkGoDoIt](https://twitter.com/OkGoDoIt) if you have any questions. Better documentation may come later.
147+
Every single class, method, and property has extensive XML documentation, so it should show up automatically in IntelliSense. That combined with the official OpenAI documentation should be enough to get started. Feel free to open an issue here if you have any questions. Better documentation may come later.
106148

107149
## License
108150
![CC-0 Public Domain](https://licensebuttons.net/p/zero/1.0/88x31.png)

0 commit comments

Comments
 (0)