openai/openai-dotnet
Publicmirrored from https://github.com/openai/openai-dotnetAvailable
tests/Models/ModelTests.cs
49lines · modecode
| 1 | using NUnit.Framework; |
| 2 | using OpenAI.Models; |
| 3 | using OpenAI.Tests.Utility; |
| 4 | using System; |
| 5 | using System.Linq; |
| 6 | using System.Threading.Tasks; |
| 7 | |
| 8 | namespace OpenAI.Tests.Models; |
| 9 | |
| 10 | [TestFixture(true)] |
| 11 | [TestFixture(false)] |
| 12 | public partial class ModelTests : SyncAsyncTestBase |
| 13 | { |
| 14 | public ModelTests(bool isAsync) |
| 15 | : base(isAsync) |
| 16 | { |
| 17 | } |
| 18 | |
| 19 | [Test] |
| 20 | public async Task ListModels() |
| 21 | { |
| 22 | ModelClient client = new(); |
| 23 | |
| 24 | OpenAIModelInfoCollection allModels = IsAsync |
| 25 | ? await client.GetModelsAsync() |
| 26 | : client.GetModels(); |
| 27 | Assert.That(allModels, Is.Not.Null.Or.Empty); |
| 28 | Assert.That(allModels.Any(modelInfo => modelInfo.Id.Contains("whisper", StringComparison.InvariantCultureIgnoreCase))); |
| 29 | Console.WriteLine($"Total model count: {allModels.Count}"); |
| 30 | } |
| 31 | |
| 32 | [Test] |
| 33 | public async Task GetModelInfo() |
| 34 | { |
| 35 | ModelClient client = new(); |
| 36 | |
| 37 | OpenAIModelInfo model = IsAsync |
| 38 | ? await client.GetModelAsync("gpt-3.5-turbo") |
| 39 | : client.GetModel("gpt-3.5-turbo"); |
| 40 | Assert.That(model, Is.Not.Null); |
| 41 | Assert.That(model.OwnedBy.ToLowerInvariant(), Contains.Substring("openai")); |
| 42 | } |
| 43 | |
| 44 | [Test] |
| 45 | public void SerializeModelCollection() |
| 46 | { |
| 47 | // TODO: Add this test. |
| 48 | } |
| 49 | } |
| 50 | |