File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,30 @@ private async void SendRequest()
66
66
}
67
67
```
68
68
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
+
69
93
### Sample Projects
70
94
This package includes two sample scenes that you can import via the Package Manager:
71
95
You can’t perform that action at this time.
0 commit comments