feat: add citation style quick setting (#554) bump:patch

This commit is contained in:
Tuan Anh Nguyen Dang (Tadashi_Cin) 2024-12-05 19:55:59 +07:00 committed by GitHub
parent 7d8f40e841
commit 6650b15c64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 46 additions and 13 deletions

View File

@ -296,6 +296,15 @@ class LCGeminiChat(LCChatMixin, ChatLLM): # type: ignore
required=True,
)
def _get_tool_call_kwargs(self):
return {
"tool_config": {
"function_calling_config": {
"mode": "ANY",
}
}
}
def __init__(
self,
api_key: str | None = None,

View File

@ -208,7 +208,12 @@ mark {
position: absolute;
top: 6px;
right: -10px;
z-index: 10;
z-index: 1;
}
#quick-setting-labels {
margin-top: 5px;
margin-bottom: -10px;
}
#use-mindmap-checkbox {
@ -218,6 +223,14 @@ mark {
right: 25px;
}
#citation-dropdown {
width: min(25%, 100px);
position: absolute;
top: 2px;
left: 120px;
height: 35px;
}
#quick-url textarea {
resize: none;
background: transparent;
@ -262,7 +275,7 @@ pdfjs-viewer-element {
.modal {
display: none;
position: relative;
z-index: 1;
z-index: 2;
left: 0;
top: 0;
width: 100%;
@ -351,11 +364,11 @@ pdfjs-viewer-element {
/* Bot animation */
.message.bot {
animation: fadein 1.5s ease-in-out forwards;
animation: fadein 1.0s ease-in-out forwards;
}
details.evidence {
animation: fadein 0.5s ease-in-out forwards;
animation: fadein 0.3s ease-in-out forwards;
}
@keyframes fadein {

View File

@ -41,8 +41,10 @@ function run() {
// move use mind-map checkbox
let mindmap_checkbox = document.getElementById("use-mindmap-checkbox");
let citation_dropdown = document.getElementById("citation-dropdown");
let chat_setting_panel = document.getElementById("chat-settings-expand");
chat_setting_panel.insertBefore(mindmap_checkbox, chat_setting_panel.childNodes[2]);
chat_setting_panel.insertBefore(citation_dropdown, mindmap_checkbox);
// create slider toggle
const is_public_checkbox = document.getElementById("is-public-checkbox");

View File

@ -185,12 +185,10 @@ class ChatPage(BasePage):
elem_id="chat-settings-expand",
open=False,
):
# a quick switch for reasoning type option
with gr.Row():
with gr.Row(elem_id="quick-setting-labels"):
gr.HTML("Reasoning method")
gr.HTML("Model")
gr.HTML("Language")
gr.HTML("Citation")
with gr.Row():
reasoning_type_values = [
@ -236,6 +234,7 @@ class ChatPage(BasePage):
container=False,
show_label=False,
interactive=True,
elem_id="citation-dropdown",
)
self.use_mindmap = gr.State(value=DEFAULT_SETTING)

View File

@ -69,11 +69,21 @@ class DecomposeQuestionPipeline(RewriteQuestionPipeline):
sub_queries = []
if tool_calls:
for tool_call in tool_calls:
if "function" in tool_call:
# openai and cohere format
function_output = tool_call["function"]["arguments"]
else:
# anthropic format
function_output = tool_call["args"]
if isinstance(function_output, str):
sub_query = SubQuery.parse_raw(function_output).sub_query
else:
sub_query = SubQuery.parse_obj(function_output).sub_query
sub_queries.append(
Document(
content=SubQuery.parse_raw(
tool_call["function"]["arguments"]
).sub_query
content=sub_query,
)
)

View File

@ -411,9 +411,9 @@ class FullQAPipeline(BaseReasoning):
"value": "highlight",
"component": "radio",
"choices": [
("highlight (long answer)", "highlight"),
("inline (precise answer)", "inline"),
("off", "off"),
("highlight (verbose)", "highlight"),
("inline (concise)", "inline"),
("no citation", "off"),
],
},
"create_mindmap": {