Merge branch 'main' into pr/654

# Conflicts:
#	app/MindWork AI Studio/Provider/Google/ProviderGoogle.cs
This commit is contained in:
Thorsten Sommer 2026-02-20 09:13:41 +01:00
commit 876529f96e
Signed by untrusted user who does not match committer: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 39 additions and 10 deletions

View File

@ -1,3 +0,0 @@
namespace AIStudio.Provider.Google;
public readonly record struct Model(string Name, string DisplayName);

View File

@ -1,7 +0,0 @@
namespace AIStudio.Provider.Google;
/// <summary>
/// A data model for the response from the model endpoint.
/// </summary>
/// <param name="Models"></param>
public readonly record struct ModelsResponse(IList<Model> Models);

View File

@ -260,6 +260,45 @@ public class ProviderGoogle() : BaseProvider(LLMProviders.GOOGLE, "https://gener
private sealed record GoogleEmbeddingResponse
{
public List<GoogleEmbedding>? Embedding { get; set; }
try
{
var modelResponse = await response.Content.ReadFromJsonAsync<ModelsResponse>(token);
if (modelResponse == default || modelResponse.Data.Count is 0)
{
LOGGER.LogError("Google model list response did not contain a valid data array.");
return [];
}
return modelResponse.Data
.Where(model => !string.IsNullOrWhiteSpace(model.Id))
.Select(model => new Model(this.NormalizeModelId(model.Id), model.DisplayName))
.ToArray();
}
catch (Exception e)
{
LOGGER.LogError("Failed to parse Google model list response: '{Message}'.", e.Message);
return [];
}
}
private bool IsEmbeddingModel(string modelId)
{
return modelId.Contains("embedding", StringComparison.OrdinalIgnoreCase) ||
modelId.Contains("embed", StringComparison.OrdinalIgnoreCase);
}
private Model WithDisplayNameFallback(Model model)
{
return string.IsNullOrWhiteSpace(model.DisplayName)
? new Model(model.Id, model.Id)
: model;
}
private string NormalizeModelId(string modelId)
{
return modelId.StartsWith("models/", StringComparison.OrdinalIgnoreCase)
? modelId["models/".Length..]
: modelId;
}
private sealed record GoogleEmbedding