Skip to content

Commit db87e73

Browse files
committed
Update README.md
2 parents 6c4a025 + d897d29 commit db87e73

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

README.md

+19-12
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,32 @@ private async void SendRequest()
6868

6969
To make a stream request, you can use the `CreateCompletionAsync` and `CreateChatCompletionAsync` methods.
7070
These methods are going to set `Stream` property of the request to `true` and return responses through an onResponse callback.
71-
In this case text responses are stored in `Delta` property of the `Choices` field.
71+
In this case text responses are stored in `Delta` property of the `Choices` field in the Chat Completion.
7272

7373
```csharp
74-
var req = new CreateCompletionRequest{
75-
Model = "text-davinci-003",
76-
Prompt = "Say this is a test.",
77-
MaxTokens = 7,
78-
Temperature = 0
74+
var req = new CreateChatCompletionRequest{
75+
Model = "gpt-3.5-turbo",
76+
Messages = new List<ChatMessage>
77+
{
78+
new ChatMessage()
79+
{
80+
Role = "user",
81+
Content = "Write a 100 word long short story in La Fontaine style."
82+
}
83+
},
84+
Temperature = 0.7f,
7985
};
8086

81-
openai.CreateCompletionAsync(req,
87+
openai.CreateChatCompletionAsync(req,
8288
(responses) => {
8389
var result = string.Join("", responses.Select(response => response.Choices[0].Delta.Content));
8490
Debug.Log(result);
8591
},
8692
() => {
8793
Debug.Log("completed");
8894
},
89-
new CancellationTokenSource());
90-
}
95+
new CancellationTokenSource()
96+
);
9197
```
9298

9399
### Sample Projects
@@ -100,9 +106,7 @@ This package includes two sample scenes that you can import via the Package Mana
100106
- **Can't See the Image Result in WebGL Builds:** Due to CORS policy of OpenAI image storage in local WebGL builds you will get the generated image's URL however it will not be
101107
downloaded using UnityWebRequest until you run it out of localhost, on a server.
102108

103-
### Further Reading
104-
For more information on how to use the various request parameters,
105-
please refer to the OpenAI documentation: https://beta.openai.com/docs/api-reference/introduction
109+
- **Streamed Response is just blank in WebGL Build:** Unity 2020 WebGL has a bug where stream responses return empty. You can update and try with a newer version of Unity.
106110

107111
### Supported Unity Versions for WebGL Builds
108112
The following table shows the supported Unity versions for WebGL builds:
@@ -112,3 +116,6 @@ The following table shows the supported Unity versions for WebGL builds:
112116
| 2022.2.8f1 ||
113117
| 2021.3.5f1 ||
114118
| 2020.3.0f1 ||
119+
120+
### Further Reading
121+
For more information on how to use the various request parameters, please refer to the OpenAI documentation: https://platform.openai.com/docs/api-reference

0 commit comments

Comments
 (0)