diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantChatDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantChatDialog.java index 80e550dbc..275e23cb7 100644 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantChatDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/assistant/AssistantChatDialog.java @@ -673,6 +673,7 @@ You should also get your employer (if you work as a programmer) or school, import com.jdimension.jlawyer.ai.ParameterData; import com.jdimension.jlawyer.client.editors.files.ArchiveFilePanel; import com.jdimension.jlawyer.client.settings.ClientSettings; +import com.jdimension.jlawyer.client.settings.UserSettings; import com.jdimension.jlawyer.client.utils.ComponentUtils; import com.jdimension.jlawyer.client.utils.FrameUtils; import com.jdimension.jlawyer.client.utils.TemplatesUtil; @@ -1288,7 +1289,28 @@ private void cmdCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST private void cmdProcessOutputActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdProcessOutputActionPerformed if (this.inputAdapter instanceof AssistantFlowAdapter && this.result != null) { // caller is capable of handling results + //((AssistantFlowAdapter) this.inputAdapter).processOutput(capability, this.result); + + if(result.getResponse()!=null && result.getResponse().getOutputData()!=null) { + OutputData intro=new OutputData(); + intro.setType(OutputData.TYPE_STRING); + intro.setStringData("Chat-Verlauf: " + System.lineSeparator()+System.lineSeparator()); + result.getResponse().getOutputData().add(intro); + for(Message msg: this.messages) { + OutputData od=new OutputData(); + od.setType(OutputData.TYPE_STRING); + String role=msg.getRole(); + if("user".equalsIgnoreCase(role)) + role=UserSettings.getInstance().getCurrentUser().getPrincipalId(); + else + role="Assistent Ingo"; + od.setStringData(role + ": " + msg.getContent() + System.lineSeparator()+System.lineSeparator()); + result.getResponse().getOutputData().add(od); + } + } + ((AssistantFlowAdapter) this.inputAdapter).processOutput(capability, this.result); + } this.setVisible(false); this.dispose(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/AddNoteDialog.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/AddNoteDialog.java index 33c369530..b9137966e 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/AddNoteDialog.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/AddNoteDialog.java @@ -696,6 +696,7 @@ import com.jdimension.jlawyer.client.mail.EmailUtils; import com.jdimension.jlawyer.client.utils.AudioUtils; import com.jdimension.jlawyer.client.utils.ThreadUtils; +import com.jdimension.jlawyer.email.CommonMailUtils; import com.jdimension.jlawyer.services.IntegrationServiceRemote; import javax.sound.sampled.*; import java.io.ByteArrayOutputStream; @@ -836,6 +837,13 @@ public void setFocusToBody() { this.htmlEditorPanel1.requestFocus(); } + public void appendToBody(String appendText, boolean convertToHtml) { + if(convertToHtml) { + appendText=CommonMailUtils.text2Html(appendText); + } + this.htmlEditorPanel1.setText(this.htmlEditorPanel1.getText() + appendText); + } + public List getTranscribeInputs(byte[] wavContent) { ArrayList inputs = new ArrayList<>(); diff --git a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java index a05cf5ad9..2f0356903 100755 --- a/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java +++ b/j-lawyer-client/src/com/jdimension/jlawyer/client/editors/files/ArchiveFilePanel.java @@ -665,9 +665,13 @@ import com.iradraconis.shrinkify.ShrinkifyGui; import com.jdimension.jlawyer.ai.AiCapability; +import com.jdimension.jlawyer.ai.AiRequestStatus; import com.jdimension.jlawyer.ai.InputData; import com.jdimension.jlawyer.ai.Message; +import com.jdimension.jlawyer.ai.OutputData; +import com.jdimension.jlawyer.ai.ParameterData; import com.jdimension.jlawyer.client.assistant.AssistantAccess; +import com.jdimension.jlawyer.client.assistant.AssistantFlowAdapter; import com.jdimension.jlawyer.client.assistant.AssistantGenerateDialog; import com.jdimension.jlawyer.client.assistant.AssistantInputAdapter; import com.jdimension.jlawyer.comparator.ReviewsComparator; @@ -815,7 +819,7 @@ * * @author jens */ -public class ArchiveFilePanel extends javax.swing.JPanel implements ThemeableEditor, PopulateOptionsEditor, SaveableEditor, SelfValidatingEditor, com.jdimension.jlawyer.client.events.EventConsumer, NewEventPanelListener, NewMessageConsumer, DocumentPreviewSaveCallback, AssistantInputAdapter { +public class ArchiveFilePanel extends javax.swing.JPanel implements ThemeableEditor, PopulateOptionsEditor, SaveableEditor, SelfValidatingEditor, com.jdimension.jlawyer.client.events.EventConsumer, NewEventPanelListener, NewMessageConsumer, DocumentPreviewSaveCallback, AssistantFlowAdapter { private static final Logger log = Logger.getLogger(ArchiveFilePanel.class.getName()); @@ -7748,6 +7752,47 @@ public List getMessages(AiCapability c) { return null; } + @Override + public String getPrompt(AiCapability c) { + return null; + } + + @Override + public List getParameters(AiCapability c) { + return new ArrayList<>(); + } + + @Override + public void processOutput(AiCapability c, AiRequestStatus status) { + String resultText = ""; + if (status != null) { + if (status.getStatus().equalsIgnoreCase("error")) { + // ignore output + } else { + StringBuilder result = new StringBuilder(); + for (OutputData o : status.getResponse().getOutputData()) { + if (o.getType().equalsIgnoreCase(OutputData.TYPE_STRING)) { + result.append(o.getStringData()).append(System.lineSeparator()).append(System.lineSeparator()); + } + + } + resultText = result.toString(); + } + } + + AddNoteDialog dlg = new AddNoteDialog(EditorsRegistry.getInstance().getMainWindow(), true, this.caseFolderPanel1, this.dto); + dlg.setTitle("Notiz hinzufügen"); + dlg.appendToBody(System.lineSeparator() + "Assistent Ingo - Ergebnis (" + c.getName() + ")" + System.lineSeparator()+ System.lineSeparator() +resultText, true); + FrameUtils.centerDialog(dlg, EditorsRegistry.getInstance().getMainWindow()); + dlg.setVisible(true); + + } + + @Override + public void processError(AiCapability c, AiRequestStatus status) { + System.out.println("test"); + } + protected class DropTargetHandler implements DropTargetListener { private JPanel p = null; diff --git a/j-lawyer-server-common/src/com/jdimension/jlawyer/email/CommonMailUtils.java b/j-lawyer-server-common/src/com/jdimension/jlawyer/email/CommonMailUtils.java index 0f37644c4..2c9eaaf14 100644 --- a/j-lawyer-server-common/src/com/jdimension/jlawyer/email/CommonMailUtils.java +++ b/j-lawyer-server-common/src/com/jdimension/jlawyer/email/CommonMailUtils.java @@ -1048,6 +1048,23 @@ public static Part getAttachmentPart(String name, Object partObject) throws Exce return null; } + public static String text2Html(String text) { + if (text == null) { + return null; + } + // Escape HTML and add line breaks + return escapeHtml(text).replace("\n", "
"); + } + + private static String escapeHtml(String text) { + return text + .replace("&", "&") + .replace("<", "<") + .replace(">", ">") + .replace("\"", """) + .replace("'", "'"); + } + public static String html2Text(String html) { try { if (html == null) {