- Thinking-Streaming: Parse 'reasoning_details' (MiniMax mit reasoning_split),
'reasoning' (Nvidia), 'reasoning_content' (DeepSeek/OpenAI-Compat),
und inline <think>...</think>-Tags aus delta.content (Fallback)
- MiniMax: max_tokens=32768, stream_options={include_usage}, reasoning_split=true
- 1h-Prompt-Cache-TTL für API (extended-cache-ttl-2025-04-11 Header,
Cache-Breakpoints auf System-Prompt + letztes Tool) und CLI (ENABLE_PROMPT_CACHING_1H=1)
- Null-Safety: choices/delta/tool_calls/usage null-Checks in Streaming + Non-Streaming
- finish_reason='length' → warning-Event + stopReason='max_tokens'
- MiniMax-Provider: BaseUrl, MinimaxApiKey-Setting, /api/models/minimax-Endpoint,
Model-Dropdown, statische Fallback-Modelle, Cache-Laden mit Fallback
- Safety-Net: InvalidOperationException-Catch um SSE-Zeilen-Block
68 lines
2.4 KiB
C#
68 lines
2.4 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Gott.Services;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
namespace Gott.Endpoints;
|
|
|
|
public static class ModelsEndpoint
|
|
{
|
|
public static void MapModelsEndpoint(this IEndpointRouteBuilder app)
|
|
{
|
|
app.MapGet("/api/models/nvidia", HandleNvidiaModels);
|
|
app.MapGet("/api/models/pollinations", HandlePollinationsModels);
|
|
app.MapGet("/api/models/gemini", HandleGeminiModels);
|
|
app.MapGet("/api/models/openai", HandleOpenAiModels);
|
|
app.MapGet("/api/models/minimax", HandleMinimaxModels);
|
|
app.MapPost("/api/models/refresh", HandleRefresh);
|
|
}
|
|
|
|
private static IResult HandleNvidiaModels(OpenAiService openAiService)
|
|
{
|
|
var models = openAiService.GetNvidiaModels()
|
|
.Select(m => new { id = m.Id, displayName = m.DisplayName })
|
|
.ToList();
|
|
return Results.Json(new { models });
|
|
}
|
|
|
|
private static IResult HandlePollinationsModels(OpenAiService openAiService)
|
|
{
|
|
var models = openAiService.GetPollinationsModels()
|
|
.Select(m => new { id = m.Id, displayName = m.DisplayName })
|
|
.ToList();
|
|
return Results.Json(new { models });
|
|
}
|
|
|
|
private static IResult HandleGeminiModels(OpenAiService openAiService)
|
|
{
|
|
var models = openAiService.GetGeminiModels()
|
|
.Select(m => new { id = m.Id, displayName = m.DisplayName })
|
|
.ToList();
|
|
return Results.Json(new { models });
|
|
}
|
|
|
|
private static IResult HandleOpenAiModels(OpenAiService openAiService)
|
|
{
|
|
var models = openAiService.GetOpenAiModels()
|
|
.Select(m => new { id = m.Id, displayName = m.DisplayName })
|
|
.ToList();
|
|
return Results.Json(new { models });
|
|
}
|
|
|
|
private static IResult HandleMinimaxModels(OpenAiService openAiService)
|
|
{
|
|
var models = openAiService.GetMinimaxModels()
|
|
.Select(m => new { id = m.Id, displayName = m.DisplayName })
|
|
.ToList();
|
|
return Results.Json(new { models });
|
|
}
|
|
|
|
private static async Task<IResult> HandleRefresh(OpenAiService openAiService)
|
|
{
|
|
await openAiService.RefreshModelsFromApis();
|
|
return Results.Json(new { success = true, message = "Modelle neu geladen und gecacht." });
|
|
}
|
|
}
|