This commit is contained in:
parent
bfd281f17e
commit
9bd365a44e
|
|
@ -282,17 +282,32 @@ def render_conversation_box() -> rx.Component:
|
||||||
runs = ConversationState.get_runs
|
runs = ConversationState.get_runs
|
||||||
|
|
||||||
# 若运行字典为空则渲染品牌图标和名称、预设用户提示词,否则遍历渲染运行项
|
# 若运行字典为空则渲染品牌图标和名称、预设用户提示词,否则遍历渲染运行项
|
||||||
return rx.auto_scroll(
|
return rx.vstack(
|
||||||
rx.cond(
|
rx.cond(
|
||||||
ConversationState.is_runs_empty,
|
runs.length() == 0,
|
||||||
# 渲染空运行字典组件
|
|
||||||
rx.center(
|
|
||||||
rx.vstack(
|
rx.vstack(
|
||||||
rx.spacer(),
|
|
||||||
# 智能体图标和名称
|
# 智能体图标和名称
|
||||||
rx.hstack(
|
rx.hstack(
|
||||||
rx.icon("info", size=18),
|
rx.image(
|
||||||
rx.text("智能体"),
|
src="/logo.png",
|
||||||
|
width="64px",
|
||||||
|
height="64px",
|
||||||
|
object_fit="contain", # 等比缩放
|
||||||
|
),
|
||||||
|
rx.box(
|
||||||
|
"Gluballu",
|
||||||
|
font_size="32px",
|
||||||
|
font_weight="700",
|
||||||
|
letter_spacing="1px",
|
||||||
|
),
|
||||||
|
display="flex",
|
||||||
|
margin_bottom="12px",
|
||||||
|
align_items="center",
|
||||||
|
gap="8px",
|
||||||
|
),
|
||||||
|
rx.box(
|
||||||
|
"Gluballu 可辅助产品检索业务资料、开展产品设计与撰写产品方案等。",
|
||||||
|
line_height="1.5",
|
||||||
),
|
),
|
||||||
# 预设用户提示词
|
# 预设用户提示词
|
||||||
rx.box(
|
rx.box(
|
||||||
|
|
@ -304,21 +319,25 @@ def render_conversation_box() -> rx.Component:
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
spacing="4",
|
color="var(--devui-text)",
|
||||||
width="min(100%, 40em)",
|
|
||||||
padding_y="40px",
|
|
||||||
),
|
),
|
||||||
border="none",
|
# 遍历渲染运行项
|
||||||
),
|
rx.auto_scroll(
|
||||||
# 遍历渲染运行组件
|
|
||||||
rx.foreach(
|
rx.foreach(
|
||||||
runs,
|
runs,
|
||||||
lambda i, _: render_run_component(i[0], i[1]),
|
lambda i, _: render_run_component(i[0], i[1]),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
display="flex",
|
||||||
flex="1",
|
flex="1",
|
||||||
padding="8px",
|
flex_direction="column",
|
||||||
overflow_y="auto",
|
width="100%",
|
||||||
|
max_height="1200px",
|
||||||
|
padding="0 12px",
|
||||||
|
justify_content="flex-start",
|
||||||
|
gap="24px",
|
||||||
|
overflow="auto",
|
||||||
style={
|
style={
|
||||||
"&::-webkit-scrollbar": {
|
"&::-webkit-scrollbar": {
|
||||||
"display": "none",
|
"display": "none",
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,12 @@ def render_sidebar() -> rx.Component:
|
||||||
rx.vstack(
|
rx.vstack(
|
||||||
# 渲染品牌 LOGO 和名称
|
# 渲染品牌 LOGO 和名称
|
||||||
rx.vstack(
|
rx.vstack(
|
||||||
# 渲染品牌 Logo
|
|
||||||
rx.image(
|
rx.image(
|
||||||
src="/logo.png",
|
src="/logo.png",
|
||||||
width="34px",
|
width="34px",
|
||||||
height="34px",
|
height="34px",
|
||||||
object_fit="contain", # 等比缩放
|
object_fit="contain", # 等比缩放
|
||||||
),
|
),
|
||||||
# 渲染品牌名称
|
|
||||||
rx.text(
|
rx.text(
|
||||||
"Gluballu",
|
"Gluballu",
|
||||||
line_height="20px", # 行高
|
line_height="20px", # 行高
|
||||||
|
|
|
||||||
|
|
@ -143,18 +143,6 @@ class ConversationState(rx.State):
|
||||||
conversation = self.conversations.get(self.conversation_id)
|
conversation = self.conversations.get(self.conversation_id)
|
||||||
return conversation.description if conversation else "新对话"
|
return conversation.description if conversation else "新对话"
|
||||||
|
|
||||||
@rx.var
|
|
||||||
def is_runs_empty(self) -> bool:
|
|
||||||
"""
|
|
||||||
运行字典是否为空
|
|
||||||
:return: 运行字典是否为空
|
|
||||||
"""
|
|
||||||
# 当前对话
|
|
||||||
conversation = self.conversations.get(self.conversation_id)
|
|
||||||
if not conversation:
|
|
||||||
return True
|
|
||||||
return not conversation.runs
|
|
||||||
|
|
||||||
@rx.var
|
@rx.var
|
||||||
def get_runs(self) -> Dict[str, Run]:
|
def get_runs(self) -> Dict[str, Run]:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue