mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 23:18:00 +00:00
Read the context window from four more model lists
This commit is contained in:
16 files changed
+415
-28
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using AIStudio.Chat;
|
||||
using AIStudio.Models.Live;
|
||||
using AIStudio.Provider.OpenAI;
|
||||
using AIStudio.Settings;
|
||||
using AIStudio.Tools.PluginSystem;
|
||||
@@ -221,7 +222,23 @@ public sealed class ProviderHuggingFace : BaseProvider
|
||||
/// <inheritdoc />
|
||||
public override Task<ModelLoadResult> GetTextModels(string? apiKeyProvisional = null, CancellationToken token = default)
|
||||
{
|
||||
return this.LoadModelsResponse<ModelsResponse>(SecretStoreType.LLM_PROVIDER, "models", this.SelectChatModels, apiKeyProvisional, token: token);
|
||||
return this.LoadModelsResponse<ModelsResponse>(SecretStoreType.LLM_PROVIDER, "models", this.SelectChatModels, apiKeyProvisional, listingFactory: this.ListingsOf, token: token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What the router stated about the models it knows.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Every model the router reports, not only the ones offered for chatting below: which models
|
||||
/// are offered depends on the chosen inference provider, while a window belongs to whoever is
|
||||
/// configured here, and both questions are asked of the same list.
|
||||
/// </remarks>
|
||||
/// <param name="response">The response of the model endpoint.</param>
|
||||
/// <returns>One listing per model, which says nothing for the models nobody stated a window for.</returns>
|
||||
private IEnumerable<ModelListing> ListingsOf(ModelsResponse response)
|
||||
{
|
||||
var providerSlug = this.hfProvider.EndpointsId();
|
||||
return response.Data.Select(hfModel => ModelListing.For(hfModel.Id, hfModel.ContextWindowTokens(providerSlug)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -253,8 +270,8 @@ public sealed class ProviderHuggingFace : BaseProvider
|
||||
return false;
|
||||
|
||||
return hfModel.Providers.Any(provider =>
|
||||
string.Equals(provider.Provider, providerSlug, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(provider.Status, "live", StringComparison.OrdinalIgnoreCase));
|
||||
provider.IsLive &&
|
||||
string.Equals(provider.Provider, providerSlug, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in new issue
Block a user