Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -668,85 +668,43 @@ with gr.Blocks(css=css, fill_width=True) as demo:
|
|
668 |
with ms.Slot("avatar"):
|
669 |
antd.Avatar(
|
670 |
os.path.join(os.path.dirname(__file__),
|
671 |
-
|
672 |
with ms.Slot(
|
673 |
"messageRender",
|
674 |
params_mapping="""(content, bubble) => {
|
675 |
-
const reason_content = bubble?.meta?.reason_content
|
676 |
const has_error = bubble?.meta?.error
|
677 |
return {
|
678 |
-
reasoning: reason_content || content,
|
679 |
-
reasoning_container: has_error ? { style: { display: 'none' } } : undefined,
|
680 |
answer: {
|
681 |
-
value:
|
682 |
},
|
683 |
-
collapse_label: bubble.meta?.thought_end_message,
|
684 |
-
collapse_progress: bubble.meta?.thought_end_message ? { style: { display: 'none' } } : undefined,
|
685 |
canceled: bubble.meta?.canceled ? undefined : { style: { display: 'none' } }
|
686 |
}
|
687 |
}"""):
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
"reasoning"
|
693 |
-
],
|
694 |
-
as_item="reasoning_container"):
|
695 |
-
with antd.Collapse.Item(
|
696 |
-
key="reasoning"):
|
697 |
-
with ms.Slot("label"):
|
698 |
-
with antd.Space(
|
699 |
-
size="middle"):
|
700 |
-
ms.Span(
|
701 |
-
get_text(
|
702 |
-
"Thinking...",
|
703 |
-
"思考中..."),
|
704 |
-
as_item=
|
705 |
-
"collapse_label")
|
706 |
-
antd.Progress(
|
707 |
-
percent="100",
|
708 |
-
status="active",
|
709 |
-
elem_style=dict(
|
710 |
-
display="flex",
|
711 |
-
alignItems=
|
712 |
-
"center",
|
713 |
-
),
|
714 |
-
show_info=False,
|
715 |
-
size=[110, 5],
|
716 |
-
as_item=
|
717 |
-
"collapse_progress"
|
718 |
-
)
|
719 |
-
with antd.Alert(
|
720 |
-
type="warning"):
|
721 |
-
with ms.Slot(
|
722 |
-
"description"):
|
723 |
-
ms.Markdown(
|
724 |
-
as_item="reasoning"
|
725 |
-
)
|
726 |
-
ms.Markdown(
|
727 |
-
as_item="answer",
|
728 |
-
elem_classes="answer-content")
|
729 |
|
730 |
antd.Divider(as_item="canceled")
|
731 |
antd.Typography.Text(get_text(
|
732 |
"Chat completion paused.", "聊天已暂停。"),
|
733 |
-
|
734 |
-
|
735 |
|
736 |
with ms.Slot("footer",
|
737 |
-
|
738 |
-
|
739 |
return {
|
740 |
-
|
741 |
copyable: { text: bubble.content, tooltips: false },
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
};
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
with ms.Div(as_item="actions_container"):
|
751 |
with antd.Typography.Text(
|
752 |
copyable=dict(tooltips=False),
|
@@ -790,11 +748,11 @@ with gr.Blocks(css=css, fill_width=True) as demo:
|
|
790 |
with ms.Slot("icon"):
|
791 |
antd.Icon("SyncOutlined")
|
792 |
with antd.Button(value=None,
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
with ms.Slot("icon"):
|
799 |
antd.Icon("EditOutlined")
|
800 |
with antd.Popconfirm(
|
@@ -815,6 +773,7 @@ with gr.Blocks(css=css, fill_width=True) as demo:
|
|
815 |
with ms.Slot("icon"):
|
816 |
antd.Icon("DeleteOutlined")
|
817 |
|
|
|
818 |
# Sender
|
819 |
with antdx.Suggestion(
|
820 |
items=DEFAULT_SUGGESTIONS,
|
|
|
668 |
with ms.Slot("avatar"):
|
669 |
antd.Avatar(
|
670 |
os.path.join(os.path.dirname(__file__),
|
671 |
+
"rednote_hilab.png"))
|
672 |
with ms.Slot(
|
673 |
"messageRender",
|
674 |
params_mapping="""(content, bubble) => {
|
|
|
675 |
const has_error = bubble?.meta?.error
|
676 |
return {
|
|
|
|
|
677 |
answer: {
|
678 |
+
value: content
|
679 |
},
|
|
|
|
|
680 |
canceled: bubble.meta?.canceled ? undefined : { style: { display: 'none' } }
|
681 |
}
|
682 |
}"""):
|
683 |
+
# 直接显示答案内容,不再有thinking相关的组件
|
684 |
+
ms.Markdown(
|
685 |
+
as_item="answer",
|
686 |
+
elem_classes="answer-content")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
687 |
|
688 |
antd.Divider(as_item="canceled")
|
689 |
antd.Typography.Text(get_text(
|
690 |
"Chat completion paused.", "聊天已暂停。"),
|
691 |
+
as_item="canceled",
|
692 |
+
type="warning")
|
693 |
|
694 |
with ms.Slot("footer",
|
695 |
+
params_mapping="""(bubble) => {
|
696 |
+
if (bubble?.meta?.end) {
|
697 |
return {
|
698 |
+
copy_btn: {
|
699 |
copyable: { text: bubble.content, tooltips: false },
|
700 |
+
},
|
701 |
+
regenerate_btn: { conversationKey: bubble.key, disabled: bubble.meta.disabled },
|
702 |
+
delete_btn: { conversationKey: bubble.key, disabled: bubble.meta.disabled },
|
703 |
+
edit_btn: { conversationKey: bubble.key, disabled: bubble.meta.disabled },
|
704 |
};
|
705 |
+
}
|
706 |
+
return { actions_container: { style: { display: 'none' } } };
|
707 |
+
}"""):
|
708 |
with ms.Div(as_item="actions_container"):
|
709 |
with antd.Typography.Text(
|
710 |
copyable=dict(tooltips=False),
|
|
|
748 |
with ms.Slot("icon"):
|
749 |
antd.Icon("SyncOutlined")
|
750 |
with antd.Button(value=None,
|
751 |
+
size="small",
|
752 |
+
color="default",
|
753 |
+
variant="text",
|
754 |
+
as_item="edit_btn"
|
755 |
+
) as chatbot_edit_btn:
|
756 |
with ms.Slot("icon"):
|
757 |
antd.Icon("EditOutlined")
|
758 |
with antd.Popconfirm(
|
|
|
773 |
with ms.Slot("icon"):
|
774 |
antd.Icon("DeleteOutlined")
|
775 |
|
776 |
+
|
777 |
# Sender
|
778 |
with antdx.Suggestion(
|
779 |
items=DEFAULT_SUGGESTIONS,
|