chatbot improvements

This commit is contained in:
Bane Stojkovic
2025-04-06 21:51:26 +02:00
parent f03a0b1417
commit 0279a89700
4 changed files with 20 additions and 12 deletions
@@ -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("<br>");
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<? extends IDIYComponent<?>>) 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<? extends IDIYComponent<?>>) c.getClass());
@@ -117,7 +125,6 @@ public class SpiceSumarizer {
sb.append(c.getValue());
}
}
return componentType.getName() + " [" + componentType.getCategory() + "]";
}
private static String formatSpiceNode(int i) {
@@ -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 {
@@ -293,7 +293,7 @@ public class ChatbotPane extends JPanel {
public JButton getAskButton() {
if (askButton == null) {
askButton = new JButton("Ask");
askButton = new JButton("<html>Send &#9166;</html>");
askButton.setBackground(TERMINAL_BG);
askButton.setForeground(TERMINAL_FG);
askButton.setFocusPainted(false);