diff --git a/src/Mscc.GenerativeAI/CHANGELOG.md b/src/Mscc.GenerativeAI/CHANGELOG.md
index 7a20216..ca1cd99 100644
--- a/src/Mscc.GenerativeAI/CHANGELOG.md
+++ b/src/Mscc.GenerativeAI/CHANGELOG.md
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- compatibility methods for PaLM models
+- Feature suggestion: Retry mechanism ([#2](https://github.com/mscraftsman/generative-ai/issues/2))
### Changed
### Fixed
@@ -19,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- missing comments and better explanations
+- add GoogleAI type ([#3](https://github.com/mscraftsman/generative-ai/issues/3))
+- read environment variables in GoogleAI and VertexAI
## 0.8.3
diff --git a/src/Mscc.GenerativeAI/GoogleAI.cs b/src/Mscc.GenerativeAI/GoogleAI.cs
index c03c978..db42a31 100644
--- a/src/Mscc.GenerativeAI/GoogleAI.cs
+++ b/src/Mscc.GenerativeAI/GoogleAI.cs
@@ -18,6 +18,8 @@ public sealed class GoogleAI
///
private GoogleAI()
{
+ GenerativeModelExtensions.ReadDotEnv();
+
_apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
}
diff --git a/src/Mscc.GenerativeAI/VertexAI.cs b/src/Mscc.GenerativeAI/VertexAI.cs
index 2eacad8..fc3bcd0 100644
--- a/src/Mscc.GenerativeAI/VertexAI.cs
+++ b/src/Mscc.GenerativeAI/VertexAI.cs
@@ -1,35 +1,57 @@
-using System.Collections.Generic;
+#if NET472_OR_GREATER || NETSTANDARD2_0
+using System;
+using System.Collections.Generic;
+#endif
namespace Mscc.GenerativeAI
{
- public class VertexAI
+ ///
+ /// Entry point to access Gemini API running in Vertex AI.
+ ///
+ public sealed class VertexAI
{
- private readonly string projectId;
- private readonly string region;
+ private readonly string? _projectId;
+ private readonly string _region = "us-central1";
+ ///
+ /// Default constructor attempts to read environment variables and
+ /// sets default values, if available
+ ///
+ private VertexAI()
+ {
+ GenerativeModelExtensions.ReadDotEnv();
+
+ _projectId = Environment.GetEnvironmentVariable("GOOGLE_PROJECT_ID");
+ _region = Environment.GetEnvironmentVariable("GOOGLE_REGION") ?? _region;
+ }
+
///
/// Constructor to initialize access to Vertex AI Gemini API.
///
/// Identifier of the Google Cloud project
/// Region to use
- public VertexAI(string projectId, string region)
+ public VertexAI(string projectId, string region) : this()
{
- this.projectId = projectId;
- this.region = region;
+ _projectId ??= projectId;
+ _region ??= region;
}
///
/// Create a generative model on Vertex AI to use.
///
/// Model to use (default: "gemini-1.0-pro")
- ///
- ///
+ /// Optional. Configuration options for model generation and outputs.
+ /// Optional. A list of unique SafetySetting instances for blocking unsafe content.
+ ///
///
public GenerativeModel GenerativeModel(string model = Model.Gemini10Pro,
GenerationConfig? generationConfig = null,
List? safetySettings = null)
{
- return new GenerativeModel(projectId, region, model, generationConfig, safetySettings);
+ if (_projectId is null) throw new ArgumentNullException("projectId");
+ if (_region is null) throw new ArgumentNullException("region");
+
+ return new GenerativeModel(_projectId, _region, model, generationConfig, safetySettings);
}
}
}