8000 implement showing result feature · ag-python-qt/pyqt-openai@aae5990 · GitHub
[go: up one dir, main page]

Skip to content

Commit aae5990

Browse files
committed
implement showing result feature
1 parent 2796cb9 commit aae5990

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

pyqt_openai/chat_widget/aiChatUnit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ def disableGUIDuringGenerateResponse(self):
161161
self.__copyBtn.setEnabled(False)
162162
self.__infoBtn.setEnabled(False)
163163

164-
def showConvResultInfo(self, finish_reason):
164+
def showConvResultInfo(self, info_dict):
165165
self.__copyBtn.setEnabled(True)
166166
self.__infoBtn.setEnabled(True)
167+
self.__result_info = info_dict
167168

168169
def setText(self, text: str):
169170
self.__lbl = QLabel(text)

pyqt_openai/chat_widget/convUnitResultDialog.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ def __initUi(self):
1515
self.setWindowTitle('Conversation Result')
1616
self.setWindowFlags(Qt.Window | Qt.WindowCloseButtonHint)
1717

18-
model_nameLbl = QLabel('model_nameLbl')
19-
finish_reasonLbl = QLabel('finish_reasonLbl')
20-
prompt_tokensLbl = QLabel('prompt_tokensLbl')
21-
completion_tokensLbl = QLabel('completion_tokensLbl')
22-
total_tokensLbl = QLabel('total_tokensLbl')
18+
lbls = []
19+
for k, v in self.__result_info.items():
20+
lbls.append(QLabel(f'{k}: {v}'))
2321

2422
sep = QFrame()
2523
sep.setFrameShape(QFrame.HLine)
@@ -29,11 +27,8 @@ def __initUi(self):
2927
okBtn.clicked.connect(self.accept)
3028

3129
lay = QFormLayout()
32-
lay.addWidget(model_nameLbl)
33-
lay.addWidget(finish_reasonLbl)
34-
lay.addWidget(prompt_tokensLbl)
35-
lay.addWidget(completion_tokensLbl)
36-
lay.addWidget(total_tokensLbl)
30+
for lbl in lbls:
31+
lay.addWidget(lbl)
3732
lay.addWidget(sep)
3833
lay.addWidget(okBtn)
3934

pyqt_openai/sqlite.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -545,12 +545,15 @@ def selectAllContentOfConv(self):
545545

546546
def insertConvUnit(self, id, user_f, conv, info):
547547
try:
548-
# TODO 2023-11-11
549-
# Insert a row into the table
550548
finish_reason = info['finish_reason']
549+
model_name = info['model_name']
550+
prompt_tokens = info['prompt_tokens']
551+
completion_tokens = info['completion_tokens']
552+
total_tokens = info['total_tokens']
551553
self.__c.execute(
552-
f'INSERT INTO {self.__conv_unit_tb_nm}{id} (id_fk, is_user, conv, finish_reason) VALUES (?, ?, ?, ?)',
553-
(id, user_f, conv, finish_reason))
554+
f'INSERT INTO {self.__conv_unit_tb_nm}{id} (id_fk, is_user, conv, finish_reason, model_name, '
555+
f'prompt_tokens, completion_tokens, total_tokens) VALUES (?, ?, ?, ?, ?, ?, ?, ?)',
556+
(id, user_f, conv, finish_reason, model_name, prompt_tokens, completion_tokens, total_tokens))
554557
new_id = self.__c.lastrowid
555558
# Commit the transaction
556559
self.__conn.commit()

0 commit comments

Comments
 (0)
0