Skip to content

Commit a4df3b7

Browse files
committed
docs: readme updated
1 parent b52f622 commit a4df3b7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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
7094
This package includes two sample scenes that you can import via the Package Manager:
7195

0 commit comments

Comments
 (0)