Skip to content

Commit fceba24

Browse files
author
kali
committed
Minor
1 parent bf12078 commit fceba24

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

C2Client/C2Client/AssistantPanel.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Assistant(QWidget):
3939
sem = Semaphore()
4040

4141
def __init__(self, parent, grpcClient):
42-
super(QWidget, self).__init__(parent)
42+
super().__init__(parent)
4343
self.layout = QVBoxLayout(self)
4444
self.layout.setContentsMargins(0, 0, 0, 0)
4545

@@ -52,7 +52,7 @@ def __init__(self, parent, grpcClient):
5252
self.editorOutput.setReadOnly(True)
5353
# Force word wrapping
5454
self.editorOutput.setLineWrapMode(QTextEdit.LineWrapMode.WidgetWidth)
55-
self.editorOutput.setLineWrapColumnOrWidth(0) # 0 = wrap at widget edge
55+
self.editorOutput.setLineWrapColumnOrWidth(0)
5656
self.layout.addWidget(self.editorOutput, 8)
5757

5858
self.commandEditor = CommandEditor()
@@ -99,6 +99,11 @@ def __init__(self, parent, grpcClient):
9999
self._response_thread = None
100100
self._response_lock = Lock()
101101

102+
api_key = os.environ.get("OPENAI_API_KEY")
103+
if not api_key:
104+
self.printInTerminal("System", "OPENAI_API_KEY is not set, functionality deactivated.")
105+
else:
106+
self.printInTerminal("System", "To let the assistant interact with sessions, select one or multiples sessions in the Sessions tab and interact with it, otherwise the assistant will not be feed the responses.")
102107

103108
def nextCompletion(self):
104109
index = self._compl.currentIndex()
@@ -194,7 +199,13 @@ def event(self, event):
194199

195200
def printInTerminal(self, header="", message="", detail=""):
196201
now = datetime.now()
197-
formater = '<p style="white-space:pre">'+'<span style="color:blue;">['+now.strftime("%Y:%m:%d %H:%M:%S").rstrip()+']</span>'+'<span style="color:red;"> [+] </span>'+'<span style="color:red;">{}</span>'+'</p>'
202+
formater = (
203+
'<p style="white-space:pre-wrap; word-wrap:break-word;">'
204+
'<span style="color:blue;">['+now.strftime("%Y:%m:%d %H:%M:%S").rstrip()+']</span>'
205+
'<span style="color:red;"> [+] </span>'
206+
'<span style="color:red;">{}</span>'
207+
'</p>'
208+
)
198209

199210
self.sem.acquire()
200211
try:

0 commit comments

Comments
 (0)