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, required=True,
) )
def _get_tool_call_kwargs(self):
return {
"tool_config": {
"function_calling_config": {
"mode": "ANY",
}
}
}
def __init__( def __init__(
self, self,
api_key: str | None = None, api_key: str | None = None,

View File

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

View File

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

View File

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

View File

@ -69,11 +69,21 @@ class DecomposeQuestionPipeline(RewriteQuestionPipeline):
sub_queries = [] sub_queries = []
if tool_calls: if tool_calls:
for tool_call in 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( sub_queries.append(
Document( Document(
content=SubQuery.parse_raw( content=sub_query,
tool_call["function"]["arguments"]
).sub_query
) )
) )

View File

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