This commit is contained in:
parent
bfd281f17e
commit
9bd365a44e
|
|
@ -282,17 +282,32 @@ def render_conversation_box() -> rx.Component:
|
|||
runs = ConversationState.get_runs
|
||||
|
||||
# 若运行字典为空则渲染品牌图标和名称、预设用户提示词,否则遍历渲染运行项
|
||||
return rx.auto_scroll(
|
||||
return rx.vstack(
|
||||
rx.cond(
|
||||
ConversationState.is_runs_empty,
|
||||
# 渲染空运行字典组件
|
||||
rx.center(
|
||||
runs.length() == 0,
|
||||
rx.vstack(
|
||||
rx.spacer(),
|
||||
# 智能体图标和名称
|
||||
rx.hstack(
|
||||
rx.icon("info", size=18),
|
||||
rx.text("智能体"),
|
||||
rx.image(
|
||||
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(
|
||||
|
|
@ -304,21 +319,25 @@ def render_conversation_box() -> rx.Component:
|
|||
),
|
||||
)
|
||||
),
|
||||
spacing="4",
|
||||
width="min(100%, 40em)",
|
||||
padding_y="40px",
|
||||
color="var(--devui-text)",
|
||||
),
|
||||
border="none",
|
||||
),
|
||||
# 遍历渲染运行组件
|
||||
# 遍历渲染运行项
|
||||
rx.auto_scroll(
|
||||
rx.foreach(
|
||||
runs,
|
||||
lambda i, _: render_run_component(i[0], i[1]),
|
||||
),
|
||||
),
|
||||
),
|
||||
display="flex",
|
||||
flex="1",
|
||||
padding="8px",
|
||||
overflow_y="auto",
|
||||
flex_direction="column",
|
||||
width="100%",
|
||||
max_height="1200px",
|
||||
padding="0 12px",
|
||||
justify_content="flex-start",
|
||||
gap="24px",
|
||||
overflow="auto",
|
||||
style={
|
||||
"&::-webkit-scrollbar": {
|
||||
"display": "none",
|
||||
|
|
|
|||
|
|
@ -72,14 +72,12 @@ def render_sidebar() -> rx.Component:
|
|||
rx.vstack(
|
||||
# 渲染品牌 LOGO 和名称
|
||||
rx.vstack(
|
||||
# 渲染品牌 Logo
|
||||
rx.image(
|
||||
src="/logo.png",
|
||||
width="34px",
|
||||
height="34px",
|
||||
object_fit="contain", # 等比缩放
|
||||
),
|
||||
# 渲染品牌名称
|
||||
rx.text(
|
||||
"Gluballu",
|
||||
line_height="20px", # 行高
|
||||
|
|
|
|||
|
|
@ -143,18 +143,6 @@ class ConversationState(rx.State):
|
|||
conversation = self.conversations.get(self.conversation_id)
|
||||
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
|
||||
def get_runs(self) -> Dict[str, Run]:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Reference in New Issue