diff --git a/src/libs/OpenAI/CustomProviders.cs b/src/libs/OpenAI/CustomProviders.cs index f03a474c..a65ed53a 100755 --- a/src/libs/OpenAI/CustomProviders.cs +++ b/src/libs/OpenAI/CustomProviders.cs @@ -61,6 +61,11 @@ public static class CustomProviders /// public const string CodestralBaseUrl = "https://codestral.mistral.ai/v1"; + /// + /// + /// + public const string HyperbolicBaseUrl = "https://api.hyperbolic.xyz/v1"; + /// /// /// @@ -179,6 +184,15 @@ public static OpenAiApi Codestral(string apiKey) return new OpenAiApi(apiKey, baseUri: new Uri(CodestralBaseUrl)); } + /// + /// Create an API to use for Hyperbolic. + /// + /// + public static OpenAiApi Hyperbolic(string apiKey) + { + return new OpenAiApi(apiKey, baseUri: new Uri(HyperbolicBaseUrl)); + } + /// /// Create an API to use for Ollama. /// diff --git a/src/tests/OpenAI.IntegrationTests/CustomProvider.cs b/src/tests/OpenAI.IntegrationTests/CustomProvider.cs index 4fbfe8b2..ebb50059 100644 --- a/src/tests/OpenAI.IntegrationTests/CustomProvider.cs +++ b/src/tests/OpenAI.IntegrationTests/CustomProvider.cs @@ -17,4 +17,5 @@ public enum CustomProvider Groq, Mistral, Codestral, + Hyperbolic, } \ No newline at end of file diff --git a/src/tests/OpenAI.IntegrationTests/Tests.Chat.cs b/src/tests/OpenAI.IntegrationTests/Tests.Chat.cs index 2997de1d..466a389b 100755 --- a/src/tests/OpenAI.IntegrationTests/Tests.Chat.cs +++ b/src/tests/OpenAI.IntegrationTests/Tests.Chat.cs @@ -17,6 +17,7 @@ public partial class Tests [DataRow(CustomProvider.Groq)] [DataRow(CustomProvider.Mistral)] [DataRow(CustomProvider.Codestral)] + [DataRow(CustomProvider.Hyperbolic)] public async Task GenerateFiveRandomWords(CustomProvider customProvider) { var pair = GetAuthorizedChatApi(customProvider); @@ -56,6 +57,7 @@ public async Task GenerateFiveRandomWords(CustomProvider customProvider) [DataRow(CustomProvider.Groq)] [DataRow(CustomProvider.Mistral)] //[DataRow(CustomProvider.Codestral)] + [DataRow(CustomProvider.Hyperbolic)] public async Task GenerateFiveRandomWordsAsStream(CustomProvider customProvider) { var pair = GetAuthorizedChatApi(customProvider); @@ -88,6 +90,7 @@ public async Task GenerateFiveRandomWordsAsStream(CustomProvider customProvider) [DataRow(CustomProvider.Ollama)] [DataRow(CustomProvider.LmStudio)] [DataRow(CustomProvider.Groq)] + [DataRow(CustomProvider.Hyperbolic)] public async Task GenerateFiveRandomWordsAsJsonObject(CustomProvider customProvider) { var pair = GetAuthorizedChatApi(customProvider); @@ -111,6 +114,7 @@ public async Task GenerateFiveRandomWordsAsJsonObject(CustomProvider customProvi [DataRow(CustomProvider.Ollama)] [DataRow(CustomProvider.Groq)] //[DataRow(CustomProvider.Together)] + [DataRow(CustomProvider.Hyperbolic)] public async Task ChatWithVision(CustomProvider customProvider) { var pair = GetAuthorizedChatApi(customProvider, model: customProvider switch diff --git a/src/tests/OpenAI.IntegrationTests/Tests.Helpers.cs b/src/tests/OpenAI.IntegrationTests/Tests.Helpers.cs index d873e02d..5769f2af 100755 --- a/src/tests/OpenAI.IntegrationTests/Tests.Helpers.cs +++ b/src/tests/OpenAI.IntegrationTests/Tests.Helpers.cs @@ -28,8 +28,8 @@ private static RealtimeConversationClient GetAuthenticatedRealtimeClient() internal static (OpenAiApi Api, string Model) GetAuthorizedChatApi(CustomProvider customProvider, string? model = null) { const string localIpAddress = "10.10.5.85"; - if (customProvider is CustomProvider.Ollama or CustomProvider.LmStudio && - Environment.GetEnvironmentVariable("LOCAL_TESTS") is null) + if (customProvider is CustomProvider.Ollama or CustomProvider.LmStudio)// && + //Environment.GetEnvironmentVariable("LOCAL_TESTS") is null) { throw new AssertInconclusiveException("This test only runs on local environment."); } @@ -111,16 +111,29 @@ internal static (OpenAiApi Api, string Model) GetAuthorizedChatApi(CustomProvide throw new AssertInconclusiveException("CODESTRAL_API_KEY environment variable is not found.")), model ?? "codestral-latest"); } + if (customProvider == CustomProvider.Hyperbolic) + { + return (CustomProviders.Hyperbolic(apiKey: + Environment.GetEnvironmentVariable("HYPERBOLIC_API_KEY") ?? + throw new AssertInconclusiveException("HYPERBOLIC_API_KEY environment variable is not found.")), + model ?? "meta-llama/Llama-3.2-90B-Vision-Instruct"); + } if (customProvider == CustomProvider.Ollama) { - return (CustomProviders.Ollama(new Uri($"http://{localIpAddress}:11434/v1")), + var pair = (CustomProviders.Ollama(new Uri($"http://{localIpAddress}:11434/v1")), model ?? "llama3.2"); + //pair.Item1.HttpClient.Timeout = TimeSpan.FromSeconds(15); + + return pair; } if (customProvider == CustomProvider.LmStudio) { - return (CustomProviders.LmStudio(new Uri($"http://{localIpAddress}:1234/v1")), + var pair = (CustomProviders.LmStudio(new Uri($"http://{localIpAddress}:1234/v1")), model ?? "lmstudio-community/Llama-3.2-3B-Instruct-GGUF"); + //pair.Item1.HttpClient.Timeout = TimeSpan.FromSeconds(15); + + return pair; } var apiKey = diff --git a/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs b/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs index 1f7705b8..6b00a67f 100755 --- a/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs +++ b/src/tests/OpenAI.IntegrationTests/Tools/Tests.Tools.cs @@ -13,6 +13,7 @@ public partial class Tests // [DataRow(CustomProvider.DeepSeek)] // [DataRow(CustomProvider.OpenRouter)] // [DataRow(CustomProvider.Together)] + // [DataRow(CustomProvider.Hyperbolic)] public async Task WeatherTools(CustomProvider customProvider) { var pair = GetAuthorizedChatApi(customProvider, model: customProvider switch