Skip to content

Commit

Permalink
Updated README for FineTuning release.
Browse files Browse the repository at this point in the history
  • Loading branch information
johniwasz committed Jan 2, 2023
1 parent cc6234d commit 33a9287
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 5 deletions.
61 changes: 58 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@

# Whetstone.ChatGPT

A simple light-weight library that wraps ChatGPT API completions. Additions to support images and other beta features are in progress.
A simple light-weight library that wraps ChatGPT API completions. Additions to support images and other beta features are in progress.

This library includes quality of life improvements:

- including support for __CancellationTokens__
- documentation comments
- conversions of Unix Epoch time to DateTime, etc.
- __IChatGPTClient__ interface for use with dependency injection

Supported features include:

- Completions
- Edits
- Files
- Fine Tunes

Pending features:

- Images
- Fine Tunes
- Embeddings
- Moderations
- Handling streamed responses

## Completion

Expand Down Expand Up @@ -118,4 +126,51 @@ using (IChatGPTClient client = new ChatGPTClient("YOURAPIKEY"))
{
uploadedFileInfo = await client.UploadFileAsync(uploadRequest);
}
```
```

## Fine Tuning Quickstart

Once the file has been created, get the fileId, and reference it when creating a new fine tuning.

```C#
using (IChatGPTClient client = new ChatGPTClient("YOURAPIKEY"))
{
var fileList = await client.ListFilesAsync();
var foundFile = fileList.Data.First(x => x.Filename.Equals("finetuningsample.jsonl"));

ChatGPTCreateFineTuneRequest tuningRequest = new ChatGPTCreateFineTuneRequest
{
TrainingFileId = foundFile.Id
};

ChatGPTFineTuneJob? tuneResponse = await client.CreateFineTuneAsync(tuningRequest);

string fineTuneId = tuneResponse.Id;

}

```

Porcessing the fine tuning request will take some time. Once it finishes, the __Status__ will report "succeeded" and it's ready to be used in a completion request.

```C#
using (IChatGPTClient client = new ChatGPTClient("YOURAPIKEY"))
{
ChatGPTFineTuneJob? tuneResponse = await client.RetrieveFineTuneAsync("FINETUNEID");

if(tuneResponse.Status.Equals("succeeded"))
{
var gptRequest = new ChatGPTCompletionRequest
{
Model = ChatGPTCompletionModels.Davinci,
Prompt = "How is the weather?"
};

var response = await client.CreateCompletionAsync(gptRequest);

Console.WriteLine(response.GetCompletionText());
}
}

```

6 changes: 4 additions & 2 deletions src/Whetstone.ChatGPT.Test/ChatGPTFineTuneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ public async Task SubmitFineTuningRequestCancelAndDeleteAsync()
using (IChatGPTClient client = ChatGPTTestUtilties.GetClient())
{

ChatGPTCreateFineTuneRequest tuningRequest = new ChatGPTCreateFineTuneRequest();
tuningRequest.TrainingFileId = _fileTestFixture.ExistingFileId;
ChatGPTCreateFineTuneRequest tuningRequest = new ChatGPTCreateFineTuneRequest
{
TrainingFileId = _fileTestFixture.ExistingFileId
};

ChatGPTFineTuneJob? tuneResponse = await client.CreateFineTuneAsync(tuningRequest);

Expand Down

0 comments on commit 33a9287

Please sign in to comment.