openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
examples/Assistants/Example03_ListAssistantsWithPaginationAsync.cs
33lines · modecode
| 1 | using NUnit.Framework; |
| 2 | using OpenAI.Assistants; |
| 3 | using System; |
| 4 | using System.ClientModel; |
| 5 | using System.Threading.Tasks; |
| 6 | |
| 7 | namespace OpenAI.Examples; |
| 8 | |
| 9 | // This example uses experimental APIs which are subject to change. To use experimental APIs, |
| 10 | // please acknowledge their experimental status by suppressing the corresponding warning. |
| 11 | #pragma warning disable OPENAI001 |
| 12 | |
| 13 | public partial class AssistantExamples |
| 14 | { |
| 15 | [Test] |
| 16 | public async Task Example03_ListAssistantsWithPaginationAsync() |
| 17 | { |
| 18 | // Assistants is a beta API and subject to change; acknowledge its experimental status by suppressing the matching warning. |
| 19 | AssistantClient client = new(Environment.GetEnvironmentVariable("OPENAI_API_KEY")); |
| 20 | |
| 21 | int count = 0; |
| 22 | |
| 23 | AsyncCollectionResult<Assistant> assistants = client.GetAssistantsAsync(); |
| 24 | await foreach (Assistant assistant in assistants) |
| 25 | { |
| 26 | Console.WriteLine($"[{count,3}] {assistant.Id} {assistant.CreatedAt:s} {assistant.Name}"); |
| 27 | |
| 28 | count++; |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | #pragma warning restore OPENAI001 |