You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

OpenAIFact.cs 661 B

12345678910111213141516171819202122
  1. // Copyright (c) Microsoft Corporation. All rights reserved.
  2. // OpenAIFact.cs
  3. namespace AutoGen.Tests;
  4. /// <summary>
  5. /// A fact for tests requiring OPENAI_API_KEY env.
  6. /// </summary>
  7. public sealed class ApiKeyFactAttribute : EnvironmentSpecificFactAttribute
  8. {
  9. private readonly string[] _envVariableNames;
  10. public ApiKeyFactAttribute(params string[] envVariableNames) : base($"{envVariableNames} is not found in env")
  11. {
  12. _envVariableNames = envVariableNames;
  13. }
  14. /// <inheritdoc />
  15. protected override bool IsEnvironmentSupported()
  16. {
  17. return _envVariableNames.All(Environment.GetEnvironmentVariables().Contains);
  18. }
  19. }