Skip to content

Commit

Permalink
feat: Added SambaNova custom provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Sep 13, 2024
1 parent 6b955c7 commit f7529fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/libs/OpenAI/CustomProviders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public static class CustomProviders
/// </summary>
public const string PerplexityBaseUrl = "https://api.perplexity.ai/";

/// <summary>
///
/// </summary>
public const string SambaNovaBaseUrl = "https://api.sambanova.ai/v1";

/// <summary>
/// Creates an API to use for GitHub Models: https://github.com/marketplace/models
/// </summary>
Expand Down Expand Up @@ -112,4 +117,13 @@ public static OpenAiApi Perplexity(string apiKey)
{
return new OpenAiApi(apiKey, baseUri: new Uri(PerplexityBaseUrl));
}

/// <summary>
/// Create an API to use for SambaNova AI.
/// </summary>
/// <returns></returns>
public static OpenAiApi SambaNova(string apiKey)
{
return new OpenAiApi(apiKey, baseUri: new Uri(SambaNovaBaseUrl));
}
}
1 change: 1 addition & 0 deletions src/tests/OpenAI.IntegrationTests/CustomProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public enum CustomProvider
OpenRouter,
GitHub,
Perplexity,
SambaNova,
}
2 changes: 2 additions & 0 deletions src/tests/OpenAI.IntegrationTests/Tests.Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public partial class Tests
[DataRow(CustomProvider.Together)]
[DataRow(CustomProvider.GitHub)]
[DataRow(CustomProvider.Perplexity)]
[DataRow(CustomProvider.SambaNova)]
public async Task GenerateFiveRandomWords(CustomProvider customProvider)
{
var pair = GetAuthorizedChatApi(customProvider);
Expand Down Expand Up @@ -39,6 +40,7 @@ public async Task GenerateFiveRandomWords(CustomProvider customProvider)
[DataRow(CustomProvider.OpenRouter)]
[DataRow(CustomProvider.Together)]
[DataRow(CustomProvider.GitHub)]
[DataRow(CustomProvider.SambaNova)]
public async Task GenerateFiveRandomWordsAsStream(CustomProvider customProvider)
{
var pair = GetAuthorizedChatApi(customProvider);
Expand Down
7 changes: 7 additions & 0 deletions src/tests/OpenAI.IntegrationTests/Tests.Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ internal static (OpenAiApi Api, string Model) GetAuthorizedChatApi(CustomProvide
throw new AssertInconclusiveException("PERPLEXITY_API_KEY environment variable is not found.")),
model ?? "llama-3.1-sonar-small-128k-online");
}
if (customProvider == CustomProvider.SambaNova)
{
return (CustomProviders.SambaNova(apiKey:
Environment.GetEnvironmentVariable("SAMBANOVA_API_KEY") ??
throw new AssertInconclusiveException("SAMBANOVA_API_KEY environment variable is not found.")),
model ?? "Meta-Llama-3.1-8B-Instruct");
}

var apiKey =
Environment.GetEnvironmentVariable("OPENAI_API_KEY") ??
Expand Down

0 comments on commit f7529fa

Please sign in to comment.