From c25eb8cd92688af98a7852efb1488f4940b51298 Mon Sep 17 00:00:00 2001 From: HavenDV Date: Tue, 6 Aug 2024 19:47:55 +0400 Subject: [PATCH] test: Refactor WeatherTools test to use custom providers. --- .../Tools/Tests.Tools.cs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs b/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs index 5b9d4c16..1c99ece6 100755 --- a/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs +++ b/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs @@ -1,36 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using OpenAI; - -namespace OpenAI.IntegrationTests; +namespace OpenAI.IntegrationTests; public partial class Tests { - [TestMethod] - //[Ignore] - public async Task SimpleMethod() + [DataTestMethod] + [DataRow(CustomProvider.OpenAi)] + // [DataRow(CustomProvider.Fireworks)] + // [DataRow(CustomProvider.DeepInfra)] + // [DataRow(CustomProvider.DeepSeek)] + // [DataRow(CustomProvider.OpenRouter)] + // [DataRow(CustomProvider.Together)] + public async Task WeatherTools(CustomProvider customProvider) { + var pair = GetAuthorizedChatApi(customProvider); + using var api = pair.Api; + var messages = new List { "You are a helpful weather assistant.".AsSystemMessage(), "What is the current temperature in Dubai, UAE in Celsius?".AsUserMessage(), }; - var model = CreateChatCompletionRequestModel.Gpt35Turbo; try { - var apiKey = - Environment.GetEnvironmentVariable("OPENAI_API_KEY") ?? - throw new AssertInconclusiveException("OPENAI_API_KEY is not set."); - using var api = new OpenAiApi(); - api.AuthorizeUsingBearer(apiKey); var service = new WeatherService(); var tools = service.AsTools(); var result = await api.Chat.CreateChatCompletionAsync( messages, - model: model, + model: pair.Model, tools: tools); var resultMessage = result.Choices.First().Message; messages.Add(resultMessage.AsRequestMessage()); @@ -51,7 +47,7 @@ public async Task SimpleMethod() result = await api.Chat.CreateChatCompletionAsync( messages, - model: model, + model: pair.Model, tools: tools); resultMessage = result.Choices.First().Message; messages.Add(resultMessage.AsRequestMessage());