Skip to content

Commit 351069a

Browse files
committed
feat: add citation style quick setting
1 parent 7d8f40e commit 351069a

File tree

6 files changed

+46
-13
lines changed

6 files changed

+46
-13
lines changed

libs/kotaemon/kotaemon/llms/chats/langchain_based.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ class LCGeminiChat(LCChatMixin, ChatLLM): # type: ignore
296296
required=True,
297297
)
298298

299+
def _get_tool_call_kwargs(self):
300+
return {
301+
"tool_config": {
302+
"function_calling_config": {
303+
"mode": "ANY",
304+
}
305+
}
306+
}
307+
299308
def __init__(
300309
self,
301310
api_key: str | None = None,

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,12 @@ mark {
208208
position: absolute;
209209
top: 6px;
210210
right: -10px;
211-
z-index: 10;
211+
z-index: 1;
212+
}
213+
214+
#quick-setting-labels {
215+
margin-top: 5px;
216+
margin-bottom: -10px;
212217
}
213218

214219
#use-mindmap-checkbox {
@@ -218,6 +223,14 @@ mark {
218223
right: 25px;
219224
}
220225

226+
#citation-dropdown {
227+
width: min(25%, 100px);
228+
position: absolute;
229+
top: 2px;
230+
left: 120px;
231+
height: 35px;
232+
}
233+
221234
#quick-url textarea {
222235
resize: none;
223236
background: transparent;
@@ -262,7 +275,7 @@ pdfjs-viewer-element {
262275
.modal {
263276
display: none;
264277
position: relative;
265-
z-index: 1;
278+
z-index: 2;
266279
left: 0;
267280
top: 0;
268281
width: 100%;
@@ -351,11 +364,11 @@ pdfjs-viewer-element {
351364
/* Bot animation */
352365

353366
.message.bot {
354-
animation: fadein 1.5s ease-in-out forwards;
367+
animation: fadein 1.0s ease-in-out forwards;
355368
}
356369

357370
details.evidence {
358-
animation: fadein 0.5s ease-in-out forwards;
371+
animation: fadein 0.3s ease-in-out forwards;
359372
}
360373

361374
@keyframes fadein {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ function run() {
4141

4242
// move use mind-map checkbox
4343
let mindmap_checkbox = document.getElementById("use-mindmap-checkbox");
44+
let citation_dropdown = document.getElementById("citation-dropdown");
4445
let chat_setting_panel = document.getElementById("chat-settings-expand");
4546
chat_setting_panel.insertBefore(mindmap_checkbox, chat_setting_panel.childNodes[2]);
47+
chat_setting_panel.insertBefore(citation_dropdown, mindmap_checkbox);
4648

4749
// create slider toggle
4850
const is_public_checkbox = document.getElementById("is-public-checkbox");

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,10 @@ def on_building_ui(self):
185185
elem_id="chat-settings-expand",
186186
open=False,
187187
):
188-
# a quick switch for reasoning type option
189-
with gr.Row():
188+
with gr.Row(elem_id="quick-setting-labels"):
190189
gr.HTML("Reasoning method")
191190
gr.HTML("Model")
192191
gr.HTML("Language")
193-
gr.HTML("Citation")
194192

195193
with gr.Row():
196194
reasoning_type_values = [
@@ -236,6 +234,7 @@ def on_building_ui(self):
236234
container=False,
237235
show_label=False,
238236
interactive=True,
237+
elem_id="citation-dropdown",
239238
)
240239

241240
self.use_mindmap = gr.State(value=DEFAULT_SETTING)

libs/ktem/ktem/reasoning/prompt_optimization/decompose_question.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,21 @@ def run(self, question: str) -> list: # type: ignore
6969
sub_queries = []
7070
if tool_calls:
7171
for tool_call in tool_calls:
72+
if "function" in tool_call:
73+
# openai and cohere format
74+
function_output = tool_call["function"]["arguments"]
75+
else:
76+
# anthropic format
77+
function_output = tool_call["args"]
78+
79+
if isinstance(function_output, str):
80+
sub_query = SubQuery.parse_raw(function_output).sub_query
81+
else:
82+
sub_query = SubQuery.parse_obj(function_output).sub_query
83+
7284
sub_queries.append(
7385
Document(
74-
content=SubQuery.parse_raw(
75-
tool_call["function"]["arguments"]
76-
).sub_query
86+
content=sub_query,
7787
)
7888
)
7989

libs/ktem/ktem/reasoning/simple.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ def get_user_settings(cls) -> dict:
411411
"value": "highlight",
412412
"component": "radio",
413413
"choices": [
414-
("highlight (long answer)", "highlight"),
415-
("inline (precise answer)", "inline"),
416-
("off", "off"),
414+
("highlight (verbose)", "highlight"),
415+
("inline (concise)", "inline"),
416+
("no citation", "off"),
417417
],
418418
},
419419
"create_mindmap": {

0 commit comments

Comments
 (0)