@@ -51,12 +51,11 @@ def __init__(self, parent=None, chat_obj=None, chat_data=None):
51
51
QWidget {
52
52
background: transparent;
53
53
}
54
-
55
54
"""
56
55
57
56
self .setStyleSheet (self .style_str )
58
57
59
- self .chats_data = { # Initialize chats_data as an empty dictionary
58
+ self .chats_data = {
60
59
"title" : "" ,
61
60
"chatlist" : []
62
61
}
@@ -66,36 +65,101 @@ def __init__(self, parent=None, chat_obj=None, chat_data=None):
66
65
self .chats_data ["chatlist" ] += self .chat_data ["chatlist" ]
67
66
68
67
self .show_chats ()
68
+
69
69
def show_chats (self ):
70
- # chat_title = self.chats_data.get("title")
71
- chat_list = self .chats_data .get ("chatlist" )
72
- for chat in chat_list :
73
- input_str = chat .get ("input_str" )
74
- input_widget = InputWidget (chat_obj = self .chat_object )
75
- input_widget .set_input_text (input_str )
76
- self .main_verticalLayout .addWidget (input_widget )
77
-
78
- out_str = chat .get ("output_str" )
79
- out_widget = OutWidget ()
80
- # markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.tables'])
70
+ chat_list = self .chats_data .get ("chatlist" )
71
+ for chat in chat_list :
72
+ input_str = chat .get ("input_str" )
73
+ input_widget = InputWidget (chat_obj = self .chat_object )
74
+ input_widget .set_input_text (input_str )
75
+ self .main_verticalLayout .addWidget (input_widget )
76
+
77
+ out_str = chat .get ("output_str" )
78
+ out_widget = OutWidget ()
79
+
80
+ markdown_text = markdown (out_str , extensions = ['markdown.extensions.extra' , 'markdown.extensions.attr_list' ])
81
+ markdown_text = markdown_text .replace ('<table>' , '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">' )
82
+ markdown_text = markdown_text .replace ('<th>' , '<th style="border: 1px solid white; padding: 10px;">' )
83
+ markdown_text = markdown_text .replace ('<td>' , '<td style="border: 1px solid white; padding: 10px;">' )
84
+ out_widget .set_output_text (markdown_text )
85
+ self .main_verticalLayout .addWidget (out_widget )
86
+
87
+ attached_pdf_info = chat .get ("pdf_info" )
88
+ if attached_pdf_info :
89
+ pdf_widget = OutWidget ()
90
+ pdf_widget .set_output_text (attached_pdf_info )
91
+ self .main_verticalLayout .addWidget (pdf_widget )
92
+
93
+ spacerItem = QSpacerItem (20 , 300 , QSizePolicy .Policy .Minimum , QSizePolicy .Policy .Expanding )
94
+ self .main_verticalLayout .addItem (spacerItem )
95
+ self .setLayout (self .main_verticalLayout )
96
+
97
+ # class ChatWindow(QWidget):
98
+ # def __init__(self, parent=None, chat_obj=None, chat_data=None):
99
+ # super().__init__(parent)
100
+ # self.chat_object = chat_obj
101
+ # self.chat_data = chat_data
102
+
103
+ # self.main_verticalLayout = QVBoxLayout(self)
104
+ # self.main_verticalLayout.setContentsMargins(0, 0, 0, 0)
105
+ # self.main_verticalLayout.setSpacing(0)
106
+ # self.main_verticalLayout.setObjectName("main_verticalLayout")
107
+
108
+ # self.style_str = """
109
+ # QPushButton,
110
+ # QLabel {
111
+ # border: none;
112
+ # padding: 5px;
113
+ # }
114
+
115
+ # QWidget {
116
+ # background: transparent;
117
+ # }
118
+
119
+ # """
120
+
121
+ # self.setStyleSheet(self.style_str)
122
+
123
+ # self.chats_data = { # Initialize chats_data as an empty dictionary
124
+ # "title": "",
125
+ # "chatlist": []
126
+ # }
127
+
128
+ # if self.chat_data:
129
+ # self.chats_data["title"] = self.chat_data["title"]
130
+ # self.chats_data["chatlist"] += self.chat_data["chatlist"]
131
+
132
+ # self.show_chats()
133
+ # def show_chats(self):
134
+ # # chat_title = self.chats_data.get("title")
135
+ # chat_list = self.chats_data.get("chatlist")
136
+ # for chat in chat_list:
137
+ # input_str = chat.get("input_str")
138
+ # input_widget = InputWidget(chat_obj=self.chat_object)
139
+ # input_widget.set_input_text(input_str)
140
+ # self.main_verticalLayout.addWidget(input_widget)
141
+
142
+ # out_str = chat.get("output_str")
143
+ # out_widget = OutWidget()
144
+ # # markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.tables'])
81
145
82
- markdown_text = markdown (out_str , extensions = ['markdown.extensions.extra' , 'markdown.extensions.attr_list' ])
146
+ # markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.attr_list'])
83
147
84
- # Add the custom attributes for the table, th, and td elements
85
- markdown_text = markdown_text .replace ('<table>' , '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">' )
86
- markdown_text = markdown_text .replace ('<th>' , '<th style="border: 1px solid white; padding: 10px;">' )
87
- markdown_text = markdown_text .replace ('<td>' , '<td style="border: 1px solid white; padding: 10px;">' )
88
- out_widget .set_output_text (markdown_text )
89
- self .main_verticalLayout .addWidget (out_widget )
90
-
91
- # out_str = chat.get("output_str")
92
- # out_widget = OutWidget()
93
- # out_widget.set_output_text(out_str)
94
- # self.main_verticalLayout.addWidget(out_widget)
95
-
96
- spacerItem = QSpacerItem (20 , 300 , QSizePolicy .Policy .Minimum , QSizePolicy .Policy .Expanding )
97
- self .main_verticalLayout .addItem (spacerItem )
98
- self .setLayout (self .main_verticalLayout )
148
+ # # Add the custom attributes for the table, th, and td elements
149
+ # markdown_text = markdown_text.replace('<table>', '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">')
150
+ # markdown_text = markdown_text.replace('<th>', '<th style="border: 1px solid white; padding: 10px;">')
151
+ # markdown_text = markdown_text.replace('<td>', '<td style="border: 1px solid white; padding: 10px;">')
152
+ # out_widget.set_output_text(markdown_text)
153
+ # self.main_verticalLayout.addWidget(out_widget)
154
+
155
+ # # out_str = chat.get("output_str")
156
+ # # out_widget = OutWidget()
157
+ # # out_widget.set_output_text(out_str)
158
+ # # self.main_verticalLayout.addWidget(out_widget)
159
+
160
+ # spacerItem = QSpacerItem(20, 300, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
161
+ # self.main_verticalLayout.addItem(spacerItem)
162
+ # self.setLayout(self.main_verticalLayout)
99
163
100
164
# def show_chats(self):
101
165
# chat_list = self.chats_data.get("chatlist")
0 commit comments