Skip to content

Commit

Permalink
com.openai.unity 3.0.1 (#37)
Browse files Browse the repository at this point in the history
- Fixed missing icons
- Fixed chat parameters
- Removed spam logging leftover from testing
- Updated docs
  • Loading branch information
StephenHodgson authored Mar 2, 2023
1 parent 34a70e8 commit 5c767ab
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Documentation~/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ Given a chat conversation, the model will return a chat completion response.
Creates a completion for the chat message

```csharp
IClient(OpenAIAuthentication.LoadFromEnv());
var api = new OpenAIClient();
var chatPrompts = new List<ChatPrompt>
{
new ChatPrompt("system", "You are a helpful assistant."),
new ChatPrompt("user", "Who won the world series in 2020?"),
new ChatPrompt("assistant", "The Los Angeles Dodgers won the World Series in 2020."),
new ChatPrompt("user", "Where was it played?"),
new ChatPrompt("system", "You are a helpful assistant."),
new ChatPrompt("user", "Who won the world series in 2020?"),
new ChatPrompt("assistant", "The Los Angeles Dodgers won the World Series in 2020."),
new ChatPrompt("user", "Where was it played?"),
};
var chatRequest = new ChatRequest(chatPrompts);
var result = await api.ChatEndpoint.GetCompletionAsync(chatRequest);
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Chat/ChatEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task<ChatResponse> GetCompletionAsync(ChatRequest chatRequest, Canc
{
var payload = JsonConvert.SerializeObject(chatRequest, Api.JsonSerializationOptions).ToJsonStringContent();
var result = await Api.Client.PostAsync($"{GetEndpoint()}/completions", payload, cancellationToken);
var resultAsString = await result.ReadAsStringAsync(true);
var resultAsString = await result.ReadAsStringAsync();
return JsonConvert.DeserializeObject<ChatResponse>(resultAsString, Api.JsonSerializationOptions);
}

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Chat/ChatPrompt.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions Runtime/Chat/ChatRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ChatRequest(
double? topP = null,
int? number = null,
string[] stops = null,
int? maxTokens = null,
double? presencePenalty = null,
double? frequencyPenalty = null,
string user = null)
Expand All @@ -44,7 +45,7 @@ public ChatRequest(
/// ID of the model to use. Currently, only gpt-3.5-turbo and gpt-3.5-turbo-0301 are supported.
/// </summary>
[JsonProperty("model")]
private string Model { get; }
public string Model { get; }

/// <summary>
/// The messages to generate chat completions for, in the chat format.
Expand Down Expand Up @@ -76,7 +77,7 @@ public ChatRequest(
/// How many chat completion choices to generate for each input message.<br/>
/// Defaults to 1
/// </summary>
[JsonProperty("number")]
[JsonProperty("n")]
public int? Number { get; }

/// <summary>
Expand All @@ -93,6 +94,13 @@ public ChatRequest(
[JsonProperty("stop")]
public string[] Stops { get; }

/// <summary>
/// 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).
/// </summary>
[JsonProperty("max_tokens")]
public int? MaxTokens { get; }

/// <summary>
/// Number between -2.0 and 2.0.
/// Positive values penalize new tokens based on whether they appear in the text so far,
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Chat/ChatRequest.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tests/TestFixture_03_Chat.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 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-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": "3.0.0",
"version": "3.0.1",
"unity": "2021.3",
"documentationUrl": "https://github.com/RageAgainstThePixel/com.openai.unity#documentation",
"changelogUrl": "https://github.com/RageAgainstThePixel/com.openai.unity/releases",
Expand Down

0 comments on commit 5c767ab

Please sign in to comment.