From 16403cec663f2ba7507c8c2177a05f3b073324b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jochen=20Kirst=C3=A4tter?=
<7329802+jochenkirstaetter@users.noreply.github.com>
Date: Thu, 21 Mar 2024 16:24:49 +0400
Subject: [PATCH] add GoogleAI type #3
---
src/Mscc.GenerativeAI/GoogleAI.cs | 50 +++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 src/Mscc.GenerativeAI/GoogleAI.cs
diff --git a/src/Mscc.GenerativeAI/GoogleAI.cs b/src/Mscc.GenerativeAI/GoogleAI.cs
new file mode 100644
index 0000000..c03c978
--- /dev/null
+++ b/src/Mscc.GenerativeAI/GoogleAI.cs
@@ -0,0 +1,50 @@
+#if NET472_OR_GREATER || NETSTANDARD2_0
+using System;
+using System.Collections.Generic;
+#endif
+
+namespace Mscc.GenerativeAI
+{
+ ///
+ /// Entry point to access Gemini API running in Google AI.
+ ///
+ public sealed class GoogleAI
+ {
+ private readonly string? _apiKey;
+
+ ///
+ /// Default constructor attempts to read environment variables and
+ /// sets default values, if available
+ ///
+ private GoogleAI()
+ {
+ _apiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY");
+ }
+
+ ///
+ /// Constructor to initialize access to Google AI Gemini API.
+ ///
+ /// Identifier of the Google Cloud project
+ public GoogleAI(string apiKey) : this()
+ {
+ _apiKey ??= apiKey;
+ }
+
+ ///
+ /// Create a generative model on Google 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)
+ {
+ if (_apiKey is null) throw new ArgumentNullException(nameof(_apiKey));
+
+ return new GenerativeModel(_apiKey, model, generationConfig, safetySettings);
+ }
+ }
+}