You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<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>
Copy file name to clipboardexpand all lines: README.md
+48-6
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,15 @@ A simple C# .NET wrapper library to use with OpenAI's GPT-3 API. More context [
5
5
## Status
6
6
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.
7
7
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!
9
9
10
10
## Quick Example
11
11
12
12
```csharp
13
13
varapi=newOpenAI_API.OpenAIAPI();
14
14
15
-
varresult=awaitapi.Completions.CreateCompletionAsync("One Two Three One Two", temperature: 0.1);
16
-
Console.WriteLine(result.ToString());
15
+
varresult=awaitapi.Completions.GetCompletion("One Two Three One Two");
16
+
Console.WriteLine(result);
17
17
// should print something starting with "Three"
18
18
```
19
19
@@ -66,7 +66,7 @@ OpenAIAPI api = new OpenAIAPI(new APIAuthentication("YOUR_API_KEY","org-yourOrgH
66
66
The Completion API is accessed via `OpenAIAPI.Completions`:
newCompletionRequest("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),
100
100
res=>ResumeTextbox.Text+=res.ToString());
101
101
```
102
102
103
+
### Embeddings
104
+
The Embedding API is accessed via `OpenAIAPI.Embeddings`:
varresult=awaitapi.Embeddings.CreateEmbeddingAsync(newEmbeddingRequest("A test text for embedding", model: Model.AdaTextEmbedding));
111
+
// or
112
+
varresult=awaitapi.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`:
Console.Write(response.Id); //the id of the uploaded file
129
+
130
+
// listing
131
+
asyncTask<List<File>>GetFilesAsync()
132
+
133
+
// for example
134
+
varresponse=awaitapi.Files.GetFilesAsync();
135
+
foreach (varfileinresponse)
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
+
103
145
## Documentation
104
146
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.
106
148
107
149
## License
108
150

0 commit comments