Skip to content

Commit

Permalink
House keeping
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenkirstaetter committed Oct 9, 2024
1 parent e5148ce commit a2e8121
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
6 changes: 3 additions & 3 deletions src/Mscc.GenerativeAI/GenerativeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ public async Task<string> TransferOwnership(string model, string emailAddress)
public async Task<UploadMediaResponse> UploadFile(string uri,
string? displayName = null,
bool resumable = false,
[EnumeratorCancellation] CancellationToken cancellationToken = default)
CancellationToken cancellationToken = default)
{
if (uri == null) throw new ArgumentNullException(nameof(uri));
if (!File.Exists(uri)) throw new FileNotFoundException(nameof(uri));
Expand Down Expand Up @@ -686,8 +686,8 @@ public async Task<GenerateContentResponse> GenerateContent(GenerateContentReques
{
case FinishReason.Safety:
return content;
break;
case FinishReason.FinishReasonUnspecified:
// break;
// case FinishReason.FinishReasonUnspecified:
default:
fullText.Append(content.Text);
break;
Expand Down
7 changes: 3 additions & 4 deletions src/Mscc.GenerativeAI/GoogleAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public GoogleAI(string? apiKey = null, string? accessToken = null) : this()
/// <param name="safetySettings">Optional. A list of unique SafetySetting instances for blocking unsafe content.</param>
/// <param name="tools">Optional. A list of Tools the model may use to generate the next response.</param>
/// <param name="systemInstruction">Optional. </param>
/// <exception cref="ArgumentNullException">Thrown when both <paramref name="apiKey"/> and <paramref name="accessToken"/> are <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when both "apiKey" and "accessToken" are <see langword="null"/>.</exception>
/// <returns>Generative model instance.</returns>
public GenerativeModel GenerativeModel(string model = Model.Gemini15Pro,
GenerationConfig? generationConfig = null,
Expand All @@ -67,8 +67,7 @@ public GenerativeModel GenerativeModel(string model = Model.Gemini15Pro,
Content? systemInstruction = null)
{
if (_apiKey is null && _accessToken is null)
throw new ArgumentNullException("apiKey or accessToken",
message: "Either API key or access token is required.");
throw new ArgumentNullException(message: "Either API key or access token is required.", null);

_generativeModel = new GenerativeModel(_apiKey,
model,
Expand All @@ -87,7 +86,7 @@ public GenerativeModel GenerativeModel(string model = Model.Gemini15Pro,
/// <inheritdoc cref="IGenerativeAI"/>
public async Task<ModelResponse> GetModel(string model)
{
return await _generativeModel?.GetModel(model);
return await _generativeModel?.GetModel(model)!;
}
}
}
14 changes: 7 additions & 7 deletions src/Mscc.GenerativeAI/VertexAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ public VertexAI(string projectId, string? region = null) : this()
/// <param name="safetySettings">Optional. A list of unique SafetySetting instances for blocking unsafe content.</param>
/// <param name="tools">Optional. A list of Tools the model may use to generate the next response.</param>
/// <param name="systemInstruction">Optional. </param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="projectId"/> or <paramref name="region"/> is <see langword="null"/>.</exception>
/// <exception cref="ArgumentNullException">Thrown when "projectId" or "region" is <see langword="null"/>.</exception>
/// <returns>Generative model instance.</returns>
public GenerativeModel GenerativeModel(string model = Model.Gemini15Pro,
GenerationConfig? generationConfig = null,
List<SafetySetting>? safetySettings = null,
List<Tool>? tools = null,
Content? systemInstruction = null)
{
if (_projectId is null) throw new ArgumentNullException("projectId");
if (_region is null) throw new ArgumentNullException("region");
if (_projectId is null) throw new ArgumentNullException(message: "ProjectId has not been set", null);
if (_region is null) throw new ArgumentNullException(message: "Region has not been set", null);

_generativeModel = new GenerativeModel(_projectId,
_region,
Expand All @@ -97,17 +97,17 @@ public Task<ModelResponse> GetModel(string model)
/// <returns></returns>
public ImageGenerationModel ImageGenerationModel(string model = Model.ImageGeneration)
{
if (_projectId is null) throw new ArgumentNullException("projectId");
if (_region is null) throw new ArgumentNullException("region");
if (_projectId is null) throw new ArgumentNullException(message: "ProjectId has not been set", null);
if (_region is null) throw new ArgumentNullException(message: "Region has not been set", null);

_imageGenerationModel = new ImageGenerationModel(_projectId, _region, model);
return _imageGenerationModel;
}

public ImageTextModel ImageTextModel(string model = Model.ImageText)
{
if (_projectId is null) throw new ArgumentNullException("projectId");
if (_region is null) throw new ArgumentNullException("region");
if (_projectId is null) throw new ArgumentNullException(message: "ProjectId has not been set", null);
if (_region is null) throw new ArgumentNullException(message: "Region has not been set", null);

_imageTextModel = new ImageTextModel(_projectId, _region, model);
return _imageTextModel;
Expand Down

0 comments on commit a2e8121

Please sign in to comment.