Skip to content

Commit

Permalink
com.openai.unity 7.0.4 (#142)
Browse files Browse the repository at this point in the history
- updated docs
  • Loading branch information
StephenHodgson authored Dec 10, 2023
1 parent d7ff611 commit 455dd9b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
13 changes: 7 additions & 6 deletions OpenAI/Packages/com.openai.unity/Documentation~/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Returns a list of assistants.

```csharp
var api = new OpenAIClient();
var assistantsList = await OpenAIClient.AssistantsEndpoint.ListAssistantsAsync();
var assistantsList = await api.AssistantsEndpoint.ListAssistantsAsync();

foreach (var assistant in assistantsList.Items)
{
Expand All @@ -402,7 +402,7 @@ Create an assistant with a model and instructions.
```csharp
var api = new OpenAIClient();
var request = new CreateAssistantRequest("gpt-3.5-turbo-1106");
var assistant = await OpenAIClient.AssistantsEndpoint.CreateAssistantAsync(request);
var assistant = await api.AssistantsEndpoint.CreateAssistantAsync(request);
```

#### [Retrieve Assistant](https://platform.openai.com/docs/api-reference/assistants/getAssistant)
Expand All @@ -411,7 +411,7 @@ Retrieves an assistant.

```csharp
var api = new OpenAIClient();
var assistant = await OpenAIClient.AssistantsEndpoint.RetrieveAssistantAsync("assistant-id");
var assistant = await api.AssistantsEndpoint.RetrieveAssistantAsync("assistant-id");
Debug.Log($"{assistant} -> {assistant.CreatedAt}");
```

Expand Down Expand Up @@ -730,7 +730,7 @@ var assistant = await api.AssistantsEndpoint.CreateAssistantAsync(
name: "Math Tutor",
instructions: "You are a personal math tutor. Answer questions briefly, in a sentence or less.",
model: "gpt-4-1106-preview"));
var thread = await OpenAIClient.ThreadsEndpoint.CreateThreadAsync();
var thread = await api.ThreadsEndpoint.CreateThreadAsync();
var message = await thread.CreateMessageAsync("I need to solve the equation `3x + 11 = 14`. Can you help me?");
var run = await thread.CreateRunAsync(assistant);
Debug.Log($"[{run.Id}] {run.Status} | {run.CreatedAt}");
Expand Down Expand Up @@ -1043,7 +1043,7 @@ var messages = new List<Message>
new Message(Role.User, "Who won the world series in 2020?"),
};
var chatRequest = new ChatRequest(messages, "gpt-4-1106-preview", responseFormat: ChatResponseFormat.Json);
var response = await OpenAIClient.ChatEndpoint.GetCompletionAsync(chatRequest);
var response = await api.ChatEndpoint.GetCompletionAsync(chatRequest);

foreach (var choice in response.Choices)
{
Expand Down Expand Up @@ -1341,7 +1341,8 @@ Assert.IsTrue(isViolation);
Additionally you can also get the scores of a given input.

```csharp
var response = await OpenAIClient.ModerationsEndpoint.CreateModerationAsync(new ModerationsRequest("I love you"));
var api = new OpenAIClient();
var response = await api.ModerationsEndpoint.CreateModerationAsync(new ModerationsRequest("I love you"));
Assert.IsNotNull(response);
Debug.Log(response.Results?[0]?.Scores?.ToString());
```
Expand Down
2 changes: 1 addition & 1 deletion OpenAI/Packages/com.openai.unity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "OpenAI",
"description": "A OpenAI package for the Unity Game Engine to use GPT-4, GPT-3.5, GPT-3 and Dall-E though their RESTful API (currently in beta).\n\nIndependently developed, this is not an official library and I am not affiliated with OpenAI.\n\nAn OpenAI API account is required.",
"keywords": [],
"version": "7.0.3",
"version": "7.0.4",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ Returns a list of assistants.

```csharp
var api = new OpenAIClient();
var assistantsList = await OpenAIClient.AssistantsEndpoint.ListAssistantsAsync();
var assistantsList = await api.AssistantsEndpoint.ListAssistantsAsync();

foreach (var assistant in assistantsList.Items)
{
Expand All @@ -402,7 +402,7 @@ Create an assistant with a model and instructions.
```csharp
var api = new OpenAIClient();
var request = new CreateAssistantRequest("gpt-3.5-turbo-1106");
var assistant = await OpenAIClient.AssistantsEndpoint.CreateAssistantAsync(request);
var assistant = await api.AssistantsEndpoint.CreateAssistantAsync(request);
```

#### [Retrieve Assistant](https://platform.openai.com/docs/api-reference/assistants/getAssistant)
Expand All @@ -411,7 +411,7 @@ Retrieves an assistant.

```csharp
var api = new OpenAIClient();
var assistant = await OpenAIClient.AssistantsEndpoint.RetrieveAssistantAsync("assistant-id");
var assistant = await api.AssistantsEndpoint.RetrieveAssistantAsync("assistant-id");
Debug.Log($"{assistant} -> {assistant.CreatedAt}");
```

Expand Down Expand Up @@ -730,7 +730,7 @@ var assistant = await api.AssistantsEndpoint.CreateAssistantAsync(
name: "Math Tutor",
instructions: "You are a personal math tutor. Answer questions briefly, in a sentence or less.",
model: "gpt-4-1106-preview"));
var thread = await OpenAIClient.ThreadsEndpoint.CreateThreadAsync();
var thread = await api.ThreadsEndpoint.CreateThreadAsync();
var message = await thread.CreateMessageAsync("I need to solve the equation `3x + 11 = 14`. Can you help me?");
var run = await thread.CreateRunAsync(assistant);
Debug.Log($"[{run.Id}] {run.Status} | {run.CreatedAt}");
Expand Down Expand Up @@ -1043,7 +1043,7 @@ var messages = new List<Message>
new Message(Role.User, "Who won the world series in 2020?"),
};
var chatRequest = new ChatRequest(messages, "gpt-4-1106-preview", responseFormat: ChatResponseFormat.Json);
var response = await OpenAIClient.ChatEndpoint.GetCompletionAsync(chatRequest);
var response = await api.ChatEndpoint.GetCompletionAsync(chatRequest);

foreach (var choice in response.Choices)
{
Expand Down Expand Up @@ -1341,7 +1341,8 @@ Assert.IsTrue(isViolation);
Additionally you can also get the scores of a given input.

```csharp
var response = await OpenAIClient.ModerationsEndpoint.CreateModerationAsync(new ModerationsRequest("I love you"));
var api = new OpenAIClient();
var response = await api.ModerationsEndpoint.CreateModerationAsync(new ModerationsRequest("I love you"));
Assert.IsNotNull(response);
Debug.Log(response.Results?[0]?.Scores?.ToString());
```
Expand Down

0 comments on commit 455dd9b

Please sign in to comment.