Improved the resource handling when loading models.

This commit is contained in:
Thorsten Sommer 2025-01-29 07:21:53 +01:00
parent 54264345d9
commit abaa4fa7b7
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
10 changed files with 17 additions and 16 deletions

View File

@ -7,7 +7,7 @@ public static class ERIVersionExtensions
try try
{ {
var url = version.SpecificationURL(); var url = version.SpecificationURL();
var response = await httpClient.GetAsync(url); using var response = await httpClient.GetAsync(url);
return await response.Content.ReadAsStringAsync(); return await response.Content.ReadAsStringAsync();
} }
catch catch

View File

@ -23,7 +23,7 @@ public partial class Changelog : ComponentBase
private async Task ReadLogAsync() private async Task ReadLogAsync()
{ {
var response = await this.HttpClient.GetAsync($"changelog/{this.SelectedLog.Filename}"); using var response = await this.HttpClient.GetAsync($"changelog/{this.SelectedLog.Filename}");
this.LogContent = await response.Content.ReadAsStringAsync(); this.LogContent = await response.Content.ReadAsStringAsync();
} }
} }

View File

@ -26,7 +26,7 @@ public partial class Home : ComponentBase
private async Task ReadLastChangeAsync() private async Task ReadLastChangeAsync()
{ {
var latest = Changelog.LOGS.MaxBy(n => n.Build); var latest = Changelog.LOGS.MaxBy(n => n.Build);
var response = await this.HttpClient.GetAsync($"changelog/{latest.Filename}"); using var response = await this.HttpClient.GetAsync($"changelog/{latest.Filename}");
this.LastChangeContent = await response.Content.ReadAsStringAsync(); this.LastChangeContent = await response.Content.ReadAsStringAsync();
} }

View File

@ -136,8 +136,8 @@ public class ProviderGoogle(ILogger logger) : BaseProvider("https://generativela
if (secretKey is null) if (secretKey is null)
return default; return default;
var request = new HttpRequestMessage(HttpMethod.Get, $"models?key={secretKey}"); using var request = new HttpRequestMessage(HttpMethod.Get, $"models?key={secretKey}");
var response = await this.httpClient.SendAsync(request, token); using var response = await this.httpClient.SendAsync(request, token);
if(!response.IsSuccessStatusCode) if(!response.IsSuccessStatusCode)
return default; return default;

View File

@ -127,10 +127,10 @@ public class ProviderGroq(ILogger logger) : BaseProvider("https://api.groq.com/o
if (secretKey is null) if (secretKey is null)
return []; return [];
var request = new HttpRequestMessage(HttpMethod.Get, "models"); using var request = new HttpRequestMessage(HttpMethod.Get, "models");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey);
var response = await this.httpClient.SendAsync(request, token); using var response = await this.httpClient.SendAsync(request, token);
if(!response.IsSuccessStatusCode) if(!response.IsSuccessStatusCode)
return []; return [];

View File

@ -138,10 +138,10 @@ public sealed class ProviderMistral(ILogger logger) : BaseProvider("https://api.
if (secretKey is null) if (secretKey is null)
return default; return default;
var request = new HttpRequestMessage(HttpMethod.Get, "models"); using var request = new HttpRequestMessage(HttpMethod.Get, "models");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey);
var response = await this.httpClient.SendAsync(request, token); using var response = await this.httpClient.SendAsync(request, token);
if(!response.IsSuccessStatusCode) if(!response.IsSuccessStatusCode)
return default; return default;

View File

@ -154,10 +154,10 @@ public sealed class ProviderOpenAI(ILogger logger) : BaseProvider("https://api.o
if (secretKey is null) if (secretKey is null)
return []; return [];
var request = new HttpRequestMessage(HttpMethod.Get, "models"); using var request = new HttpRequestMessage(HttpMethod.Get, "models");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey);
var response = await this.httpClient.SendAsync(request, token); using var response = await this.httpClient.SendAsync(request, token);
if(!response.IsSuccessStatusCode) if(!response.IsSuccessStatusCode)
return []; return [];

View File

@ -154,11 +154,11 @@ public sealed class ProviderSelfHosted(ILogger logger, Host host, string hostnam
} }
}; };
var lmStudioRequest = new HttpRequestMessage(HttpMethod.Get, "models"); using var lmStudioRequest = new HttpRequestMessage(HttpMethod.Get, "models");
if(secretKey is not null) if(secretKey is not null)
lmStudioRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKeyProvisional); lmStudioRequest.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKeyProvisional);
var lmStudioResponse = await this.httpClient.SendAsync(lmStudioRequest, token); using var lmStudioResponse = await this.httpClient.SendAsync(lmStudioRequest, token);
if(!lmStudioResponse.IsSuccessStatusCode) if(!lmStudioResponse.IsSuccessStatusCode)
return []; return [];

View File

@ -127,10 +127,10 @@ public sealed class ProviderX(ILogger logger) : BaseProvider("https://api.x.ai/v
if (secretKey is null) if (secretKey is null)
return []; return [];
var request = new HttpRequestMessage(HttpMethod.Get, "models"); using var request = new HttpRequestMessage(HttpMethod.Get, "models");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey); request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", secretKey);
var response = await this.httpClient.SendAsync(request, token); using var response = await this.httpClient.SendAsync(request, token);
if(!response.IsSuccessStatusCode) if(!response.IsSuccessStatusCode)
return []; return [];

View File

@ -1,2 +1,3 @@
# v0.9.28, build 203 (2025-0x-xx xx:xx UTC) # v0.9.28, build 203 (2025-0x-xx xx:xx UTC)
- Added an information view to all data sources to the data source configuration page. The data source configuration is a preview feature behind the RAG feature flag. - Added an information view to all data sources to the data source configuration page. The data source configuration is a preview feature behind the RAG feature flag.
- Improved the resource handling when loading models.