Cronjobs + AnthropicService Singleton Refactoring
Cronjobs: - CronjobService (BackgroundService) prüft jede Minute auf fällige Jobs - Cron-Expression in Server-Lokalzeit via Cronos (CronFormat.Standard) - Cronjob-Ausführung: Prompt → Session → Agent-Antwort in Chat-History - Optionale Benachrichtigungs-Session (notify_session_id): Zusammenfassung wird in separate Session geschrieben (z.B. mit Telegram) - Telegram-Benachrichtigung mit Cronjob-Name + Ursprungs-Session - REST API: CRUD + toggle + manuelles Ausführen (/run) - Frontend: Dashboard-Cards, Cronjob-Formular mit Cron-Vorschau, Session-Dropdown, Notify-Session-Dropdown, Status-Box Refactoring: - AnthropicService als Singleton in DI registriert - ChatEndpoint + TelegramService nutzen injizierte Instanz - Redundante Dependencies (Token, ToolService, MemoryService) entfernt Neue Dateien: - Models/CronjobRecord.cs - Services/CronjobService.cs - Endpoints/CronjobEndpoint.cs - wwwroot/js/pages/cronjob-page.js - PLAN-Cronjob.md
This commit is contained in:
1 parent
0120bb8f73
commit
b645625b56
16 files changed
+1132
-28
No files matched your search
@@ -10,29 +10,23 @@ namespace Gott.Services;
|
||||
|
||||
public class TelegramService
|
||||
{
|
||||
private readonly string _anthropicToken;
|
||||
private readonly IHttpClientFactory _httpFactory;
|
||||
private readonly DatabaseService _db;
|
||||
private readonly ToolService _toolService;
|
||||
private readonly MemoryService _memoryService;
|
||||
private readonly ChatService _chatService;
|
||||
private readonly AnthropicService _anthropic;
|
||||
private readonly int _maxIterations;
|
||||
|
||||
public TelegramService(
|
||||
string anthropicToken,
|
||||
IHttpClientFactory httpFactory,
|
||||
DatabaseService db,
|
||||
ToolService toolService,
|
||||
MemoryService memoryService,
|
||||
ChatService chatService,
|
||||
AnthropicService anthropic,
|
||||
int maxIterations = 100)
|
||||
{
|
||||
_anthropicToken = anthropicToken;
|
||||
_httpFactory = httpFactory;
|
||||
_db = db;
|
||||
_toolService = toolService;
|
||||
_memoryService = memoryService;
|
||||
_chatService = chatService;
|
||||
_anthropic = anthropic;
|
||||
_maxIterations = maxIterations;
|
||||
}
|
||||
|
||||
@@ -165,8 +159,7 @@ public class TelegramService
|
||||
});
|
||||
|
||||
// AnthropicService für Non-Streaming-Chat nutzen
|
||||
var anthropic = new AnthropicService(_httpFactory, _anthropicToken, _toolService, _db, _memoryService);
|
||||
var reply = await anthropic.ChatNonStreaming(ctx, history, onIteration: async (iteration) =>
|
||||
var reply = await _anthropic.ChatNonStreaming(ctx, history, onIteration: async (iteration) =>
|
||||
{
|
||||
if (iteration % 3 == 0)
|
||||
await SendChatAction(chatId, botToken, "typing");
|
||||
|
||||
Reference in new issue
Block a user