Skip to content

Commit 013f6f4

Browse files
authored
fix: code block overflow in chat (#509) bump:patch
1 parent 747bff8 commit 013f6f4

File tree

6 files changed

+125
-36
lines changed

6 files changed

+125
-36
lines changed

docs/about.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,3 @@ developers in mind.
99
[User Guide](https://cinnamon.github.io/kotaemon/) |
1010
[Developer Guide](https://cinnamon.github.io/kotaemon/development/) |
1111
[Feedback](https://github.com/Cinnamon/kotaemon/issues)
12-
13-
[Dark Mode](?__theme=dark) |
14-
[Light Mode](?__theme=light)

libs/ktem/ktem/assets/css/main.css

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ button.selected {
5252
font-weight: bold;
5353
}
5454

55+
.message-row.bubble.bot-row{
56+
overflow-x: auto;
57+
}
58+
59+
.flex-wrap.bot {
60+
overflow-x: inherit;
61+
}
62+
5563
#chat-tab,
5664
#indices-tab,
5765
#settings-tab,
@@ -191,11 +199,11 @@ mark {
191199
right: 15px;
192200
}
193201

194-
#new-conv-button > img {
202+
/* #new-conv-button > img {
195203
position: relative;
196204
top: 0px;
197205
right: -50%;
198-
}
206+
} */
199207

200208
span.icon {
201209
color: #cecece;
@@ -271,3 +279,54 @@ pdfjs-viewer-element {
271279
flex: 1;
272280
overflow: auto;
273281
}
282+
283+
/** Switch
284+
-------------------------------------*/
285+
286+
#is-public-checkbox {
287+
position: relative;
288+
top: 4px;
289+
}
290+
291+
.switch input {
292+
position: absolute;
293+
opacity: 0;
294+
}
295+
296+
/**
297+
* 1. Adjust this to size
298+
*/
299+
300+
.switch {
301+
display: inline-block;
302+
/* 1 */
303+
height: 1em;
304+
width: 2em;
305+
background: #8f8f8f;
306+
border-radius: 1em;
307+
position: relative;
308+
top: 2px;
309+
margin-right: 1em;
310+
}
311+
312+
.switch div {
313+
height: 1em;
314+
width: 1em;
315+
border-radius: 1em;
316+
background: #FFF;
317+
box-shadow: 0 0.1em 0.3em rgba(0, 0, 0, 0.3);
318+
-webkit-transition: all 300ms;
319+
-moz-transition: all 300ms;
320+
transition: all 300ms;
321+
}
322+
323+
.switch input:checked+div {
324+
-webkit-transform: translate3d(100%, 0, 0);
325+
-moz-transform: translate3d(100%, 0, 0);
326+
transform: translate3d(100%, 0, 0);
327+
background: #12df9a;
328+
}
329+
330+
.switch:has(> input:checked) {
331+
background: #0c895f;
332+
}

libs/ktem/ktem/assets/js/main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ function run() {
1616
let chat_info_panel = document.getElementById("info-expand");
1717
chat_info_panel.insertBefore(info_expand_button, chat_info_panel.childNodes[2]);
1818

19+
// create slider toggle
20+
const is_public_checkbox = document.getElementById("is-public-checkbox");
21+
const label_element = is_public_checkbox.getElementsByTagName("label")[0];
22+
const checkbox_span = is_public_checkbox.getElementsByTagName("span")[0];
23+
new_div = document.createElement("div");
24+
25+
label_element.classList.add("switch");
26+
is_public_checkbox.appendChild(checkbox_span);
27+
label_element.appendChild(new_div)
28+
1929
// clpse
2030
globalThis.clpseFn = (id) => {
2131
var obj = document.getElementById('clpse-btn-' + id);

libs/ktem/ktem/assets/md/about.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,3 @@ An open-source tool for you to chat with your documents.
88
[User Guide](https://cinnamon.github.io/kotaemon/) |
99
[Developer Guide](https://cinnamon.github.io/kotaemon/development/) |
1010
[Feedback](https://github.com/Cinnamon/kotaemon/issues)
11-
12-
[Dark Mode](?__theme=dark)
13-
[Night Mode](?__theme=light)

libs/ktem/ktem/pages/chat/__init__.py

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ def __init__(self, app):
7676

7777
self._preview_links = gr.State(value=None)
7878
self._reasoning_type = gr.State(value=None)
79-
self._llm_type = gr.State(value=None)
8079
self._conversation_renamed = gr.State(value=False)
8180
self._suggestion_updated = gr.State(value=False)
8281
self._info_panel_expanded = gr.State(value=True)
@@ -142,20 +141,21 @@ def on_building_ui(self):
142141
with gr.Row():
143142
gr.HTML("Reasoning method")
144143
gr.HTML("Model")
144+
gr.HTML("Generate mindmap")
145145

146146
with gr.Row():
147147
reasoning_type_values = [
148148
(DEFAULT_SETTING, DEFAULT_SETTING)
149149
] + self._app.default_settings.reasoning.settings[
150150
"use"
151151
].choices
152-
self.reasoning_types = gr.Dropdown(
152+
self.reasoning_type = gr.Dropdown(
153153
choices=reasoning_type_values,
154154
value=DEFAULT_SETTING,
155155
container=False,
156156
show_label=False,
157157
)
158-
self.model_types = gr.Dropdown(
158+
self.model_type = gr.Dropdown(
159159
choices=self._app.default_settings.reasoning.options[
160160
"simple"
161161
]
@@ -165,6 +165,17 @@ def on_building_ui(self):
165165
container=False,
166166
show_label=False,
167167
)
168+
binary_default_choices = [
169+
(DEFAULT_SETTING, DEFAULT_SETTING),
170+
("Enable", True),
171+
("Disable", False),
172+
]
173+
self.use_mindmap = gr.Dropdown(
174+
value=DEFAULT_SETTING,
175+
choices=binary_default_choices,
176+
container=False,
177+
show_label=False,
178+
)
168179

169180
with gr.Column(
170181
scale=INFO_PANEL_SCALES[False], elem_id="chat-info-panel"
@@ -222,7 +233,8 @@ def on_register_events(self):
222233
self.chat_panel.chatbot,
223234
self._app.settings_state,
224235
self._reasoning_type,
225-
self._llm_type,
236+
self.model_type,
237+
self.use_mindmap,
226238
self.state_chat,
227239
self._app.user_id,
228240
]
@@ -489,16 +501,11 @@ def on_register_events(self):
489501
+ self._indices_input,
490502
outputs=None,
491503
)
492-
self.reasoning_types.change(
504+
self.reasoning_type.change(
493505
self.reasoning_changed,
494-
inputs=[self.reasoning_types],
506+
inputs=[self.reasoning_type],
495507
outputs=[self._reasoning_type],
496508
)
497-
self.model_types.change(
498-
lambda x: x,
499-
inputs=[self.model_types],
500-
outputs=[self._llm_type],
501-
)
502509
self.chat_control.conversation_id.change(
503510
lambda: gr.update(visible=False),
504511
outputs=self.plot_panel,
@@ -714,6 +721,7 @@ def create_pipeline(
714721
settings: dict,
715722
session_reasoning_type: str,
716723
session_llm: str,
724+
session_use_mindmap: bool | str,
717725
state: dict,
718726
user_id: int,
719727
*selecteds,
@@ -730,7 +738,12 @@ def create_pipeline(
730738
- the pipeline objects
731739
"""
732740
# override reasoning_mode by temporary chat page state
733-
print("Session reasoning type", session_reasoning_type)
741+
print(
742+
"Session reasoning type",
743+
session_reasoning_type,
744+
"use mindmap",
745+
session_use_mindmap,
746+
)
734747
print("Session LLM", session_llm)
735748
reasoning_mode = (
736749
settings["reasoning.use"]
@@ -743,9 +756,16 @@ def create_pipeline(
743756

744757
settings = deepcopy(settings)
745758
llm_setting_key = f"reasoning.options.{reasoning_id}.llm"
746-
if llm_setting_key in settings and session_llm not in (DEFAULT_SETTING, None):
759+
if llm_setting_key in settings and session_llm not in (
760+
DEFAULT_SETTING,
761+
None,
762+
"",
763+
):
747764
settings[llm_setting_key] = session_llm
748765

766+
if session_use_mindmap not in (DEFAULT_SETTING, None):
767+
settings["reasoning.options.simple.create_mindmap"] = session_use_mindmap
768+
749769
# get retrievers
750770
retrievers = []
751771
for index in self._app.index_manager.indices:
@@ -777,6 +797,7 @@ def chat_fn(
777797
settings,
778798
reasoning_type,
779799
llm_type,
800+
use_mind_map,
780801
state,
781802
user_id,
782803
*selecteds,
@@ -793,7 +814,7 @@ def chat_fn(
793814

794815
# construct the pipeline
795816
pipeline, reasoning_state = self.create_pipeline(
796-
settings, reasoning_type, llm_type, state, user_id, *selecteds
817+
settings, reasoning_type, llm_type, use_mind_map, state, user_id, *selecteds
797818
)
798819
print("Reasoning state", reasoning_state)
799820
pipeline.set_output_queue(queue)

libs/ktem/ktem/pages/chat/control.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,6 @@ def __init__(self, app):
4040
def on_building_ui(self):
4141
with gr.Row():
4242
gr.Markdown("## Conversations")
43-
self.btn_new = gr.Button(
44-
value="",
45-
icon=f"{ASSETS_DIR}/new.svg",
46-
min_width=2,
47-
scale=1,
48-
size="sm",
49-
elem_classes=["no-background", "body-text-color"],
50-
elem_id="new-conv-button",
51-
)
5243
self.btn_toggle_dark_mode = gr.Button(
5344
value="",
5445
icon=f"{ASSETS_DIR}/dark_mode.svg",
@@ -87,6 +78,22 @@ def on_building_ui(self):
8778
)
8879

8980
with gr.Row() as self._new_delete:
81+
self.cb_is_public = gr.Checkbox(
82+
value=False,
83+
label="Shared",
84+
min_width=10,
85+
scale=4,
86+
elem_id="is-public-checkbox",
87+
container=False,
88+
)
89+
self.btn_conversation_rn = gr.Button(
90+
value="",
91+
icon=f"{ASSETS_DIR}/rename.svg",
92+
min_width=2,
93+
scale=1,
94+
size="sm",
95+
elem_classes=["no-background", "body-text-color"],
96+
)
9097
self.btn_del = gr.Button(
9198
value="",
9299
icon=f"{ASSETS_DIR}/delete.svg",
@@ -95,16 +102,14 @@ def on_building_ui(self):
95102
size="sm",
96103
elem_classes=["no-background", "body-text-color"],
97104
)
98-
self.btn_conversation_rn = gr.Button(
105+
self.btn_new = gr.Button(
99106
value="",
100-
icon=f"{ASSETS_DIR}/rename.svg",
107+
icon=f"{ASSETS_DIR}/new.svg",
101108
min_width=2,
102109
scale=1,
103110
size="sm",
104111
elem_classes=["no-background", "body-text-color"],
105-
)
106-
self.cb_is_public = gr.Checkbox(
107-
value=False, label="Share conversation", min_width=10, scale=6
112+
elem_id="new-conv-button",
108113
)
109114

110115
with gr.Row(visible=False) as self._delete_confirm:

0 commit comments

Comments
 (0)