From 0279a89700a76e8ed1edeac7a306453cbd9f2ec8 Mon Sep 17 00:00:00 2001 From: Bane Stojkovic Date: Sun, 6 Apr 2025 21:51:26 +0200 Subject: [PATCH] chatbot improvements --- .../org/diylc/netlist/SpiceSumarizer.java | 25 ++++++++++++------- .../chatbot/service/ChatbotService.java | 2 +- .../swing/plugins/chatbot/ChatbotPane.java | 2 +- knowledge/user_manual.sql | 3 ++- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/diylc/diylc-core/src/main/java/org/diylc/netlist/SpiceSumarizer.java b/diylc/diylc-core/src/main/java/org/diylc/netlist/SpiceSumarizer.java index 50f1cfb8..286ae295 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/netlist/SpiceSumarizer.java +++ b/diylc/diylc-core/src/main/java/org/diylc/netlist/SpiceSumarizer.java @@ -75,14 +75,9 @@ public class SpiceSumarizer { sb.append(" "); } - String comment = outputComponentValue(c, sb); + outputComponentValue(c, sb); - if (c instanceof ISpiceMapper) { - String spiceComment = ((ISpiceMapper)c).getComment(); - if (spiceComment != null) - comment += spiceComment; - } - sb.append(" ; ").append(comment); + outputComment(c, sb); if (useHTML) sb.append("
"); lines.add(sb.toString()); @@ -94,7 +89,20 @@ public class SpiceSumarizer { .collect(Collectors.joining("\n")); } - private static String outputComponentValue(IDIYComponent c, StringBuilder sb) { + private static void outputComment(IDIYComponent c, StringBuilder sb) { + ComponentType componentType = ComponentProcessor.getInstance() + .extractComponentTypeFrom((Class>) c.getClass()); + + String comment = componentType.getName() + " [" + componentType.getCategory() + "]"; + if (c instanceof ISpiceMapper) { + String spiceComment = ((ISpiceMapper) c).getComment(); + if (spiceComment != null) + comment = spiceComment + " " + comment; + } + sb.append(" ; ").append(comment); + } + + private static void outputComponentValue(IDIYComponent c, StringBuilder sb) { ComponentType componentType = ComponentProcessor.getInstance() .extractComponentTypeFrom((Class>) c.getClass()); @@ -117,7 +125,6 @@ public class SpiceSumarizer { sb.append(c.getValue()); } } - return componentType.getName() + " [" + componentType.getCategory() + "]"; } private static String formatSpiceNode(int i) { diff --git a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java index eb70a265..b9d0f30a 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java +++ b/diylc/diylc-core/src/main/java/org/diylc/plugins/chatbot/service/ChatbotService.java @@ -161,7 +161,7 @@ public class ChatbotService { if (!netlist.getSwitchSetup().isEmpty()) { sb.append("Switch configuration: ").append(netlist.getSwitchSetup()).append(". "); } - sb.append("Effective circuit netlist") + sb.append("Circuit netlist") .append(netlist.getSwitchSetup().isEmpty() ? "" : " in this switch configuration") .append(":\n\n"); try { diff --git a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java index 16dbc54a..1e60a9a2 100644 --- a/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java +++ b/diylc/diylc-swing/src/main/java/org/diylc/swing/plugins/chatbot/ChatbotPane.java @@ -293,7 +293,7 @@ public class ChatbotPane extends JPanel { public JButton getAskButton() { if (askButton == null) { - askButton = new JButton("Ask"); + askButton = new JButton("Send ⏎"); askButton.setBackground(TERMINAL_BG); askButton.setForeground(TERMINAL_FG); askButton.setFocusPainted(false); diff --git a/knowledge/user_manual.sql b/knowledge/user_manual.sql index f62c9268..0f665a7a 100644 --- a/knowledge/user_manual.sql +++ b/knowledge/user_manual.sql @@ -254,4 +254,5 @@ INSERT INTO diylc_knowledge_base(category, section, content) VALUES ('User Manua - If you are asking about a DIYLC feature, make sure to include the words "DIYLC" or "DIY Layout Creator" and the feature in question to ensure that the AI assistant understands the context of the question. - Use simple language and avoid complex technical terms. - Ask follow-up questions if needed. -- Use the "Clear" button to reset the conversation.'); \ No newline at end of file +- Use the "Clear" button to reset the conversation. +- Each chat conversation is associated with the current project and is saved in the cloud and will be automatically downloaded when that project is opened.'); \ No newline at end of file