Skip to content

Agent Input 输入框 ​

Agent 会话输入坞:磨砂容器,输入区自动限高;工具行左侧为操作原子,右侧为圆形发送按钮,生成中切换为停止按钮。

示例 ​

会话输入坞 ​

moonbit
@sumi.agent_input(
  value=current,
  placeholder="Describe your idea, or type / to use a skill",
  on_input=set_prompt.map(v => _ => v),
  on_send=set_prompt(_ => ""),
  send_disabled=current.is_empty(),
  actions=[
    @sumi.icon_button(@sumi.icon_plus_fill(size=14), aria_label="Add attachment"),
    @sumi.agent_tool_button(@sumi.icon_skill(), label="Use Skill"),
    @sumi.icon_button(@sumi.icon_at(), aria_label="Mention a reference"),
  ],
)

API ​

agent_input ​

名称类型默认值说明
valueString""当前文本(受控)
placeholderString""占位文本
rowsInt3输入区可见行数
on_inputEmit[String]—每次输入时调用
on_sendCmd—发送命令
on_stopCmd—generating 时的停止命令
send_disabledBoolfalse禁用发送按钮
send_loadingBoolfalse将图标替换为加载圈
generatingBoolfalse将发送按钮切换为停止方块
disabledBoolfalse禁用交互并降低不透明度
autofocusBool—挂载后自动聚焦
actionsArray[Html][]左侧工具原子(图标按钮、工具 pill)
childrenArray[Html]—替换输入区的富文本内容
aria_labelString—
idString—元素 id
classString—附加 class 名
attrsAttrs—附加 HTML 属性
styleArray[String][]附加内联样式

agent_tool_button ​

图标前置的工具 pill。

名称类型默认值说明
iconHtml—
label *String—12/20 标签文本
disabledBoolfalse禁用交互并降低不透明度
on_clickCmd—点击时发送的命令
idString—元素 id
classString—附加 class 名
titleString—原生 tooltip 标题
aria_labelString—
attrsAttrs—附加 HTML 属性
styleArray[String][]附加内联样式

* 必填(标签)参数——其余均为可选。