feat: KI-Funktionalität per .env-Schalter AI_ENABLED abschaltbar (Standard: aus)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
13
.env.example
13
.env.example
@@ -41,3 +41,16 @@ MONGODB_ELEMENT_SCRIPT_COLLECTION=element_script
|
|||||||
# true = Script-Element wird im Editor nicht angezeigt
|
# true = Script-Element wird im Editor nicht angezeigt
|
||||||
# false = Script-Element ist verfügbar (Standard)
|
# false = Script-Element ist verfügbar (Standard)
|
||||||
HIDE_SCRIPT_BLOCK=false
|
HIDE_SCRIPT_BLOCK=false
|
||||||
|
|
||||||
|
# --- KI-Workflow-Assistent ---------------------------------------------------
|
||||||
|
# KI-Funktionalität ein-/ausschalten:
|
||||||
|
# true = KI-Assistent ist im Editor verfügbar
|
||||||
|
# false = KI-Assistent ist deaktiviert (Standard)
|
||||||
|
AI_ENABLED=false
|
||||||
|
|
||||||
|
# API-Key für die Claude API (https://platform.claude.com/settings/keys).
|
||||||
|
# Ohne Key ist der KI-Assistent im Editor deaktiviert.
|
||||||
|
ANTHROPIC_API_KEY=
|
||||||
|
|
||||||
|
# Verwendetes Claude-Modell (Standard: claude-opus-4-8):
|
||||||
|
#ANTHROPIC_MODEL=claude-opus-4-8
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import java.util.List;
|
|||||||
public class WorkflowAssistantService {
|
public class WorkflowAssistantService {
|
||||||
|
|
||||||
private final BlockTypeRegistry registry;
|
private final BlockTypeRegistry registry;
|
||||||
|
private final boolean aiEnabled;
|
||||||
private final String apiKey;
|
private final String apiKey;
|
||||||
private final String model;
|
private final String model;
|
||||||
private final ObjectMapper lenientMapper;
|
private final ObjectMapper lenientMapper;
|
||||||
@@ -38,9 +39,11 @@ public class WorkflowAssistantService {
|
|||||||
private volatile AnthropicClient client;
|
private volatile AnthropicClient client;
|
||||||
|
|
||||||
public WorkflowAssistantService(BlockTypeRegistry registry,
|
public WorkflowAssistantService(BlockTypeRegistry registry,
|
||||||
|
@Value("${tasklist.ai-enabled:false}") boolean aiEnabled,
|
||||||
@Value("${tasklist.anthropic-api-key:}") String apiKey,
|
@Value("${tasklist.anthropic-api-key:}") String apiKey,
|
||||||
@Value("${tasklist.anthropic-model:claude-opus-4-8}") String model) {
|
@Value("${tasklist.anthropic-model:claude-opus-4-8}") String model) {
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
|
this.aiEnabled = aiEnabled;
|
||||||
this.apiKey = apiKey == null ? "" : apiKey.trim();
|
this.apiKey = apiKey == null ? "" : apiKey.trim();
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.lenientMapper = new ObjectMapper()
|
this.lenientMapper = new ObjectMapper()
|
||||||
@@ -51,9 +54,9 @@ public class WorkflowAssistantService {
|
|||||||
public record WorkflowDraft(String name, List<TaskDto> tasks) {
|
public record WorkflowDraft(String name, List<TaskDto> tasks) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Ob der Assistent nutzbar ist (API-Key in der .env hinterlegt). */
|
/** Ob der Assistent nutzbar ist (AI_ENABLED=true und API-Key in der .env). */
|
||||||
public boolean isEnabled() {
|
public boolean isEnabled() {
|
||||||
return !apiKey.isBlank();
|
return aiEnabled && !apiKey.isBlank();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +87,8 @@ public class WorkflowAssistantService {
|
|||||||
public WorkflowDraft generateWorkflow(String wish, String currentName, String currentTasksJson) {
|
public WorkflowDraft generateWorkflow(String wish, String currentName, String currentTasksJson) {
|
||||||
if (!isEnabled()) {
|
if (!isEnabled()) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Kein Claude-API-Key konfiguriert (ANTHROPIC_API_KEY in der .env-Datei).");
|
"KI-Assistent deaktiviert: AI_ENABLED=true und ANTHROPIC_API_KEY "
|
||||||
|
+ "in der .env-Datei setzen.");
|
||||||
}
|
}
|
||||||
if (wish == null || wish.isBlank()) {
|
if (wish == null || wish.isBlank()) {
|
||||||
throw new IllegalStateException("Bitte einen Workflow-Wunsch eingeben.");
|
throw new IllegalStateException("Bitte einen Workflow-Wunsch eingeben.");
|
||||||
|
|||||||
@@ -229,6 +229,8 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
|||||||
assistant.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
assistant.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||||
assistant.setTooltipText("Workflow aus einer Beschreibung erzeugen oder ändern (Claude)");
|
assistant.setTooltipText("Workflow aus einer Beschreibung erzeugen oder ändern (Claude)");
|
||||||
assistant.addClickListener(e -> openAssistantDialog());
|
assistant.addClickListener(e -> openAssistantDialog());
|
||||||
|
// KI-Funktionalität per .env (AI_ENABLED) abschaltbar.
|
||||||
|
assistant.setVisible(workflowAssistantService.isEnabled());
|
||||||
|
|
||||||
Button undo = new Button("Rückgängig", new Icon(VaadinIcon.ARROW_BACKWARD));
|
Button undo = new Button("Rückgängig", new Icon(VaadinIcon.ARROW_BACKWARD));
|
||||||
undo.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
undo.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
|
||||||
@@ -1033,8 +1035,9 @@ public class MainView extends VerticalLayout implements BeforeEnterObserver {
|
|||||||
*/
|
*/
|
||||||
private void openAssistantDialog() {
|
private void openAssistantDialog() {
|
||||||
if (!workflowAssistantService.isEnabled()) {
|
if (!workflowAssistantService.isEnabled()) {
|
||||||
Notification.show("KI-Assistent nicht verfügbar: Bitte ANTHROPIC_API_KEY "
|
Notification.show("KI-Assistent nicht verfügbar: Bitte AI_ENABLED=true und "
|
||||||
+ "in der .env-Datei hinterlegen und die Anwendung neu starten.");
|
+ "ANTHROPIC_API_KEY in der .env-Datei hinterlegen und die "
|
||||||
|
+ "Anwendung neu starten.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean modifying = !instances.isEmpty();
|
boolean modifying = !instances.isEmpty();
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ management.health.mongo.enabled=false
|
|||||||
tasklist.hide-script-block=${HIDE_SCRIPT_BLOCK:false}
|
tasklist.hide-script-block=${HIDE_SCRIPT_BLOCK:false}
|
||||||
|
|
||||||
# --- KI-Workflow-Assistent (Claude API) --------------------------------------
|
# --- KI-Workflow-Assistent (Claude API) --------------------------------------
|
||||||
# API-Key und Modell kommen aus der .env-Datei (ANTHROPIC_API_KEY,
|
# Ein-/Ausschalter, API-Key und Modell kommen aus der .env-Datei (AI_ENABLED,
|
||||||
# ANTHROPIC_MODEL). Ohne Key ist der Assistent im Editor deaktiviert.
|
# ANTHROPIC_API_KEY, ANTHROPIC_MODEL). Der Assistent ist nur verfügbar, wenn
|
||||||
|
# AI_ENABLED=true gesetzt UND ein Key hinterlegt ist (Standard: aus).
|
||||||
|
tasklist.ai-enabled=${AI_ENABLED:false}
|
||||||
tasklist.anthropic-api-key=${ANTHROPIC_API_KEY:}
|
tasklist.anthropic-api-key=${ANTHROPIC_API_KEY:}
|
||||||
tasklist.anthropic-model=${ANTHROPIC_MODEL:claude-opus-4-8}
|
tasklist.anthropic-model=${ANTHROPIC_MODEL:claude-opus-4-8}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user