Skip to content

Commit

Permalink
prototyping for a dialog that allows the combined use of free prompts…
Browse files Browse the repository at this point in the history
… and speech to text, enabling an efficient generation of texts / documents. issue #2395
  • Loading branch information
j-dimension committed Aug 18, 2024
1 parent 429949d commit bb127ec
Show file tree
Hide file tree
Showing 11 changed files with 1,840 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ public void flushCustomPrompts() {
}
}

public List<AssistantPrompt> getCustomPrompts(String requestType) throws Exception {
Map<String, List<AssistantPrompt>> allCustom=this.getCustomPrompts();
if(allCustom.containsKey(requestType)) {
return allCustom.get(requestType);
}
return new ArrayList<>();
}

private Map<String, List<AssistantPrompt>> getCustomPrompts() throws Exception {
synchronized (customPrompts) {
if (customPrompts.isEmpty()) {
Expand Down Expand Up @@ -860,7 +868,7 @@ public void populateMenu(JPopupMenu menu, Map<AssistantConfig, List<AiCapability
mi.setText(c.getName());
mi.setToolTipText(c.getDescription() + " (" + config.getName() + ")");
mi.addActionListener((ActionEvent e) -> {
GenericAssistantDialog dlg = new GenericAssistantDialog(config, c, adapter, !c.hasParameters(), EditorsRegistry.getInstance().getMainWindow(), false);
AssistantGenericDialog dlg = new AssistantGenericDialog(config, c, adapter, !c.hasParameters(), EditorsRegistry.getInstance().getMainWindow(), false);
dlg.setVisible(true);
});
menu.add(mi);
Expand All @@ -877,7 +885,7 @@ public void populateMenu(JMenu menu, Map<AssistantConfig, List<AiCapability>> ca
mi.setText(c.getName());
mi.setToolTipText(c.getDescription() + " (" + config.getName() + ")");
mi.addActionListener((ActionEvent e) -> {
GenericAssistantDialog dlg = new GenericAssistantDialog(config, c, adapter, !c.hasParameters(), EditorsRegistry.getInstance().getMainWindow(), false);
AssistantGenericDialog dlg = new AssistantGenericDialog(config, c, adapter, !c.hasParameters(), EditorsRegistry.getInstance().getMainWindow(), false);
dlg.setVisible(true);
});
menu.add(mi);
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,9 @@ You should also get your employer (if you work as a programmer) or school,
*
* @author jens
*/
public class GenericAssistantDialog extends javax.swing.JDialog {
public class AssistantGenericDialog extends javax.swing.JDialog {

private static final Logger log = Logger.getLogger(GenericAssistantDialog.class.getName());
private static final Logger log = Logger.getLogger(AssistantGenericDialog.class.getName());

private AssistantConfig config = null;
private AiCapability capability = null;
Expand All @@ -717,7 +717,7 @@ public class GenericAssistantDialog extends javax.swing.JDialog {
* @param parent
* @param modal
*/
public GenericAssistantDialog(AssistantConfig config, AiCapability c, AssistantInputAdapter inputAdapter, boolean autoExecute, java.awt.Frame parent, boolean modal) {
public AssistantGenericDialog(AssistantConfig config, AiCapability c, AssistantInputAdapter inputAdapter, boolean autoExecute, java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();

Expand Down Expand Up @@ -1200,19 +1200,20 @@ public static void main(String args[]) {
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(GenericAssistantDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(AssistantGenericDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(GenericAssistantDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(AssistantGenericDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(GenericAssistantDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(AssistantGenericDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(GenericAssistantDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
java.util.logging.Logger.getLogger(AssistantGenericDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>

/* Create and display the dialog */
java.awt.EventQueue.invokeLater(() -> {
GenericAssistantDialog dialog = new GenericAssistantDialog(null, null, null, false, new javax.swing.JFrame(), true);
AssistantGenericDialog dialog = new AssistantGenericDialog(null, null, null, false, new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,8 @@ private void cmdAssistantMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIR
this.popAssistant.removeAll();
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate2, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilities = ingo.filterCapabilities(AiCapability.REQUESTTYPE_EXPLAIN, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@
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.AssistantDictateDialog;
import com.jdimension.jlawyer.client.assistant.AssistantFlowAdapter;
import com.jdimension.jlawyer.client.assistant.AssistantInputAdapter;
import com.jdimension.jlawyer.client.calendar.CalendarUtils;
Expand Down Expand Up @@ -2504,12 +2505,24 @@ private void cmdAssistantMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIR
this.popAssistant.removeAll();
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilitiesGenerate2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_GENERATE, AiCapability.INPUTTYPE_NONE);
ingo.populateMenu(this.popAssistant, capabilitiesGenerate2, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilities = ingo.filterCapabilities(AiCapability.REQUESTTYPE_EXPLAIN, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilities2 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_SUMMARIZE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities2, (AssistantInputAdapter)this);
Map<AssistantConfig, List<AiCapability>> capabilities3 = ingo.filterCapabilities(AiCapability.REQUESTTYPE_TRANSLATE, AiCapability.INPUTTYPE_STRING);
ingo.populateMenu(this.popAssistant, capabilities3, (AssistantInputAdapter)this);

JMenuItem mi = new JMenuItem();
mi.setText("Text generieren (Diktat, Prompting)");
//mi.setToolTipText(c.getDescription() + " (" + config.getName() + ")");
mi.addActionListener((ActionEvent e) -> {
AssistantDictateDialog dlg = new AssistantDictateDialog(EditorsRegistry.getInstance().getMainWindow(), true);
dlg.setVisible(true);
});
this.popAssistant.add(mi);

this.popAssistant.show(this.cmdAssistant, evt.getX(), evt.getY());
} catch (Exception ex) {
log.error(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class AiCapability implements Serializable {

public static final String INPUTTYPE_STRING="STRING";
public static final String INPUTTYPE_FILE="FILE";
public static final String INPUTTYPE_NONE="NONE";

private String name;
private String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ You should also get your employer (if you work as a programmer) or school,
import com.jdimension.jlawyer.fax.utils.Base64;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ws.rs.core.Response;
import org.apache.log4j.Logger;
Expand Down
13 changes: 13 additions & 0 deletions j-lawyer-fax/src/com/jdimension/jlawyer/ai/NoneInput.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package com.jdimension.jlawyer.ai;

import java.io.Serializable;

class NoneInput extends Input implements Serializable {
// Implement if needed


}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file.reference.poi-excelant-4.1.2.jar=lib/poi/poi-excelant-4.1.2.jar
file.reference.poi-ooxml-4.1.2.jar=lib/poi/poi-ooxml-4.1.2.jar
file.reference.poi-ooxml-schemas-4.1.2.jar=lib/poi/poi-ooxml-schemas-4.1.2.jar
file.reference.poi-scratchpad-4.1.2.jar=lib/poi/poi-scratchpad-4.1.2.jar
j2ee.platform.classpath=${j2ee.server.home}/modules/system/layers/base/javax/activation/api/main/activation-1.1.1.jar:${j2ee.server.home}/modules/system/layers/base/javax/annotation/api/main/jboss-annotations-api_1.3_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/batch/api/main/jboss-batch-api_1.0_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.2_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/el/api/main/jboss-el-api_3.0_spec-1.0.13.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/api/main/cdi-api-2.0.SP1.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/concurrent/api/main/jboss-concurrency-api_1.0_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-2.3.9.SP01.jar:${j2ee.server.home}/modules/system/layers/base/javax/inject/api/main/javax.inject-1.jar:${j2ee.server.home}/modules/system/layers/base/javax/interceptor/api/main/jboss-interceptors-api_1.2_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/jms/api/main/jboss-jms-api_2.0_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/api/main/javax.json-api-1.1.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/bind/api/main/javax.json.bind-api-1.0.jar:${j2ee.server.home}/modules/system/layers/base/javax/jws/api/main/jsr181-api-1.0-MR1.jar:${j2ee.server.home}/modules/system/layers/base/javax/mail/api/main/javax.mail-1.6.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/management/j2ee/api/main/jboss-j2eemgmt-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/orb/api/main/openjdk-orb-8.1.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/persistence/api/main/javax.persistence-api-2.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/resource/api/main/jboss-connector-api_1.7_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/auth/message/api/main/jboss-jaspi-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/enterprise/api/main/javax.security.enterprise-api-1.0.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/jacc/api/main/jboss-jacc-api_1.5_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/api/main/jboss-servlet-api_4.0_spec-1.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jsp/api/main/jboss-jsp-api_2.3_spec-1.0.3.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-compat-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-impl-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-spec-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.2_spec-1.1.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/validation/api/main/validation-api-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/websocket/api/main/jboss-websocket-api_1.1_spec-1.1.3.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ws/rs/api/main/jboss-jaxrs-api_2.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/wsdl4j/api/main/wsdl4j-1.6.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.3_spec-1.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/rpc/api/main/jboss-jaxrpc-api_1.1_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/soap/api/main/jboss-saaj-api_1.3_spec-1.0.6.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/ws/api/main/jboss-jaxws-api_2.3_spec-1.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/el/main/javax.el-impl-3.0.1-b08-jbossorg-1.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/enterprise/concurrent/main/javax.enterprise.concurrent-1.0.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/json/main/javax.json-1.1.2.jar
j2ee.platform.classpath=${j2ee.server.home}/modules/system/layers/base/javax/activation/api/main/jakarta.activation-1.2.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/annotation/api/main/jboss-annotations-api_1.3_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/batch/api/main/jboss-batch-api_1.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ejb/api/main/jboss-ejb-api_3.2_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/el/api/main/jboss-el-api_3.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/api/main/jakarta.enterprise.cdi-api-2.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/enterprise/concurrent/api/main/jboss-concurrency-api_1.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/faces/api/main/jboss-jsf-api_2.3_spec-3.1.0.SP01.jar:${j2ee.server.home}/modules/system/layers/base/javax/inject/api/main/jakarta.inject-api-1.0.5.jar:${j2ee.server.home}/modules/system/layers/base/javax/interceptor/api/main/jboss-interceptors-api_1.2_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/jms/api/main/jboss-jms-api_2.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/api/main/jakarta.json-api-1.1.6.jar:${j2ee.server.home}/modules/system/layers/base/javax/json/bind/api/main/jakarta.json.bind-api-1.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/jws/api/main/jsr181-api-1.0-MR1.jar:${j2ee.server.home}/modules/system/layers/base/javax/mail/api/main/jakarta.mail-1.6.7.jar:${j2ee.server.home}/modules/system/layers/base/javax/management/j2ee/api/main/jboss-j2eemgmt-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/orb/api/main/openjdk-orb-8.1.7.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/persistence/api/main/jakarta.persistence-api-2.2.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/resource/api/main/jboss-connector-api_1.7_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/auth/message/api/main/jboss-jaspi-api_1.1_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/enterprise/api/main/jakarta.security.enterprise-api-1.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/security/jacc/api/main/jboss-jacc-api_1.5_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/api/main/jboss-servlet-api_4.0_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jsp/api/main/jboss-jsp-api_2.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-compat-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-impl-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/servlet/jstl/api/main/taglibs-standard-spec-1.2.6-RC1.jar:${j2ee.server.home}/modules/system/layers/base/javax/transaction/api/main/jboss-transaction-api_1.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/validation/api/main/jakarta.validation-api-2.0.2.jar:${j2ee.server.home}/modules/system/layers/base/javax/websocket/api/main/jboss-websocket-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/ws/rs/api/main/jboss-jaxrs-api_2.1_spec-2.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/wsdl4j/api/main/wsdl4j-1.6.3.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/bind/api/main/jboss-jaxb-api_2.3_spec-2.0.1.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/rpc/api/main/jboss-jaxrpc-api_1.1_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/soap/api/main/jboss-saaj-api_1.4_spec-1.0.2.Final.jar:${j2ee.server.home}/modules/system/layers/base/javax/xml/ws/api/main/jboss-jaxws-api_2.3_spec-2.0.0.Final.jar:${j2ee.server.home}/modules/system/layers/base/org/glassfish/javax/enterprise/concurrent/main/jakarta.enterprise.concurrent-1.1.1.jar
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
Expand Down

0 comments on commit bb127ec

Please sign in to comment.