KI-Feature 4.5.22: KI-Unterstützung direkt aus dem Stunden-Editor starten
Bisher musste man aus dem Stunden-Editor raus, die KI-Hilfe für die ganze Einheit aufrufen und die gewünschte Stunde in der freien Anweisung erst benennen. Neuer Button "KI-Unterstützung für diese Stunde" im LessonDialog öffnet denselben AiAssistDialog im neuen Fokus-Modus. AiPlanningRequest.FocusLessonId weist die KI im Systemprompt an, sich auf genau diese Stunde zu beschränken; zusätzlich wie beim Umfangs-Umschalter client-seitig hart durchgesetzt in Send() und ApplyResponse, statt der KI-Antwort blind zu vertrauen. Da "Übernehmen" direkt ins Repository speichert, wären die noch offenen Feldwerte des ursprünglichen LessonDialog danach veraltet gewesen - der Dialog schließt sich deshalb nach einer angewendeten KI-Änderung automatisch mit dem frischen Stand statt ihn mit alten Werten zu überschreiben. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -299,13 +299,14 @@ public class AiPlanningService(HttpClient http, ILessonRepository lessons,
|
||||
}
|
||||
|
||||
public async Task<AiPlanningResponse> RequestPlanAsync(Unit unit, string instruction, string token,
|
||||
bool allowModifyingExistingLessons = true, List<AiLesson>? draftOverrides = null)
|
||||
bool allowModifyingExistingLessons = true, List<AiLesson>? draftOverrides = null, Guid? focusLessonId = null)
|
||||
{
|
||||
var request = new AiPlanningRequest
|
||||
{
|
||||
Instruction = instruction,
|
||||
Unit = BuildContext(unit, instruction, draftOverrides),
|
||||
AllowModifyingExistingLessons = allowModifyingExistingLessons,
|
||||
FocusLessonId = focusLessonId,
|
||||
};
|
||||
|
||||
using var req = new HttpRequestMessage(HttpMethod.Post, "plan.php")
|
||||
@@ -388,9 +389,12 @@ public class AiPlanningService(HttpClient http, ILessonRepository lessons,
|
||||
/// interpretiert, sondern immer als neue Lesson behandelt (Anti-Halluzinations-Absicherung).
|
||||
/// Ist <paramref name="allowModifyingExistingLessons"/> false, werden Änderungen an bestehenden
|
||||
/// Lessons zusätzlich hart verworfen (nicht nur per Systemprompt an die KI erbeten) — die
|
||||
/// Einschränkung wird also nicht blind der KI-Antwort überlassen.
|
||||
/// Einschränkung wird also nicht blind der KI-Antwort überlassen. Ist
|
||||
/// <paramref name="focusLessonId"/> gesetzt (Anfrage aus dem Editor einer einzelnen Stunde
|
||||
/// heraus), wird ebenso hart jede Lesson mit abweichender oder fehlender Id verworfen.
|
||||
/// </summary>
|
||||
public List<Lesson> ApplyResponse(Unit unit, List<AiLesson> acceptedLessons, bool allowModifyingExistingLessons = true)
|
||||
public List<Lesson> ApplyResponse(Unit unit, List<AiLesson> acceptedLessons,
|
||||
bool allowModifyingExistingLessons = true, Guid? focusLessonId = null)
|
||||
{
|
||||
var pathIdsByName = altPaths.GetAll().ToDictionary(p => p.Name, p => p.Id);
|
||||
var existingLessons = lessons.GetByUnit(unit.Id).ToDictionary(l => l.Id);
|
||||
@@ -398,6 +402,7 @@ public class AiPlanningService(HttpClient http, ILessonRepository lessons,
|
||||
var result = new List<Lesson>();
|
||||
foreach (var ai in acceptedLessons)
|
||||
{
|
||||
if (focusLessonId is { } focus && ai.Id != focus) continue;
|
||||
var isUpdate = ai.Id is { } id && existingLessons.ContainsKey(id);
|
||||
if (isUpdate && !allowModifyingExistingLessons) continue;
|
||||
result.Add(new Lesson
|
||||
|
||||
Reference in New Issue
Block a user