|
| 1 | +using AgentFrameworkToolkit.Cerebras; |
| 2 | +using Microsoft.Extensions.DependencyInjection; |
| 3 | +using Secrets; |
| 4 | + |
| 5 | +namespace AgentFrameworkToolkit.Tests; |
| 6 | + |
| 7 | +public sealed class CerebrasTests : TestsBase |
| 8 | +{ |
| 9 | + [Fact] |
| 10 | + public Task AgentFactory_Simple_ChatClient() => SimpleAgentTestsAsync(AgentProvider.CerebrasChatClient); |
| 11 | + |
| 12 | + [Fact] |
| 13 | + public Task AgentFactory_Normal_ChatClient() => NormalAgentTestsAsync(AgentProvider.CerebrasChatClient); |
| 14 | + |
| 15 | + [Fact] |
| 16 | + public Task AgentFactory_OpenTelemetryAndLoggingMiddleware_ChatClient() => OpenTelemetryAndLoggingMiddlewareTestsAsync(AgentProvider.CerebrasChatClient); |
| 17 | + |
| 18 | + [Fact] |
| 19 | + public Task AgentFactory_ToolCall_ChatClient() => ToolCallAgentTestsAsync(AgentProvider.CerebrasChatClient); |
| 20 | + |
| 21 | + [Fact] |
| 22 | + public Task AgentFactory_McpToolCall_ChatClient() => McpToolCallAgentTestsAsync(AgentProvider.CerebrasChatClient); |
| 23 | + |
| 24 | + [Fact] |
| 25 | + public Task AgentFactory_StructuredOutput_ChatClient() => StructuredOutputAgentTestsAsync(AgentProvider.CerebrasChatClient); |
| 26 | + |
| 27 | + [Fact] |
| 28 | + public async Task AgentFactory_DependencyInjection() |
| 29 | + { |
| 30 | + Secrets.Secrets secrets = SecretsManager.GetSecrets(); |
| 31 | + ServiceCollection services = new(); |
| 32 | + services.AddCerebrasAgentFactory(secrets.CerebrasApiKey); |
| 33 | + |
| 34 | + ServiceProvider provider = services.BuildServiceProvider(); |
| 35 | + |
| 36 | + CancellationToken cancellationToken = TestContext.Current.CancellationToken; |
| 37 | + string text = (await provider.GetRequiredService<CerebrasAgentFactory>() |
| 38 | + .CreateAgent(CerebrasChatModels.Llama318B) |
| 39 | + .RunAsync("Hello", cancellationToken: cancellationToken)).Text; |
| 40 | + Assert.NotEmpty(text); |
| 41 | + } |
| 42 | + |
| 43 | + [Fact] |
| 44 | + public async Task AgentFactory_DependencyInjection_Connection() |
| 45 | + { |
| 46 | + Secrets.Secrets secrets = SecretsManager.GetSecrets(); |
| 47 | + ServiceCollection services = new(); |
| 48 | + services.AddCerebrasAgentFactory(new CerebrasConnection |
| 49 | + { |
| 50 | + ApiKey = secrets.CerebrasApiKey, |
| 51 | + NetworkTimeout = TimeSpan.FromSeconds(10) |
| 52 | + }); |
| 53 | + |
| 54 | + ServiceProvider provider = services.BuildServiceProvider(); |
| 55 | + |
| 56 | + CancellationToken cancellationToken = TestContext.Current.CancellationToken; |
| 57 | + string text = (await provider.GetRequiredService<CerebrasAgentFactory>() |
| 58 | + .CreateAgent(CerebrasChatModels.Llama318B) |
| 59 | + .RunAsync("Hello", cancellationToken: cancellationToken)).Text; |
| 60 | + Assert.NotEmpty(text); |
| 61 | + } |
| 62 | +} |
0 commit comments