Skip to content

feat: 为 ChatKit Voice 添加自定义 system prompt 支持#482

Merged
chenyme merged 5 commits intochenyme:mainfrom
ekti123456:main
Apr 20, 2026
Merged

feat: 为 ChatKit Voice 添加自定义 system prompt 支持#482
chenyme merged 5 commits intochenyme:mainfrom
ekti123456:main

Conversation

@ekti123456
Copy link
Copy Markdown
Contributor

Summary

为 ChatKit Voice 添加自定义 system prompt 支持。

用户可在工具栏输入自定义提示词,通过 instructions + is_raw_instructions: true 字段传给 Grok LiveKit 后端,替代预定义的 personality 模板。

修改了 5 个文件,形成完整透传链路:

  • xai_livekit.py — payload 构建层:当 custom_instruction 非空时,使用 instructions + is_raw_instructions + personality=null 替代默认 personality 模板
  • livekit.py — transport 层透传 custom_instruction 参数
  • voice.py — API 端点接收前端 instruction 查询参数
  • chatkit.html — 工具栏新增「提示词」输入框
  • chatkit.js — 将输入框值拼入请求参数

留空提示词时行为与之前完全一致,向后兼容。

Testing

本地部署验证:

  • 提示词留空 → personality 正常生效,行为不变
  • 提示词填入自定义文本 → Grok 语音回复按自定义指令扮演角色
  • 对比 Grok 网页端 voice 模式的 sessionPayload 结构,确认字段名 instructions / is_raw_instructions 与官方前端一致(从 cdn.grok.com/_next/static/chunks/ 逆向确认)

Related

Closes #

ekti123456 and others added 3 commits April 17, 2026 12:45
- Add custom_instruction parameter to xai_livekit.py payload builder
- Use 'instructions' + 'is_raw_instructions' fields instead of 'customPersonality'
- Transport layer passes custom_instruction through
- API endpoint accepts 'instruction' query param
- Frontend: add expandable input with popup modal for editing
- CSS: toolbar 520px, 4-column equal width layout, responsive on mobile
@chenyme chenyme changed the title 为 ChatKit Voice 添加自定义 system prompt 支持 feat: 为 ChatKit Voice 添加自定义 system prompt 支持 Apr 20, 2026
@chenyme chenyme merged commit b97ec77 into chenyme:main Apr 20, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants