feat: OpenAI-kompatibler Provider (Nvidia/g4f.space) mit Tool-Calling und SSE-Streaming

- OpenAiService.cs: Neuer Service für OpenAI-kompatible APIs
  - SSE-Streaming mit text_start/text_delta/text_end Events
  - Tool-Calling: list_files, read_file, write_file, edit_file, delete_file, execute
  - Agentic Loop (max 10 Iterationen)
  - Tool-Use + Tool-Result in DB gespeichert
  - History-Rebuild: Anthropic-Format → OpenAI-Format (tool_use/tool_result korrekt konvertiert)
- ChatContext.cs: Provider-Feld hinzugefügt
- ChatService.cs: OpenAI-Provider-Erkennung in ResolveModelId + PrepareContext
- ChatEndpoint.cs: Provider-Dispatch (nvidia → OpenAiService, sonst → AnthropicService)
- Program.cs: OpenAiService als Singleton registriert
- wwwroot/index.html: nvidia:moonshotai/kimi-k2.5 in Modell-Auswahl
This commit is contained in:
Meleki committed 2026-03-11 16:15:09 +01:00
1 parent a646e695cd
commit 7972ca6a3a
6 files changed
+665 -2

No files matched your search

+6
View File
@@ -30,6 +30,9 @@ public class ChatService
public static string ResolveModelId(string model)
{
// OpenAI-kompatible Provider werden unverändert durchgereicht (Format: "provider:model")
if (OpenAiService.IsOpenAiProvider(model)) return model;
return model switch
{
"sonnet" => "claude-sonnet-4-6",
@@ -160,11 +163,14 @@ Für welche Plattform soll die App entwickelt werden? Web, Mobile oder Desktop?
reviewContext.MaxReviewIterations = session.MaxReviewIterations > 0 ? session.MaxReviewIterations : 3;
var (provider, _) = OpenAiService.ParseModelString(modelId);
return new ChatContext
{
ChainId = chainId,
SessionId = sessionId,
ModelId = modelId,
Provider = provider,
Workspace = workspace,
AgentId = agent.AgentId,
SystemPromptText = systemPromptText,