File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,30 @@ private async void SendRequest()
6666}
6767```
6868
69+ To make a stream request, you can use the ` CreateCompletionAsync ` and ` CreateChatCompletionAsync ` methods.
70+ 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.
72+
73+ ``` csharp
74+ var req = new CreateCompletionRequest {
75+ Model = " text-davinci-003" ,
76+ Prompt = " Say this is a test." ,
77+ MaxTokens = 7 ,
78+ Temperature = 0
79+ };
80+
81+ openai .CreateCompletionAsync (req ,
82+ (responses ) => {
83+ var result = string .Join (" " , responses .Select (response => response .Choices [0 ].Delta .Content ));
84+ Debug .Log (result );
85+ },
86+ () => {
87+ Debug .Log (" completed" );
88+ },
89+ new CancellationTokenSource ());
90+ }
91+ ```
92+
6993### Sample Projects
7094This package includes two sample scenes that you can import via the Package Manager:
7195
You can’t perform that action at this time.
0 commit comments