feat(ai): TDesign React Chat UI, homepage chat entry, and admin-configurable assistant content - #1599
Open
lb1038678031 wants to merge 2 commits into
Open
feat(ai): TDesign React Chat UI, homepage chat entry, and admin-configurable assistant content#1599lb1038678031 wants to merge 2 commits into
lb1038678031 wants to merge 2 commits into
Conversation
…t switches - 新建 AnswerChatBot adapter component wraps @tdesign-react/chat ChatBot with the Answer backend contract: custom SSE parsing (markdown + thinking blocks from reasoning_content), vote actions bridged to the conversation vote API, conversation history rehydration. - The AI assistant page now renders AnswerChatBot; the legacy Sender/Bubble components stay for other pages. - 新建 site AI switches: home_chat_enabled (floating AI entry on the homepage) and home_chat_guest_enabled (logged-out visitors can chat; guest sessions stay client-side and are never persisted, voting off). - POST /chat/completions moves to the unauthenticated route group; the handler enforces the guest switch itself and runs guest sessions fully in memory with a system prompt prepended. - zh/en translations for the new switches and chat strings.
…stem prompt - Expose the assistant welcome text and a suggested-questions list (one per line) as site AI settings; both render inside the single welcome message as tappable chips, matching the TDesign reference layout. - Surface the existing prompt_config (zh/en system prompt) in the admin AI settings form, and always round-trip it on save so the backend no longer silently resets configured prompts to the built-in defaults. - Localize new admin labels and assistant strings (zh_CN/en_US). - apply refreshed language packs via i18next.addResourceBundle as soon as they are fetched instead of waiting for the next full page load. - fix new-chat reset: remount the ChatBot instead of swapping the omi message store in place, which crashed the action-bar re-render for conversations with completed messages; abort in-flight streams on reset and unmount. - fix suggestion chips: deliver clicks through per-message handle操作 (the installed tdesign-web-components has no directSend support).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
注册 for free
to join this conversation on GitHub.
Already have an account?
登录 to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #1598
What
Modernize the AI assistant chat UI with TDesign React Chat and make the assistant's opening content admin-configurable, as proposed in #1598. Two commits:
feat: replace AI chat UI with TDesign React Chat and add homepage chat switchesAnswerChatBotadapter wiring the TDesignChatBotcomponent to Answer's existing/answer/api/v1/chat/completionsSSE contract:delta.contentstreams into a markdown block,delta.reasoning_contentinto a thinking block, with per-message voting, replay, and history rehydration when switching conversations.home_chat_guest_enabledswitch, logged-out visitors can chat; guest history stays client-side and voting is disabled.home_chat_enabled), reusing the same component.feat(ai): admin-configurable welcome text, suggested questions and system promptprompt_config(zh/en system prompt) is now editable in the admin AI settings form, and saving always round-trips it — previously an omitted prompt_config silently reset stored prompts to the built-in defaults.i18next.addResourceBundleas soon as they are fetched instead of waiting for the next full page load.Why
We self-host Answer as a community FAQ and wanted a streaming chat experience with thinking blocks, markdown and suggestion chips, plus control over what the assistant says and which tools the prompt advertises. TDesign React Chat provides the chat primitives; this patch keeps Answer's own backend contract unchanged apart from the guest gate and the new site-info fields.
Testing
go build ./...andgo test ./internal/schema ./internal/controllerNotes
tdesign-web-components@1.3.0-alpha.2does not implement suggestiondirectSend, so chip clicks are delivered through per-messagehandle操作and sent from the adapter. A one-line defensive guard for the component library'ssetExportpartsis applied in our deployment build; standard flows work without it.